| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::{Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#, Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#}; |
| 2 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/; |
| 3 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().; |
| 4 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::ffirust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/::{CStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/CString#, CStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_str/CStr#}; |
| 5 | 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/::Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#; |
| 6 | |
| 7 | use libcrust-analyzer cargo libc 0.2.189 crate/::{uid_trust-analyzer cargo libc 0.2.189 unix/uid_t#, gid_trust-analyzer cargo libc 0.2.189 unix/gid_t#, mode_trust-analyzer cargo libc 0.2.189 unix/linux_like/linux/mode_t#}; |
| 8 | use nixrust-analyzer cargo nix 0.31.3 crate/::mountrust-analyzer cargo nix 0.31.3 mount/::{MsFlagsrust-analyzer cargo nix 0.31.3 mount/linux/MsFlags#, mountrust-analyzer cargo nix 0.31.3 mount/linux/mount().}; |
| 9 | |
| 10 | use {OSErrorrust-analyzer cargo libmount 0.1.15 OSError#, Errorrust-analyzer cargo libmount 0.1.15 Error#}; |
| 11 | use util::{path_to_cstring, as_path}; |
| 12 | use explain::{Explainable, exists, user}; |
| 13 | |
| 14 | |
| 15 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:)] |
| 16 | enum Sizerust-analyzer cargo libmount 0.1.15 tmpfs/Size# { |
| 17 | Autorust-analyzer cargo libmount 0.1.15 tmpfs/Size#Auto#, |
| 18 | Bytesrust-analyzer cargo libmount 0.1.15 tmpfs/Size#Bytes#(usize), |
| 19 | Blocksrust-analyzer cargo libmount 0.1.15 tmpfs/Size#Blocks#(usize), |
| 20 | } |
| 21 | |
| 22 | /// A tmpfs mount definition |
| 23 | /// |
| 24 | /// By default tmpfs is mounted with nosuid,nodev |
| 25 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 26 | pub struct Tmpfsrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs# { |
| 27 | targetrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#target.: CStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/CString#, |
| 28 | sizerust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#size.: Sizerust-analyzer cargo libmount 0.1.15 tmpfs/Size#, |
| 29 | nr_inodesrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#nr_inodes.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>, |
| 30 | moderust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#mode.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<mode_trust-analyzer cargo libc 0.2.189 unix/linux_like/linux/mode_t#>, |
| 31 | uidrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#uid.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<uid_trust-analyzer cargo libc 0.2.189 unix/uid_t#>, |
| 32 | gidrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#gid.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<gid_trust-analyzer cargo libc 0.2.189 unix/gid_t#>, |
| 33 | flagsrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#flags.: MsFlagsrust-analyzer cargo nix 0.31.3 mount/linux/MsFlags#, |
| 34 | } |
| 35 | |
| 36 | impl Tmpfsrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs# { |
| 37 | /// New tmpfs mount point with target path and default settngs |
| 38 | pub fn newrust-analyzer cargo libmount 0.1.15 tmpfs/impl#[Tmpfs]new().<P: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#>>(path: P) -> Tmpfsrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs# { |
| 39 | Tmpfsrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs# { |
| 40 | targetrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#target.: path_to_cstringrust-analyzer cargo libmount 0.1.15 util/path_to_cstring().(path.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().()), |
| 41 | sizerust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#size.: Sizerust-analyzer cargo libmount 0.1.15 tmpfs/Size#::Autorust-analyzer cargo libmount 0.1.15 tmpfs/Size#Auto#, |
| 42 | nr_inodesrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#nr_inodes.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 43 | moderust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#mode.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 44 | uidrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#uid.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 45 | gidrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#gid.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 46 | flagsrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#flags.: MsFlagsrust-analyzer cargo nix 0.31.3 mount/linux/MsFlags#::MS_NOSUIDrust-analyzer cargo nix 0.31.3 mount/linux/impl#[MsFlags]MS_NOSUID.|rust-analyzer cargo nix 0.31.3 mount/linux/impl#[MsFlags][`BitOr<Self>`]bitor().MsFlagsrust-analyzer cargo nix 0.31.3 mount/linux/MsFlags#::MS_NODEVrust-analyzer cargo nix 0.31.3 mount/linux/impl#[MsFlags]MS_NODEV., |
| 47 | } |
| 48 | } |
| 49 | /// Set size in bytes |
| 50 | pub fn size_bytesrust-analyzer cargo libmount 0.1.15 tmpfs/impl#[Tmpfs]size_bytes().(mut self, size: usize) -> Tmpfsrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs# { |
| 51 | self.sizerust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#size. = Sizerust-analyzer cargo libmount 0.1.15 tmpfs/Size#::Bytesrust-analyzer cargo libmount 0.1.15 tmpfs/Size#Bytes#(size); |
| 52 | self |
| 53 | } |
| 54 | /// Set size in blocks of PAGE_CACHE_SIZE |
| 55 | pub fn size_blocksrust-analyzer cargo libmount 0.1.15 tmpfs/impl#[Tmpfs]size_blocks().(mut self, size: usize) -> Tmpfsrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs# { |
| 56 | self.sizerust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#size. = Sizerust-analyzer cargo libmount 0.1.15 tmpfs/Size#::Blocksrust-analyzer cargo libmount 0.1.15 tmpfs/Size#Blocks#(size); |
| 57 | self |
| 58 | } |
| 59 | /// Maximum number of inodes |
| 60 | pub fn nr_inodesrust-analyzer cargo libmount 0.1.15 tmpfs/impl#[Tmpfs]nr_inodes().(mut self, num: usize) -> Tmpfsrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs# { |
| 61 | self.nr_inodesrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#nr_inodes. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(num); |
| 62 | self |
| 63 | } |
| 64 | /// Set initial permissions of the root directory |
| 65 | pub fn moderust-analyzer cargo libmount 0.1.15 tmpfs/impl#[Tmpfs]mode().(mut self, mode: mode_trust-analyzer cargo libc 0.2.189 unix/linux_like/linux/mode_t#) -> Tmpfsrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs# { |
| 66 | self.moderust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#mode. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(mode); |
| 67 | self |
| 68 | } |
| 69 | /// Set initial owner of the root directory |
| 70 | pub fn uidrust-analyzer cargo libmount 0.1.15 tmpfs/impl#[Tmpfs]uid().(mut self, uid: uid_trust-analyzer cargo libc 0.2.189 unix/uid_t#) -> Tmpfsrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs# { |
| 71 | self.uidrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#uid. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(uid); |
| 72 | self |
| 73 | } |
| 74 | /// Set initial group of the root directory |
| 75 | pub fn gidrust-analyzer cargo libmount 0.1.15 tmpfs/impl#[Tmpfs]gid().(mut self, gid: gid_trust-analyzer cargo libc 0.2.189 unix/gid_t#) -> Tmpfsrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs# { |
| 76 | self.gidrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#gid. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(gid); |
| 77 | self |
| 78 | } |
| 79 | |
| 80 | fn format_optionsrust-analyzer cargo libmount 0.1.15 tmpfs/impl#[Tmpfs]format_options().(&self) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> { |
| 81 | let mut cur = Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]new().(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().()); |
| 82 | match self.sizerust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#size. { |
| 83 | Sizerust-analyzer cargo libmount 0.1.15 tmpfs/Size#::Autorust-analyzer cargo libmount 0.1.15 tmpfs/Size#Auto# => {} |
| 84 | Sizerust-analyzer cargo libmount 0.1.15 tmpfs/Size#::Bytesrust-analyzer cargo libmount 0.1.15 tmpfs/Size#Bytes#(x) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(cur, "size={}", x).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 85 | Sizerust-analyzer cargo libmount 0.1.15 tmpfs/Size#::Blocksrust-analyzer cargo libmount 0.1.15 tmpfs/Size#Blocks#(x) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(cur, "nr_blocks={}", x).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 86 | } |
| 87 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(inodes) = self.nr_inodesrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#nr_inodes. { |
| 88 | if cur.positionrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]position().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne().0 { |
| 89 | cur.writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<Vec<u8, A>>`][Write]write().(b",").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 90 | } |
| 91 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(cur, "nr_inodes={}", inodes).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 92 | } |
| 93 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(mode) = self.moderust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#mode. { |
| 94 | if cur.positionrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]position().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne().0 { |
| 95 | cur.writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<Vec<u8, A>>`][Write]write().(b",").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 96 | } |
| 97 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(cur, "mode=0{:04o}", mode).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 98 | } |
| 99 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(uid) = self.uidrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#uid. { |
| 100 | if cur.positionrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]position().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne().0 { |
| 101 | cur.writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<Vec<u8, A>>`][Write]write().(b",").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 102 | } |
| 103 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(cur, "uid={}", uid).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 104 | } |
| 105 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(gid) = self.gidrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#gid. { |
| 106 | if cur.positionrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]position().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne().0 { |
| 107 | cur.writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<Vec<u8, A>>`][Write]write().(b",").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 108 | } |
| 109 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(cur, "gid={}", gid).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 110 | } |
| 111 | return cur.into_innerrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]into_inner().(); |
| 112 | } |
| 113 | |
| 114 | /// Mount the tmpfs |
| 115 | pub fn bare_mountrust-analyzer cargo libmount 0.1.15 tmpfs/impl#[Tmpfs]bare_mount().(self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), OSErrorrust-analyzer cargo libmount 0.1.15 OSError#> { |
| 116 | let mut options = self.format_optionsrust-analyzer cargo libmount 0.1.15 tmpfs/impl#[Tmpfs]format_options().(); |
| 117 | mountrust-analyzer cargo nix 0.31.3 mount/linux/mount().( |
| 118 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(CStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_str/CStr#::from_bytes_with_nulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_str/impl#[CStr]from_bytes_with_nul().(b"tmpfs\0").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()), |
| 119 | &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/impl#[CString][Deref]deref().self.targetrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#target., |
| 120 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(CStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_str/CStr#::from_bytes_with_nulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_str/impl#[CStr]from_bytes_with_nul().(b"tmpfs\0").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()), |
| 121 | self.flagsrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#flags., |
| 122 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Deref]deref().options) |
| 123 | ).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|err| OSErrorrust-analyzer cargo libmount 0.1.15 OSError#::from_nixrust-analyzer cargo libmount 0.1.15 impl#[OSError]from_nix().(err, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(self))) |
| 124 | } |
| 125 | |
| 126 | /// Mount the tmpfs and explain error immediately |
| 127 | pub fn mountrust-analyzer cargo libmount 0.1.15 tmpfs/impl#[Tmpfs]mount().(self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo libmount 0.1.15 Error#> { |
| 128 | self.bare_mountrust-analyzer cargo libmount 0.1.15 tmpfs/impl#[Tmpfs]bare_mount().().map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(OSErrorrust-analyzer cargo libmount 0.1.15 OSError#::explainrust-analyzer cargo libmount 0.1.15 error/impl#[OSError]explain().) |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | impl fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for Tmpfsrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs# { |
| 133 | fn fmtrust-analyzer cargo libmount 0.1.15 tmpfs/impl#[Tmpfs][Display]fmt().(&self, fmt: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 134 | let opts = self.format_optionsrust-analyzer cargo libmount 0.1.15 tmpfs/impl#[Tmpfs]format_options().(); |
| 135 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(fmt, "tmpfs {} -> {:?}", from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(&opts).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 136 | as_pathrust-analyzer cargo libmount 0.1.15 util/as_path().(&self.targetrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#target.)) |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | impl Explainablerust-analyzer cargo libmount 0.1.15 explain/Explainable# for Tmpfsrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs# { |
| 141 | fn explainrust-analyzer cargo libmount 0.1.15 tmpfs/impl#[Tmpfs][Explainable]explain().(&self) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 142 | [ |
| 143 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("target: {}", existsrust-analyzer cargo libmount 0.1.15 explain/exists().(as_pathrust-analyzer cargo libmount 0.1.15 util/as_path().(&self.targetrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#target.))), |
| 144 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", userrust-analyzer cargo libmount 0.1.15 explain/user().()), |
| 145 | ].joinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]join().(", ") |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | |
| 150 | mod testrust-analyzer cargo libmount 0.1.15 tmpfs/test/ { |
| 151 | #[cfg(test)] |
| 152 | use superrust-analyzer cargo libmount 0.1.15 tmpfs/::Tmpfsrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#; |
| 153 | |
| 154 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 155 | fn test_tmpfs_optionsrust-analyzer cargo libmount 0.1.15 tmpfs/test/test_tmpfs_options().() { |
| 156 | let fs = Tmpfsrust-analyzer cargo libmount 0.1.15 tmpfs/Tmpfs#::newrust-analyzer cargo libmount 0.1.15 tmpfs/impl#[Tmpfs]new().("/tmp") |
| 157 | .size_bytesrust-analyzer cargo libmount 0.1.15 tmpfs/impl#[Tmpfs]size_bytes().(1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<i32>`]shl().20) |
| 158 | .nr_inodesrust-analyzer cargo libmount 0.1.15 tmpfs/impl#[Tmpfs]nr_inodes().(1024) |
| 159 | .moderust-analyzer cargo libmount 0.1.15 tmpfs/impl#[Tmpfs]mode().(0o1777) |
| 160 | .uidrust-analyzer cargo libmount 0.1.15 tmpfs/impl#[Tmpfs]uid().(1000) |
| 161 | .gidrust-analyzer cargo libmount 0.1.15 tmpfs/impl#[Tmpfs]gid().(1000); |
| 162 | |
| 163 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(fs.format_optionsrust-analyzer cargo libmount 0.1.15 tmpfs/impl#[Tmpfs]format_options().(), |
| 164 | "size=1048576,nr_inodes=1024,mode=01777,uid=1000,gid=1000".as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()) |
| 165 | } |
| 166 | } |