1 use crate::backend::c; 2 use bitflags::bitflags; 3 4 #[cfg(linux_kernel)] 5 bitflags! { 6 /// `MS_*` constants for use with [`mount`]. 7 /// 8 /// [`mount`]: crate::mount::mount 9 #[repr(transparent)] 10 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] 11 pub struct MountFlags: c::c_ulong { 12 /// `MS_BIND` 13 const BIND = c::MS_BIND; 14 15 /// `MS_DIRSYNC` 16 const DIRSYNC = c::MS_DIRSYNC; 17 18 /// `MS_LAZYTIME` 19 const LAZYTIME = c::MS_LAZYTIME; 20 21 /// `MS_MANDLOCK` 22 #[doc(alias = "MANDLOCK")] 23 const PERMIT_MANDATORY_FILE_LOCKING = c::MS_MANDLOCK; 24 25 /// `MS_NOATIME` 26 const NOATIME = c::MS_NOATIME; 27 28 /// `MS_NODEV` 29 const NODEV = c::MS_NODEV; 30 31 /// `MS_NODIRATIME` 32 const NODIRATIME = c::MS_NODIRATIME; 33 34 /// `MS_NOEXEC` 35 const NOEXEC = c::MS_NOEXEC; 36 37 /// `MS_NOSUID` 38 const NOSUID = c::MS_NOSUID; 39 40 /// `MS_RDONLY` 41 const RDONLY = c::MS_RDONLY; 42 43 /// `MS_REC` 44 const REC = c::MS_REC; 45 46 /// `MS_RELATIME` 47 const RELATIME = c::MS_RELATIME; 48 49 /// `MS_SILENT` 50 const SILENT = c::MS_SILENT; 51 52 /// `MS_STRICTATIME` 53 const STRICTATIME = c::MS_STRICTATIME; 54 55 /// `MS_SYNCHRONOUS` 56 const SYNCHRONOUS = c::MS_SYNCHRONOUS; 57 58 /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags> 59 const _ = !0; 60 } 61 } 62 63 #[cfg(linux_kernel)] 64 bitflags! { 65 /// `MNT_*` constants for use with [`unmount`]. 66 /// 67 /// [`unmount`]: crate::mount::unmount 68 #[repr(transparent)] 69 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] 70 pub struct UnmountFlags: u32 { 71 /// `MNT_FORCE` 72 const FORCE = bitcast!(c::MNT_FORCE); 73 /// `MNT_DETACH` 74 const DETACH = bitcast!(c::MNT_DETACH); 75 /// `MNT_EXPIRE` 76 const EXPIRE = bitcast!(c::MNT_EXPIRE); 77 /// `UMOUNT_NOFOLLOW` 78 const NOFOLLOW = bitcast!(c::UMOUNT_NOFOLLOW); 79 80 /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags> 81 const _ = !0; 82 } 83 } 84 85 #[cfg(feature = "mount")] 86 #[cfg(linux_kernel)] 87 bitflags! { 88 /// `FSOPEN_*` constants for use with [`fsopen`]. 89 /// 90 /// [`fsopen`]: crate::mount::fsopen 91 #[repr(transparent)] 92 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] 93 pub struct FsOpenFlags: c::c_uint { 94 /// `FSOPEN_CLOEXEC` 95 const FSOPEN_CLOEXEC = 0x0000_0001; 96 97 /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags> 98 const _ = !0; 99 } 100 } 101 102 #[cfg(feature = "mount")] 103 #[cfg(linux_kernel)] 104 bitflags! { 105 /// `FSMOUNT_*` constants for use with [`fsmount`]. 106 /// 107 /// [`fsmount`]: crate::mount::fsmount 108 #[repr(transparent)] 109 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] 110 pub struct FsMountFlags: c::c_uint { 111 /// `FSMOUNT_CLOEXEC` 112 const FSMOUNT_CLOEXEC = 0x0000_0001; 113 114 /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags> 115 const _ = !0; 116 } 117 } 118 119 /// `FSCONFIG_*` constants for use with the `fsconfig` syscall. 120 #[cfg(feature = "mount")] 121 #[cfg(linux_kernel)] 122 #[derive(Debug, Copy, Clone, Eq, PartialEq)] 123 #[repr(u32)] 124 pub(crate) enum FsConfigCmd { 125 /// `FSCONFIG_SET_FLAG` 126 SetFlag = 0, 127 128 /// `FSCONFIG_SET_STRING` 129 SetString = 1, 130 131 /// `FSCONFIG_SET_BINARY` 132 SetBinary = 2, 133 134 /// `FSCONFIG_SET_PATH` 135 SetPath = 3, 136 137 /// `FSCONFIG_SET_PATH_EMPTY` 138 SetPathEmpty = 4, 139 140 /// `FSCONFIG_SET_FD` 141 SetFd = 5, 142 143 /// `FSCONFIG_CMD_CREATE` 144 Create = 6, 145 146 /// `FSCONFIG_CMD_RECONFIGURE` 147 Reconfigure = 7, 148 } 149 150 #[cfg(feature = "mount")] 151 #[cfg(linux_kernel)] 152 bitflags! { 153 /// `MOUNT_ATTR_*` constants for use with [`fsmount`]. 154 /// 155 /// [`fsmount`]: crate::mount::fsmount 156 #[repr(transparent)] 157 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] 158 pub struct MountAttrFlags: c::c_uint { 159 /// `MOUNT_ATTR_RDONLY` 160 const MOUNT_ATTR_RDONLY = 0x0000_0001; 161 162 /// `MOUNT_ATTR_NOSUID` 163 const MOUNT_ATTR_NOSUID = 0x0000_0002; 164 165 /// `MOUNT_ATTR_NODEV` 166 const MOUNT_ATTR_NODEV = 0x0000_0004; 167 168 /// `MOUNT_ATTR_NOEXEC` 169 const MOUNT_ATTR_NOEXEC = 0x0000_0008; 170 171 /// `MOUNT_ATTR__ATIME` 172 const MOUNT_ATTR__ATIME = 0x0000_0070; 173 174 /// `MOUNT_ATTR_RELATIME` 175 const MOUNT_ATTR_RELATIME = 0x0000_0000; 176 177 /// `MOUNT_ATTR_NOATIME` 178 const MOUNT_ATTR_NOATIME = 0x0000_0010; 179 180 /// `MOUNT_ATTR_STRICTATIME` 181 const MOUNT_ATTR_STRICTATIME = 0x0000_0020; 182 183 /// `MOUNT_ATTR_NODIRATIME` 184 const MOUNT_ATTR_NODIRATIME = 0x0000_0080; 185 186 /// `MOUNT_ATTR_NOUSER` 187 const MOUNT_ATTR_IDMAP = 0x0010_0000; 188 189 /// `MOUNT_ATTR__ATIME_FLAGS` 190 const MOUNT_ATTR_NOSYMFOLLOW = 0x0020_0000; 191 192 /// `MOUNT_ATTR__ATIME_FLAGS` 193 const MOUNT_ATTR_SIZE_VER0 = 32; 194 195 /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags> 196 const _ = !0; 197 } 198 } 199 200 #[cfg(feature = "mount")] 201 #[cfg(linux_kernel)] 202 bitflags! { 203 /// `MOVE_MOUNT_*` constants for use with [`move_mount`]. 204 /// 205 /// [`move_mount`]: crate::mount::move_mount 206 #[repr(transparent)] 207 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] 208 pub struct MoveMountFlags: c::c_uint { 209 /// `MOVE_MOUNT_F_EMPTY_PATH` 210 const MOVE_MOUNT_F_SYMLINKS = 0x0000_0001; 211 212 /// `MOVE_MOUNT_F_AUTOMOUNTS` 213 const MOVE_MOUNT_F_AUTOMOUNTS = 0x0000_0002; 214 215 /// `MOVE_MOUNT_F_EMPTY_PATH` 216 const MOVE_MOUNT_F_EMPTY_PATH = 0x0000_0004; 217 218 /// `MOVE_MOUNT_T_SYMLINKS` 219 const MOVE_MOUNT_T_SYMLINKS = 0x0000_0010; 220 221 /// `MOVE_MOUNT_T_AUTOMOUNTS` 222 const MOVE_MOUNT_T_AUTOMOUNTS = 0x0000_0020; 223 224 /// `MOVE_MOUNT_T_EMPTY_PATH` 225 const MOVE_MOUNT_T_EMPTY_PATH = 0x0000_0040; 226 227 /// `MOVE_MOUNT__MASK` 228 const MOVE_MOUNT_SET_GROUP = 0x0000_0100; 229 230 // TODO: add when Linux 6.5 is released 231 // /// `MOVE_MOUNT_BENEATH` 232 // const MOVE_MOUNT_BENEATH = 0x0000_0200; 233 234 /// `MOVE_MOUNT__MASK` 235 const MOVE_MOUNT__MASK = 0x0000_0377; 236 237 /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags> 238 const _ = !0; 239 } 240 } 241 242 #[cfg(feature = "mount")] 243 #[cfg(linux_kernel)] 244 bitflags! { 245 /// `OPENTREE_*` constants for use with [`open_tree`]. 246 /// 247 /// [`open_tree`]: crate::mount::open_tree 248 #[repr(transparent)] 249 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] 250 pub struct OpenTreeFlags: c::c_uint { 251 /// `OPENTREE_CLONE` 252 const OPEN_TREE_CLONE = 1; 253 254 /// `OPENTREE_CLOEXEC` 255 const OPEN_TREE_CLOEXEC = c::O_CLOEXEC as c::c_uint; 256 257 /// `AT_EMPTY_PATH` 258 const AT_EMPTY_PATH = c::AT_EMPTY_PATH as c::c_uint; 259 260 /// `AT_NO_AUTOMOUNT` 261 const AT_NO_AUTOMOUNT = c::AT_NO_AUTOMOUNT as c::c_uint; 262 263 /// `AT_RECURSIVE` 264 const AT_RECURSIVE = c::AT_RECURSIVE as c::c_uint; 265 266 /// `AT_SYMLINK_NOFOLLOW` 267 const AT_SYMLINK_NOFOLLOW = c::AT_SYMLINK_NOFOLLOW as c::c_uint; 268 269 /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags> 270 const _ = !0; 271 } 272 } 273 274 #[cfg(feature = "mount")] 275 #[cfg(linux_kernel)] 276 bitflags! { 277 /// `FSPICK_*` constants for use with [`fspick`]. 278 /// 279 /// [`fspick`]: crate::mount::fspick 280 #[repr(transparent)] 281 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] 282 pub struct FsPickFlags: c::c_uint { 283 /// `FSPICK_CLOEXEC` 284 const FSPICK_CLOEXEC = 0x0000_0001; 285 286 /// `FSPICK_SYMLINK_NOFOLLOW` 287 const FSPICK_SYMLINK_NOFOLLOW = 0x0000_0002; 288 289 /// `FSPICK_NO_AUTOMOUNT` 290 const FSPICK_NO_AUTOMOUNT = 0x0000_0004; 291 292 /// `FSPICK_EMPTY_PATH` 293 const FSPICK_EMPTY_PATH = 0x0000_0008; 294 295 /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags> 296 const _ = !0; 297 } 298 } 299 300 #[cfg(linux_kernel)] 301 bitflags! { 302 /// `MS_*` constants for use with [`mount_change`]. 303 /// 304 /// [`mount_change`]: crate::mount::mount_change 305 #[repr(transparent)] 306 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] 307 pub struct MountPropagationFlags: c::c_ulong { 308 /// `MS_SILENT` 309 const SILENT = c::MS_SILENT; 310 /// `MS_SHARED` 311 const SHARED = c::MS_SHARED; 312 /// `MS_PRIVATE` 313 const PRIVATE = c::MS_PRIVATE; 314 /// `MS_SLAVE` 315 const SLAVE = c::MS_SLAVE; 316 /// `MS_UNBINDABLE` 317 const UNBINDABLE = c::MS_UNBINDABLE; 318 /// `MS_REC` 319 const REC = c::MS_REC; 320 321 /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags> 322 const _ = !0; 323 } 324 } 325 326 #[cfg(linux_kernel)] 327 bitflags! { 328 #[repr(transparent)] 329 #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] 330 pub(crate) struct InternalMountFlags: c::c_ulong { 331 const REMOUNT = c::MS_REMOUNT; 332 const MOVE = c::MS_MOVE; 333 334 /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags> 335 const _ = !0; 336 } 337 } 338 339 #[cfg(linux_kernel)] 340 pub(crate) struct MountFlagsArg(pub(crate) c::c_ulong); 341