finis implementing netns add

This commit is contained in:
netjaileRS 2024-05-11 21:18:30 +02:00
parent a510394d02
commit 5e96269a07
372 changed files with 1604 additions and 10 deletions

View File

@ -1,23 +1,49 @@
use std::fs::create_dir; use std::fs::create_dir;
use std::io::Result; use std::io::{Result, ErrorKind};
use std::fs::File;
use sys_mount::{
Mount,
MountFlags
};
const PATH_MAX:u32 = 4096; const PATH_MAX:u32 = 4096;
const NET_NS_DIR:&str = "/var/run/netns"; const NET_NS_DIR:&str = "/var/run/netns";
fn main() -> std::io::Result<()> { const PROC_NS_DIR:&str = "/proc/self/ns/net";
fn main() -> Result<()> {
create_ns_dir()?; create_ns_dir()?;
println!("Hello World"); let nsdir = format!("{}/{}",NET_NS_DIR,"fake-net");
File::create(nsdir.clone())?;
bind_ns_file(nsdir)?;
println!("end");
Ok(()) Ok(())
} }
fn create_ns_dir() -> std::io::Result<()> { fn create_ns_dir() -> Result<()> {
match create_dir(NET_NS_DIR) { match create_dir(NET_NS_DIR) {
_ => { Err(e) if e.kind() != ErrorKind::AlreadyExists => {
println!("entra 1") println!("entra 2");
Ok(())
},
Err(e) if e.kind() != std::io::ErrorKind::AlreadyExists => {
println!("entra 2")
Err(e) Err(e)
}, },
_ => {
println!("entra 1");
Ok(())
},
} }
} }
fn bind_ns_file(ns_file: String) -> Result<()> {
match create_mount(ns_file) {
Ok(_mount) => {
println!("mount succes");
Ok(())
},
Err(e) => Err(e),
}
}
fn create_mount(ns_file: String) -> std::io::Result<Mount> {
Mount::builder()
.flags(MountFlags::BIND)
.mount(PROC_NS_DIR, ns_file)
}

1
target/.rustc_info.json Normal file
View File

@ -0,0 +1 @@
{"rustc_fingerprint":6810405396222242824,"outputs":{"14371922958718593042":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/usr/lib/rust/1.75.0\noff\npacked\nunpacked\n___\ndebug_assertions\noverflow_checks\npanic=\"unwind\"\nproc_macro\nrelocation_model=\"pic\"\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_has_atomic_equal_alignment=\"16\"\ntarget_has_atomic_equal_alignment=\"32\"\ntarget_has_atomic_equal_alignment=\"64\"\ntarget_has_atomic_equal_alignment=\"8\"\ntarget_has_atomic_equal_alignment=\"ptr\"\ntarget_has_atomic_load_store\ntarget_has_atomic_load_store=\"16\"\ntarget_has_atomic_load_store=\"32\"\ntarget_has_atomic_load_store=\"64\"\ntarget_has_atomic_load_store=\"8\"\ntarget_has_atomic_load_store=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_thread_local\ntarget_vendor=\"unknown\"\nunix\n","stderr":""},"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.75.0-nightly (82e1608df 2023-12-21) (gentoo)\nbinary: rustc\ncommit-hash: 82e1608dfa6e0b5569232559e3d385fea5a93112\ncommit-date: 2023-12-21\nhost: x86_64-unknown-linux-gnu\nrelease: 1.75.0-nightly\nLLVM version: 17.0.6\n","stderr":""},"15729799797837862367":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/usr/lib/rust/1.75.0\noff\npacked\nunpacked\n___\ndebug_assertions\noverflow_checks\npanic=\"unwind\"\nproc_macro\nrelocation_model=\"pic\"\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_has_atomic_equal_alignment=\"16\"\ntarget_has_atomic_equal_alignment=\"32\"\ntarget_has_atomic_equal_alignment=\"64\"\ntarget_has_atomic_equal_alignment=\"8\"\ntarget_has_atomic_equal_alignment=\"ptr\"\ntarget_has_atomic_load_store\ntarget_has_atomic_load_store=\"16\"\ntarget_has_atomic_load_store=\"32\"\ntarget_has_atomic_load_store=\"64\"\ntarget_has_atomic_load_store=\"8\"\ntarget_has_atomic_load_store=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_thread_local\ntarget_vendor=\"unknown\"\nunix\n","stderr":""}},"successes":{}}

