| 1 | extern crate libmountrust-analyzer cargo libmount 0.1.15 libmount/; |
| 2 | extern crate argparserust-analyzer cargo libmount 0.1.15 argparse/; |
| 3 | extern crate env_loggerrust-analyzer cargo libmount 0.1.15 env_logger/; |
| 4 | #[macro_use] extern crate logrust-analyzer cargo libmount 0.1.15 log/; |
| 5 | |
| 6 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#; |
| 7 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::processrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/::exitrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/exit().; |
| 8 | |
| 9 | use argparserust-analyzer cargo argparse 0.2.2 crate/::{ArgumentParserrust-analyzer cargo argparse 0.2.2 parser/ArgumentParser#, Parserust-analyzer cargo argparse 0.2.2 Parse#, StoreOptionrust-analyzer cargo argparse 0.2.2 StoreOption#}; |
| 10 | |
| 11 | |
| 12 | fn mainrust-analyzer cargo libmount 0.1.15 main().() { |
| 13 | env_loggerrust-analyzer cargo env_logger 0.11.11 crate/::initrust-analyzer cargo env_logger 0.11.11 logger/init().(); |
| 14 | let mut target = PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf]new().(); |
| 15 | let mut size = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#::<usize>; |
| 16 | let mut mode = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>; |
| 17 | let mut uid = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#::<u32>; |
| 18 | let mut gid = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#::<u32>; |
| 19 | { |
| 20 | let mut ap = ArgumentParserrust-analyzer cargo argparse 0.2.2 parser/ArgumentParser#::newrust-analyzer cargo argparse 0.2.2 parser/impl#[`ArgumentParser<'parser>`]new().(); |
| 21 | ap.set_descriptionrust-analyzer cargo argparse 0.2.2 parser/impl#[`ArgumentParser<'parser>`]set_description().("Tmpfs mount utility. Similar to `mount --tmpfs`"); |
| 22 | ap.referrust-analyzer cargo argparse 0.2.2 parser/impl#[`ArgumentParser<'parser>`]refer().(&mut target).add_argumentrust-analyzer cargo argparse 0.2.2 parser/impl#[`Ref<'parser, 'refer, T>`]add_argument().("target", Parserust-analyzer cargo argparse 0.2.2 Parse#, |
| 23 | "Target directory to mount tmpfs to").requiredrust-analyzer cargo argparse 0.2.2 parser/impl#[`Ref<'parser, 'refer, T>`]required().(); |
| 24 | ap.referrust-analyzer cargo argparse 0.2.2 parser/impl#[`ArgumentParser<'parser>`]refer().(&mut size).add_optionrust-analyzer cargo argparse 0.2.2 parser/impl#[`Ref<'parser, 'refer, T>`]add_option().(&["--size"], StoreOptionrust-analyzer cargo argparse 0.2.2 StoreOption#, |
| 25 | "Set size of the filesystem"); |
| 26 | ap.referrust-analyzer cargo argparse 0.2.2 parser/impl#[`ArgumentParser<'parser>`]refer().(&mut mode).add_optionrust-analyzer cargo argparse 0.2.2 parser/impl#[`Ref<'parser, 'refer, T>`]add_option().(&["--mode"], StoreOptionrust-analyzer cargo argparse 0.2.2 StoreOption#, |
| 27 | "Set mode of the root directory"); |
| 28 | ap.referrust-analyzer cargo argparse 0.2.2 parser/impl#[`ArgumentParser<'parser>`]refer().(&mut uid).add_optionrust-analyzer cargo argparse 0.2.2 parser/impl#[`Ref<'parser, 'refer, T>`]add_option().(&["--uid"], StoreOptionrust-analyzer cargo argparse 0.2.2 StoreOption#, |
| 29 | "Set uid of the directory"); |
| 30 | ap.referrust-analyzer cargo argparse 0.2.2 parser/impl#[`ArgumentParser<'parser>`]refer().(&mut gid).add_optionrust-analyzer cargo argparse 0.2.2 parser/impl#[`Ref<'parser, 'refer, T>`]add_option().(&["--gid"], StoreOptionrust-analyzer cargo argparse 0.2.2 StoreOption#, |
| 31 | "Set gid of the directory"); |
| 32 | ap.parse_args_or_exitrust-analyzer cargo argparse 0.2.2 parser/impl#[`ArgumentParser<'parser>`]parse_args_or_exit().(); |
| 33 | } |
| 34 | let mut mnt = libmountrust-analyzer cargo libmount 0.1.15 crate/::Tmpfsrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#::newrust-analyzer cargo libmount 0.1.15 tmpfs/impl#[Tmpfs]new().(target); |
| 35 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(x) = size { mnt = mnt.size_bytesrust-analyzer cargo libmount 0.1.15 tmpfs/impl#[Tmpfs]size_bytes().(x); }; |
| 36 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ref x) = mode { |
| 37 | mnt = mnt.moderust-analyzer cargo libmount 0.1.15 tmpfs/impl#[Tmpfs]mode().(u32::from_str_radixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]from_str_radix().(x, 8).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("valid octal mode")); |
| 38 | } |
| 39 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(x) = uid { mnt = mnt.uidrust-analyzer cargo libmount 0.1.15 tmpfs/impl#[Tmpfs]uid().(x); } |
| 40 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(x) = gid { mnt = mnt.gidrust-analyzer cargo libmount 0.1.15 tmpfs/impl#[Tmpfs]gid().(x); } |
| 41 | match mnt.mountrust-analyzer cargo libmount 0.1.15 tmpfs/impl#[Tmpfs]mount().() { |
| 42 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) => {} |
| 43 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) => { |
| 44 | errorrust-analyzer cargo log 0.4.34 macros/error!!("{}", e); |
| 45 | exitrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/exit().(1); |
| 46 | } |
| 47 | } |
| 48 | } |