starnix_uapi/
mount_flags.rs1use crate::uapi;
6use bitflags::bitflags;
7
8bitflags! {
9 #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
10 pub struct MountFlags: u32 {
11 const RDONLY = uapi::MS_RDONLY;
13 const NOEXEC = uapi::MS_NOEXEC;
14 const NOSUID = uapi::MS_NOSUID;
15 const NODEV = uapi::MS_NODEV;
16 const NOATIME = uapi::MS_NOATIME;
17 const NODIRATIME = uapi::MS_NODIRATIME;
18 const RELATIME = uapi::MS_RELATIME;
19 const STRICTATIME = uapi::MS_STRICTATIME;
20
21 const SILENT = uapi::MS_SILENT;
23 const LAZYTIME = uapi::MS_LAZYTIME;
24 const SYNCHRONOUS = uapi::MS_SYNCHRONOUS;
25 const DIRSYNC = uapi::MS_DIRSYNC;
26 const MANDLOCK = uapi::MS_MANDLOCK;
27
28 const REMOUNT = uapi::MS_REMOUNT;
30 const BIND = uapi::MS_BIND;
31 const REC = uapi::MS_REC;
32 const DOWNSTREAM = uapi::MS_SLAVE;
33 const SHARED = uapi::MS_SHARED;
34 const PRIVATE = uapi::MS_PRIVATE;
35
36 const STORED_ON_MOUNT = Self::RDONLY.bits() | Self::NOEXEC.bits() | Self::NOSUID.bits() |
38 Self::NODEV.bits() | Self::NOATIME.bits() | Self::NODIRATIME.bits() | Self::RELATIME.bits();
39
40 const STORED_ON_FILESYSTEM = Self::RDONLY.bits() | Self::DIRSYNC.bits() | Self::LAZYTIME.bits() |
42 Self::MANDLOCK.bits() | Self::SILENT.bits() | Self::SYNCHRONOUS.bits();
43
44 const CHANGEABLE_WITH_REMOUNT = Self::STORED_ON_MOUNT.bits() | Self::STRICTATIME.bits() |
48 Self::MANDLOCK.bits() | Self::LAZYTIME.bits() | Self::SYNCHRONOUS.bits();
49 }
50}
51
52impl std::fmt::Display for MountFlags {
53 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
54 write!(f, "{}", if self.contains(Self::RDONLY) { "ro" } else { "rw" })?;
55 if self.contains(Self::NOEXEC) {
56 write!(f, ",noexec")?;
57 }
58 if self.contains(Self::NOSUID) {
59 write!(f, ",nosuid")?;
60 }
61 if self.contains(Self::NODEV) {
62 write!(f, ",nodev")?
63 }
64 if self.contains(Self::NOATIME) {
65 write!(f, ",noatime")?;
66 }
67 if self.contains(Self::NOEXEC) {
68 write!(f, ",noexec")?;
69 }
70 if self.contains(Self::SILENT) {
71 write!(f, ",silent")?;
72 }
73 if self.contains(Self::BIND) {
74 write!(f, ",bind")?;
75 }
76 if self.contains(Self::LAZYTIME) {
77 write!(f, ",lazytime")?;
78 }
79 Ok(())
80 }
81}