3
target/CACHEDIR.TAG Normal file
View File

@ -0,0 +1,3 @@
Signature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag created by cargo.
# For information about cache directory tags see https://bford.info/cachedir/

0
target/debug/.cargo-lock Normal file
View File

View File

@ -0,0 +1 @@
bdae259f81fa1a5e

View File

@ -0,0 +1 @@
{"rustc":13421329839480389204,"features":"[\"runtime\"]","target":2297296889237502566,"profile":13232757476167777671,"path":16441280068773014788,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/bindgen-3e9776b5caf0602b/dep-build-script-build-script-build"}}],"rustflags":[],"metadata":12047033523087941064,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
{"rustc":13421329839480389204,"features":"","target":0,"profile":0,"path":0,"deps":[[16657950103275413129,"build_script_build",false,6781007623587475133],[3645781541664732627,"build_script_build",false,13381621582300735131]],"local":[{"RerunIfEnvChanged":{"var":"LLVM_CONFIG_PATH","val":null}},{"RerunIfEnvChanged":{"var":"LIBCLANG_PATH","val":null}},{"RerunIfEnvChanged":{"var":"LIBCLANG_STATIC_PATH","val":null}},{"RerunIfEnvChanged":{"var":"BINDGEN_EXTRA_CLANG_ARGS","val":null}},{"RerunIfEnvChanged":{"var":"BINDGEN_EXTRA_CLANG_ARGS_x86_64-unknown-linux-gnu","val":null}},{"RerunIfEnvChanged":{"var":"BINDGEN_EXTRA_CLANG_ARGS_x86_64_unknown_linux_gnu","val":null}}],"rustflags":[],"metadata":0,"config":0,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
a0c36e22caab4da7

View File

@ -0,0 +1 @@
{"rustc":13421329839480389204,"features":"[\"runtime\"]","target":16970473089856473606,"profile":13232757476167777671,"path":10135709493537907987,"deps":[[781203651122893512,"itertools",false,1196255805855801766],[1098045598771442027,"rustc_hash",false,15873768857435819073],[3315648657471645960,"syn",false,5069628571888748611],[3645781541664732627,"clang_sys",false,3586882353191584289],[6685014296130524576,"lazy_static",false,14456438003198516100],[7667881417093566568,"regex",false,10131567605926034710],[7803147409971559194,"bitflags",false,13774089662621865957],[9919038314455684856,"cexpr",false,9758609279652146378],[12879454158807538225,"proc_macro2",false,6269066671878042494],[14268468010440576439,"quote",false,934534267851553249],[15215384180442390425,"shlex",false,1155142216850249724],[16657950103275413129,"build_script_build",false,3173400543433163944],[17982777832778715688,"lazycell",false,3696227459918614681]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/bindgen-975d40f2171e6a4b/dep-lib-bindgen"}}],"rustflags":[],"metadata":12047033523087941064,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
e5d7f4e4916527bf

View File

@ -0,0 +1 @@
{"rustc":13421329839480389204,"features":"[]","target":17263469766201294439,"profile":13232757476167777671,"path":12965942823663347115,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/bitflags-7c79278797171fe4/dep-lib-bitflags"}}],"rustflags":[],"metadata":14564035643000669268,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
c2de4d22c149740b

View File

@ -0,0 +1 @@
{"rustc":13421329839480389204,"features":"[]","target":17263469766201294439,"profile":10243973527296709326,"path":12965942823663347115,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/bitflags-e2ec6af07d04812b/dep-lib-bitflags"}}],"rustflags":[],"metadata":14564035643000669268,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
ca2c7fbf6f8b6d87

View File

@ -0,0 +1 @@
{"rustc":13421329839480389204,"features":"[]","target":6156026458003474340,"profile":13232757476167777671,"path":16781895747561641039,"deps":[[6954241390595330609,"nom",false,18266198037604573168]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/cexpr-9030ae258cba2f75/dep-lib-cexpr"}}],"rustflags":[],"metadata":10749519017815238760,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
d9d668884144ab04

View File

@ -0,0 +1 @@
{"rustc":13421329839480389204,"features":"[]","target":10623512480563079566,"profile":13232757476167777671,"path":6989630276718306723,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/cfg-if-567b18db5e64b918/dep-lib-cfg-if"}}],"rustflags":[],"metadata":8462187951337715540,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
{"rustc":13421329839480389204,"features":"","target":0,"profile":0,"path":0,"deps":[[3645781541664732627,"build_script_build",false,7944119245256798479]],"local":[{"Precalculated":"1.7.0"}],"rustflags":[],"metadata":0,"config":0,"compile_kind":0}

View File

@ -0,0 +1 @@
0f31e0225d2e3f6e

View File

@ -0,0 +1 @@
{"rustc":13421329839480389204,"features":"[\"clang_3_5\", \"clang_3_6\", \"clang_3_7\", \"clang_3_8\", \"clang_3_9\", \"clang_4_0\", \"clang_5_0\", \"clang_6_0\", \"libloading\", \"runtime\"]","target":8188216131759486267,"profile":13232757476167777671,"path":3264583103793129916,"deps":[[11695236103535428844,"glob",false,12405090853772603720]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/clang-sys-78aed8adf867dace/dep-build-script-build-script-build"}}],"rustflags":[],"metadata":16670924540240920614,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
21021a017f2ac731

View File

@ -0,0 +1 @@
{"rustc":13421329839480389204,"features":"[\"clang_3_5\", \"clang_3_6\", \"clang_3_7\", \"clang_3_8\", \"clang_3_9\", \"clang_4_0\", \"clang_5_0\", \"clang_6_0\", \"libloading\", \"runtime\"]","target":3695163521108343623,"profile":13232757476167777671,"path":7073536676544276869,"deps":[[3645781541664732627,"build_script_build",false,13381621582300735131],[4419231006748921122,"libloading",false,11846970560759831048],[11695236103535428844,"glob",false,12405090853772603720],[11943424025318460506,"libc",false,11606914615387550226]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/clang-sys-8c39b8e66d6251b3/dep-lib-clang-sys"}}],"rustflags":[],"metadata":16670924540240920614,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
16937f196a70c830

View File

@ -0,0 +1 @@
{"rustc":13421329839480389204,"features":"[]","target":10519268927367075084,"profile":13232757476167777671,"path":1720556288695834191,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/either-7f1aafcb85617e4f/dep-lib-either"}}],"rustflags":[],"metadata":14516623572814205243,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
567ef77b93dc2f50

View File

@ -0,0 +1 @@
{"rustc":13421329839480389204,"features":"[\"default\", \"std\"]","target":11546544995965262184,"profile":10243973527296709326,"path":998331986172328999,"deps":[[11943424025318460506,"libc",false,16460702754235035181]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/errno-1285d090b447ed2d/dep-lib-errno"}}],"rustflags":[],"metadata":10194485576052114626,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
4831901168bc27ac

View File

@ -0,0 +1 @@
{"rustc":13421329839480389204,"features":"[]","target":8253681438955412652,"profile":13232757476167777671,"path":9830485311862484433,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/glob-ead686df6db2d0d2/dep-lib-glob"}}],"rustflags":[],"metadata":17263181195404352091,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
a6a1884051f49910

View File

@ -0,0 +1 @@
{"rustc":13421329839480389204,"features":"[]","target":14692798381618873247,"profile":13232757476167777671,"path":2949816092772279414,"deps":[[6935445623804880264,"either",false,3515183110159307542]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/itertools-eb25c028faf0a7e0/dep-lib-itertools"}}],"rustflags":[],"metadata":3730724209676955614,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
84db1a3ac5959fc8

View File

@ -0,0 +1 @@
{"rustc":13421329839480389204,"features":"[]","target":1623840821729021818,"profile":13232757476167777671,"path":1487154540886443234,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/lazy_static-8b2339b61f5e2c85/dep-lib-lazy_static"}}],"rustflags":[],"metadata":111743654650316589,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
99507e954aa34b33

View File

@ -0,0 +1 @@
{"rustc":13421329839480389204,"features":"[]","target":575067042841070665,"profile":13232757476167777671,"path":13055925064691433295,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/lazycell-470586395cc53f3d/dep-lib-lazycell"}}],"rustflags":[],"metadata":9081195101616900511,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
12f276bc580b14a1

View File

@ -0,0 +1 @@
{"rustc":13421329839480389204,"features":"[]","target":1307715644349195660,"profile":13232757476167777671,"path":16306975430689204783,"deps":[[11943424025318460506,"build_script_build",false,5339920507148141619]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/libc-144e073b48013196/dep-lib-libc"}}],"rustflags":[],"metadata":14998826085014762512,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
338463bd68351b4a

View File

@ -0,0 +1 @@
{"rustc":13421329839480389204,"features":"","target":0,"profile":0,"path":0,"deps":[[11943424025318460506,"build_script_build",false,276242517182491292]],"local":[{"RerunIfChanged":{"output":"debug/build/libc-2bb74d82bcdc5b66/output","paths":["build.rs"]}}],"rustflags":[],"metadata":0,"config":0,"compile_kind":0}

View File

@ -0,0 +1 @@
4e17334686a15327

View File

@ -0,0 +1 @@
{"rustc":13421329839480389204,"features":"[\"default\", \"std\"]","target":8188216131759486267,"profile":13232757476167777671,"path":14629593345852939220,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/libc-5378183b3bfe9c14/dep-build-script-build-script-build"}}],"rustflags":[],"metadata":14998826085014762512,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
9caa85141b69d503

View File

@ -0,0 +1 @@
{"rustc":13421329839480389204,"features":"[]","target":8188216131759486267,"profile":13232757476167777671,"path":14629593345852939220,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/libc-5ca29d649947216f/dep-build-script-build-script-build"}}],"rustflags":[],"metadata":14998826085014762512,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
2d2e7943f12970e4

View File

@ -0,0 +1 @@
{"rustc":13421329839480389204,"features":"[\"default\", \"std\"]","target":1307715644349195660,"profile":10243973527296709326,"path":16306975430689204783,"deps":[[11943424025318460506,"build_script_build",false,13120215139248425157]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/libc-6975844e7d95d870/dep-lib-libc"}}],"rustflags":[],"metadata":14998826085014762512,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
c5c89abf275e14b6

View File

@ -0,0 +1 @@
{"rustc":13421329839480389204,"features":"","target":0,"profile":0,"path":0,"deps":[[11943424025318460506,"build_script_build",false,2833786188621616974]],"local":[{"RerunIfChanged":{"output":"debug/build/libc-e4a2dcb608421939/output","paths":["build.rs"]}}],"rustflags":[],"metadata":0,"config":0,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
089a9902f5e468a4

View File

@ -0,0 +1 @@
{"rustc":13421329839480389204,"features":"[]","target":3904882595153906123,"profile":13232757476167777671,"path":3571735269864537879,"deps":[[2452538001284770427,"cfg_if",false,336437645421369049]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/libloading-63728d76c9803c81/dep-lib-libloading"}}],"rustflags":[],"metadata":17567831315501188372,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
eba24ab09c8ddd1b

View File

@ -0,0 +1 @@
{"rustc":13421329839480389204,"features":"[]","target":13644624891050830270,"profile":10243973527296709326,"path":6012871159122769333,"deps":[[1261317733641946338,"build_script_build",false,417388446600888254],[11943424025318460506,"libc",false,16460702754235035181],[16536619557110832369,"errno",false,5778079372937756246]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/loopdev-3-1a3e3939b58c79cd/dep-lib-loopdev"}}],"rustflags":[],"metadata":2868171966936601121,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
{"rustc":13421329839480389204,"features":"","target":0,"profile":0,"path":0,"deps":[[1261317733641946338,"build_script_build",false,17777823683492348861]],"local":[{"Precalculated":"0.5.1"}],"rustflags":[],"metadata":0,"config":0,"compile_kind":0}

View File

@ -0,0 +1 @@
bd8316fe7284b7f6

View File

@ -0,0 +1 @@
{"rustc":13421329839480389204,"features":"[]","target":427768481117760528,"profile":13232757476167777671,"path":11074135987642926396,"deps":[[16657950103275413129,"bindgen",false,12055480662190113696]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/loopdev-3-5395c7b494bd7d9c/dep-build-script-build-script-build"}}],"rustflags":[],"metadata":2868171966936601121,"config":2202906307356721367,"compile_kind":0}

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

View File

@ -0,0 +1 @@
This file has an mtime of when this was started.

Some files were not shown because too many files have changed in this diff Show More