This commit is contained in:
2024-04-27 21:39:15 +02:00
commit a510394d02
7 changed files with 1145 additions and 0 deletions

23
src/main.rs Normal file
View File

@@ -0,0 +1,23 @@
use std::fs::create_dir;
use std::io::Result;
const PATH_MAX:u32 = 4096;
const NET_NS_DIR:&str = "/var/run/netns";
fn main() -> std::io::Result<()> {
create_ns_dir()?;
println!("Hello World");
Ok(())
}
fn create_ns_dir() -> std::io::Result<()> {
match create_dir(NET_NS_DIR) {
_ => {
println!("entra 1")
Ok(())
},
Err(e) if e.kind() != std::io::ErrorKind::AlreadyExists => {
println!("entra 2")
Err(e)
},
}
}

26
src/meson.build Normal file
View File

@@ -0,0 +1,26 @@
cargo_bin = find_program('cargo')
cargo_opt = [ '--manifest-path', meson.project_source_root() / 'Cargo.toml' ]
cargo_opt += [ '--target-dir', meson.project_build_root() / 'src' ]
cargo_env = [ 'CARGO_HOME=' + meson.project_build_root() / 'cargo-home' ]
if get_option('buildtype') == 'release'
cargo_options += [ '--release' ]
rust_target = 'release'
else
rust_target = 'debug'
endif
cargo_build = custom_target(
'cargo-build',
build_by_default: true,
build_always_stale: true,
output: meson.project_name(),
console: true,
install: true,
install_dir: get_option('bindir'),
command: [
'env', cargo_env,
cargo_bin, 'build',
cargo_opt, '&&', 'cp', 'src' / rust_target / meson.project_name(), '@OUTPUT@',
]
)