diff options
Diffstat (limited to 'vendor/rustix/src/backend/libc/fs/types.rs')
-rw-r--r-- | vendor/rustix/src/backend/libc/fs/types.rs | 256 |
1 files changed, 143 insertions, 113 deletions
diff --git a/vendor/rustix/src/backend/libc/fs/types.rs b/vendor/rustix/src/backend/libc/fs/types.rs index 0cf7fe8ff..b52f0e210 100644 --- a/vendor/rustix/src/backend/libc/fs/types.rs +++ b/vendor/rustix/src/backend/libc/fs/types.rs @@ -1,10 +1,12 @@ -use super::super::c; +use crate::backend::c; use bitflags::bitflags; bitflags! { /// `*_OK` constants for use with [`accessat`]. /// /// [`accessat`]: fn.accessat.html + #[repr(transparent)] + #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub struct Access: c::c_int { /// `R_OK` const READ_OK = c::R_OK; @@ -27,44 +29,49 @@ bitflags! { /// /// [`openat`]: crate::fs::openat /// [`statat`]: crate::fs::statat - pub struct AtFlags: c::c_int { + #[repr(transparent)] + #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] + pub struct AtFlags: u32 { + /// `AT_SYMLINK_NOFOLLOW` + const SYMLINK_NOFOLLOW = bitcast!(c::AT_SYMLINK_NOFOLLOW); + + /// `AT_EACCESS` + #[cfg(not(any(target_os = "emscripten", target_os = "android")))] + const EACCESS = bitcast!(c::AT_EACCESS); + /// `AT_REMOVEDIR` - const REMOVEDIR = c::AT_REMOVEDIR; + const REMOVEDIR = bitcast!(c::AT_REMOVEDIR); /// `AT_SYMLINK_FOLLOW` - const SYMLINK_FOLLOW = c::AT_SYMLINK_FOLLOW; + const SYMLINK_FOLLOW = bitcast!(c::AT_SYMLINK_FOLLOW); - /// `AT_SYMLINK_NOFOLLOW` - const SYMLINK_NOFOLLOW = c::AT_SYMLINK_NOFOLLOW; + /// `AT_NO_AUTOMOUNT` + #[cfg(any(linux_like, target_os = "fuchsia"))] + const NO_AUTOMOUNT = bitcast!(c::AT_NO_AUTOMOUNT); /// `AT_EMPTY_PATH` #[cfg(any( - target_os = "android", + linux_kernel, target_os = "freebsd", target_os = "fuchsia", - target_os = "linux", ))] - const EMPTY_PATH = c::AT_EMPTY_PATH; + const EMPTY_PATH = bitcast!(c::AT_EMPTY_PATH); /// `AT_RESOLVE_BENEATH` #[cfg(target_os = "freebsd")] - const RESOLVE_BENEATH = c::AT_RESOLVE_BENEATH; - - /// `AT_EACCESS` - #[cfg(not(any(target_os = "emscripten", target_os = "android")))] - const EACCESS = c::AT_EACCESS; + const RESOLVE_BENEATH = bitcast!(c::AT_RESOLVE_BENEATH); /// `AT_STATX_SYNC_AS_STAT` #[cfg(all(target_os = "linux", target_env = "gnu"))] - const STATX_SYNC_AS_STAT = c::AT_STATX_SYNC_AS_STAT; + const STATX_SYNC_AS_STAT = bitcast!(c::AT_STATX_SYNC_AS_STAT); /// `AT_STATX_FORCE_SYNC` #[cfg(all(target_os = "linux", target_env = "gnu"))] - const STATX_FORCE_SYNC = c::AT_STATX_FORCE_SYNC; + const STATX_FORCE_SYNC = bitcast!(c::AT_STATX_FORCE_SYNC); /// `AT_STATX_DONT_SYNC` #[cfg(all(target_os = "linux", target_env = "gnu"))] - const STATX_DONT_SYNC = c::AT_STATX_DONT_SYNC; + const STATX_DONT_SYNC = bitcast!(c::AT_STATX_DONT_SYNC); } } @@ -74,6 +81,8 @@ bitflags! { /// [`openat`]: crate::fs::openat /// [`chmodat`]: crate::fs::chmodat /// [`fchmod`]: crate::fs::fchmod + #[repr(transparent)] + #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub struct Mode: RawMode { /// `S_IRWXU` #[cfg(not(target_os = "wasi"))] // WASI doesn't have Unix-style mode flags. @@ -166,7 +175,7 @@ impl From<RawMode> for Mode { } impl From<Mode> for RawMode { - /// Support conversions from `Mode to raw mode values. + /// Support conversions from `Mode` to raw mode values. /// /// ``` /// use rustix::fs::{Mode, RawMode}; @@ -182,9 +191,11 @@ bitflags! { /// `O_*` constants for use with [`openat`]. /// /// [`openat`]: crate::fs::openat - pub struct OFlags: c::c_int { + #[repr(transparent)] + #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] + pub struct OFlags: u32 { /// `O_ACCMODE` - const ACCMODE = c::O_ACCMODE; + const ACCMODE = bitcast!(c::O_ACCMODE); /// Similar to `ACCMODE`, but just includes the read/write flags, and /// no other flags. @@ -193,117 +204,112 @@ bitflags! { /// sometimes we really just want the read/write bits. Caution is /// indicated, as the presence of `O_PATH` may mean that the read/write /// bits don't have their usual meaning. - const RWMODE = c::O_RDONLY | c::O_WRONLY | c::O_RDWR; + const RWMODE = bitcast!(c::O_RDONLY | c::O_WRONLY | c::O_RDWR); /// `O_APPEND` - const APPEND = c::O_APPEND; + const APPEND = bitcast!(c::O_APPEND); /// `O_CREAT` #[doc(alias = "CREAT")] - const CREATE = c::O_CREAT; + const CREATE = bitcast!(c::O_CREAT); /// `O_DIRECTORY` - const DIRECTORY = c::O_DIRECTORY; + const DIRECTORY = bitcast!(c::O_DIRECTORY); /// `O_DSYNC` #[cfg(not(any(target_os = "dragonfly", target_os = "redox")))] - const DSYNC = c::O_DSYNC; + const DSYNC = bitcast!(c::O_DSYNC); /// `O_EXCL` - const EXCL = c::O_EXCL; + const EXCL = bitcast!(c::O_EXCL); /// `O_FSYNC` #[cfg(any( bsd, all(target_os = "linux", not(target_env = "musl")), ))] - const FSYNC = c::O_FSYNC; + const FSYNC = bitcast!(c::O_FSYNC); /// `O_NOFOLLOW` - const NOFOLLOW = c::O_NOFOLLOW; + const NOFOLLOW = bitcast!(c::O_NOFOLLOW); /// `O_NONBLOCK` - const NONBLOCK = c::O_NONBLOCK; + const NONBLOCK = bitcast!(c::O_NONBLOCK); /// `O_RDONLY` - const RDONLY = c::O_RDONLY; + const RDONLY = bitcast!(c::O_RDONLY); /// `O_WRONLY` - const WRONLY = c::O_WRONLY; + const WRONLY = bitcast!(c::O_WRONLY); /// `O_RDWR` - const RDWR = c::O_RDWR; + const RDWR = bitcast!(c::O_RDWR); /// `O_NOCTTY` #[cfg(not(target_os = "redox"))] - const NOCTTY = c::O_NOCTTY; + const NOCTTY = bitcast!(c::O_NOCTTY); /// `O_RSYNC` #[cfg(any( + linux_kernel, netbsdlike, - target_os = "android", target_os = "emscripten", - target_os = "linux", target_os = "wasi", ))] - const RSYNC = c::O_RSYNC; + const RSYNC = bitcast!(c::O_RSYNC); /// `O_SYNC` #[cfg(not(target_os = "redox"))] - const SYNC = c::O_SYNC; + const SYNC = bitcast!(c::O_SYNC); /// `O_TRUNC` - const TRUNC = c::O_TRUNC; + const TRUNC = bitcast!(c::O_TRUNC); /// `O_PATH` #[cfg(any( - target_os = "android", + linux_kernel, target_os = "emscripten", target_os = "freebsd", target_os = "fuchsia", - target_os = "linux", target_os = "redox", ))] - const PATH = c::O_PATH; + const PATH = bitcast!(c::O_PATH); /// `O_CLOEXEC` - const CLOEXEC = c::O_CLOEXEC; + const CLOEXEC = bitcast!(c::O_CLOEXEC); /// `O_TMPFILE` #[cfg(any( - target_os = "android", + linux_kernel, target_os = "emscripten", target_os = "fuchsia", - target_os = "linux", ))] - const TMPFILE = c::O_TMPFILE; + const TMPFILE = bitcast!(c::O_TMPFILE); /// `O_NOATIME` #[cfg(any( - target_os = "android", + linux_kernel, target_os = "fuchsia", - target_os = "linux", ))] - const NOATIME = c::O_NOATIME; + const NOATIME = bitcast!(c::O_NOATIME); /// `O_DIRECT` #[cfg(any( - target_os = "android", + linux_kernel, target_os = "emscripten", target_os = "freebsd", target_os = "fuchsia", - target_os = "linux", target_os = "netbsd", ))] - const DIRECT = c::O_DIRECT; + const DIRECT = bitcast!(c::O_DIRECT); /// `O_RESOLVE_BENEATH` #[cfg(target_os = "freebsd")] - const RESOLVE_BENEATH = c::O_RESOLVE_BENEATH; + const RESOLVE_BENEATH = bitcast!(c::O_RESOLVE_BENEATH); /// `O_EMPTY_PATH` #[cfg(target_os = "freebsd")] - const EMPTY_PATH = c::O_EMPTY_PATH; + const EMPTY_PATH = bitcast!(c::O_EMPTY_PATH); } } @@ -312,7 +318,9 @@ bitflags! { /// `CLONE_*` constants for use with [`fclonefileat`]. /// /// [`fclonefileat`]: crate::fs::fclonefileat - pub struct CloneFlags: c::c_int { + #[repr(transparent)] + #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] + pub struct CloneFlags: u32 { /// `CLONE_NOFOLLOW` const NOFOLLOW = 1; @@ -337,6 +345,8 @@ bitflags! { /// `COPYFILE_*` constants for use with [`fcopyfile`]. /// /// [`fcopyfile`]: crate::fs::fcopyfile + #[repr(transparent)] + #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub struct CopyfileFlags: c::c_uint { /// `COPYFILE_ACL` const ACL = copyfile::ACL; @@ -361,12 +371,13 @@ bitflags! { } } -#[cfg(any(target_os = "android", target_os = "linux"))] +#[cfg(linux_kernel)] bitflags! { /// `RESOLVE_*` constants for use with [`openat2`]. /// /// [`openat2`]: crate::fs::openat2 - #[derive(Default)] + #[repr(transparent)] + #[derive(Default, Copy, Clone, Eq, PartialEq, Hash, Debug)] pub struct ResolveFlags: u64 { /// `RESOLVE_NO_XDEV` const NO_XDEV = 0x01; @@ -388,20 +399,22 @@ bitflags! { } } -#[cfg(any(target_os = "android", target_os = "linux"))] +#[cfg(linux_kernel)] bitflags! { /// `RENAME_*` constants for use with [`renameat_with`]. /// /// [`renameat_with`]: crate::fs::renameat_with + #[repr(transparent)] + #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub struct RenameFlags: c::c_uint { /// `RENAME_EXCHANGE` - const EXCHANGE = c::RENAME_EXCHANGE as _; + const EXCHANGE = bitcast!(c::RENAME_EXCHANGE); /// `RENAME_NOREPLACE` - const NOREPLACE = c::RENAME_NOREPLACE as _; + const NOREPLACE = bitcast!(c::RENAME_NOREPLACE); /// `RENAME_WHITEOUT` - const WHITEOUT = c::RENAME_WHITEOUT as _; + const WHITEOUT = bitcast!(c::RENAME_WHITEOUT); } } @@ -528,11 +541,13 @@ pub enum Advice { DontNeed = c::POSIX_FADV_DONTNEED as c::c_uint, } -#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))] +#[cfg(any(linux_kernel, target_os = "freebsd"))] bitflags! { /// `MFD_*` constants for use with [`memfd_create`]. /// /// [`memfd_create`]: crate::fs::memfd_create + #[repr(transparent)] + #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub struct MemfdFlags: c::c_uint { /// `MFD_CLOEXEC` const CLOEXEC = c::MFD_CLOEXEC; @@ -570,30 +585,27 @@ bitflags! { } } -#[cfg(any( - target_os = "android", - target_os = "freebsd", - target_os = "fuchsia", - target_os = "linux", -))] +#[cfg(any(linux_kernel, target_os = "freebsd", target_os = "fuchsia"))] bitflags! { /// `F_SEAL_*` constants for use with [`fcntl_add_seals`] and /// [`fcntl_get_seals`]. /// /// [`fcntl_add_seals`]: crate::fs::fcntl_add_seals /// [`fcntl_get_seals`]: crate::fs::fcntl_get_seals - pub struct SealFlags: i32 { + #[repr(transparent)] + #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] + pub struct SealFlags: u32 { /// `F_SEAL_SEAL`. - const SEAL = c::F_SEAL_SEAL; + const SEAL = bitcast!(c::F_SEAL_SEAL); /// `F_SEAL_SHRINK`. - const SHRINK = c::F_SEAL_SHRINK; + const SHRINK = bitcast!(c::F_SEAL_SHRINK); /// `F_SEAL_GROW`. - const GROW = c::F_SEAL_GROW; + const GROW = bitcast!(c::F_SEAL_GROW); /// `F_SEAL_WRITE`. - const WRITE = c::F_SEAL_WRITE; + const WRITE = bitcast!(c::F_SEAL_WRITE); /// `F_SEAL_FUTURE_WRITE` (since Linux 5.1) - #[cfg(any(target_os = "android", target_os = "linux"))] - const FUTURE_WRITE = c::F_SEAL_FUTURE_WRITE; + #[cfg(linux_kernel)] + const FUTURE_WRITE = bitcast!(c::F_SEAL_FUTURE_WRITE); } } @@ -602,6 +614,8 @@ bitflags! { /// `STATX_*` constants for use with [`statx`]. /// /// [`statx`]: crate::fs::statx + #[repr(transparent)] + #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub struct StatxFlags: u32 { /// `STATX_TYPE` const TYPE = c::STATX_TYPE; @@ -645,6 +659,9 @@ bitflags! { /// `STATX_MNT_ID` (since Linux 5.8) const MNT_ID = c::STATX_MNT_ID; + /// `STATX_DIOALIGN` (since Linux 6.1) + const DIOALIGN = c::STATX_DIOALIGN; + /// `STATX_ALL` const ALL = c::STATX_ALL; } @@ -658,6 +675,8 @@ bitflags! { /// `STATX_*` constants for use with [`statx`]. /// /// [`statx`]: crate::fs::statx + #[repr(transparent)] + #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub struct StatxFlags: u32 { /// `STATX_TYPE` const TYPE = 0x0001; @@ -711,7 +730,9 @@ bitflags! { /// `FALLOC_FL_*` constants for use with [`fallocate`]. /// /// [`fallocate`]: crate::fs::fallocate - pub struct FallocateFlags: i32 { + #[repr(transparent)] + #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] + pub struct FallocateFlags: u32 { /// `FALLOC_FL_KEEP_SIZE` #[cfg(not(any( bsd, @@ -719,7 +740,7 @@ bitflags! { target_os = "haiku", target_os = "wasi", )))] - const KEEP_SIZE = c::FALLOC_FL_KEEP_SIZE; + const KEEP_SIZE = bitcast!(c::FALLOC_FL_KEEP_SIZE); /// `FALLOC_FL_PUNCH_HOLE` #[cfg(not(any( bsd, @@ -727,7 +748,7 @@ bitflags! { target_os = "haiku", target_os = "wasi", )))] - const PUNCH_HOLE = c::FALLOC_FL_PUNCH_HOLE; + const PUNCH_HOLE = bitcast!(c::FALLOC_FL_PUNCH_HOLE); /// `FALLOC_FL_NO_HIDE_STALE` #[cfg(not(any( bsd, @@ -738,7 +759,7 @@ bitflags! { target_os = "fuchsia", target_os = "wasi", )))] - const NO_HIDE_STALE = c::FALLOC_FL_NO_HIDE_STALE; + const NO_HIDE_STALE = bitcast!(c::FALLOC_FL_NO_HIDE_STALE); /// `FALLOC_FL_COLLAPSE_RANGE` #[cfg(not(any( bsd, @@ -747,7 +768,7 @@ bitflags! { target_os = "emscripten", target_os = "wasi", )))] - const COLLAPSE_RANGE = c::FALLOC_FL_COLLAPSE_RANGE; + const COLLAPSE_RANGE = bitcast!(c::FALLOC_FL_COLLAPSE_RANGE); /// `FALLOC_FL_ZERO_RANGE` #[cfg(not(any( bsd, @@ -756,7 +777,7 @@ bitflags! { target_os = "emscripten", target_os = "wasi", )))] - const ZERO_RANGE = c::FALLOC_FL_ZERO_RANGE; + const ZERO_RANGE = bitcast!(c::FALLOC_FL_ZERO_RANGE); /// `FALLOC_FL_INSERT_RANGE` #[cfg(not(any( bsd, @@ -765,7 +786,7 @@ bitflags! { target_os = "emscripten", target_os = "wasi", )))] - const INSERT_RANGE = c::FALLOC_FL_INSERT_RANGE; + const INSERT_RANGE = bitcast!(c::FALLOC_FL_INSERT_RANGE); /// `FALLOC_FL_UNSHARE_RANGE` #[cfg(not(any( bsd, @@ -774,32 +795,39 @@ bitflags! { target_os = "emscripten", target_os = "wasi", )))] - const UNSHARE_RANGE = c::FALLOC_FL_UNSHARE_RANGE; + const UNSHARE_RANGE = bitcast!(c::FALLOC_FL_UNSHARE_RANGE); } } #[cfg(not(any(target_os = "haiku", target_os = "redox", target_os = "wasi")))] bitflags! { /// `ST_*` constants for use with [`StatVfs`]. + #[repr(transparent)] + #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub struct StatVfsMountFlags: u64 { /// `ST_MANDLOCK` - #[cfg(any(target_os = "android", target_os = "emscripten", target_os = "fuchsia", target_os = "linux"))] + #[cfg(any(linux_kernel, target_os = "emscripten", target_os = "fuchsia"))] const MANDLOCK = c::ST_MANDLOCK as u64; /// `ST_NOATIME` - #[cfg(any(target_os = "android", target_os = "emscripten", target_os = "fuchsia", target_os = "linux"))] + #[cfg(any(linux_kernel, target_os = "emscripten", target_os = "fuchsia"))] const NOATIME = c::ST_NOATIME as u64; /// `ST_NODEV` - #[cfg(any(target_os = "aix", target_os = "android", target_os = "emscripten", target_os = "fuchsia", target_os = "linux"))] + #[cfg(any( + linux_kernel, + target_os = "aix", + target_os = "emscripten", + target_os = "fuchsia" + ))] const NODEV = c::ST_NODEV as u64; /// `ST_NODIRATIME` - #[cfg(any(target_os = "android", target_os = "emscripten", target_os = "fuchsia", target_os = "linux"))] + #[cfg(any(linux_kernel, target_os = "emscripten", target_os = "fuchsia"))] const NODIRATIME = c::ST_NODIRATIME as u64; /// `ST_NOEXEC` - #[cfg(any(target_os = "android", target_os = "emscripten", target_os = "fuchsia", target_os = "linux"))] + #[cfg(any(linux_kernel, target_os = "emscripten", target_os = "fuchsia"))] const NOEXEC = c::ST_NOEXEC as u64; /// `ST_NOSUID` @@ -813,7 +841,7 @@ bitflags! { const RELATIME = c::ST_RELATIME as u64; /// `ST_SYNCHRONOUS` - #[cfg(any(target_os = "android", target_os = "emscripten", target_os = "fuchsia", target_os = "linux"))] + #[cfg(any(linux_kernel, target_os = "emscripten", target_os = "fuchsia"))] const SYNCHRONOUS = c::ST_SYNCHRONOUS as u64; } } @@ -824,20 +852,20 @@ bitflags! { /// [`fcntl_lock`]: crate::fs::fcntl_lock #[cfg(not(target_os = "wasi"))] #[derive(Clone, Copy, Debug, PartialEq, Eq)] -#[repr(i32)] +#[repr(u32)] pub enum FlockOperation { /// `LOCK_SH` - LockShared = c::LOCK_SH, + LockShared = bitcast!(c::LOCK_SH), /// `LOCK_EX` - LockExclusive = c::LOCK_EX, + LockExclusive = bitcast!(c::LOCK_EX), /// `LOCK_UN` - Unlock = c::LOCK_UN, + Unlock = bitcast!(c::LOCK_UN), /// `LOCK_SH | LOCK_NB` - NonBlockingLockShared = c::LOCK_SH | c::LOCK_NB, + NonBlockingLockShared = bitcast!(c::LOCK_SH | c::LOCK_NB), /// `LOCK_EX | LOCK_NB` - NonBlockingLockExclusive = c::LOCK_EX | c::LOCK_NB, + NonBlockingLockExclusive = bitcast!(c::LOCK_EX | c::LOCK_NB), /// `LOCK_UN | LOCK_NB` - NonBlockingUnlock = c::LOCK_UN | c::LOCK_NB, + NonBlockingUnlock = bitcast!(c::LOCK_UN | c::LOCK_NB), } /// `struct stat` for use with [`statat`] and [`fstat`]. @@ -852,10 +880,7 @@ pub type Stat = c::stat; /// [`statat`]: crate::fs::statat /// [`fstat`]: crate::fs::fstat #[cfg(any( - all( - any(target_os = "android", target_os = "linux"), - target_pointer_width = "64", - ), + all(linux_kernel, target_pointer_width = "64"), target_os = "emscripten", target_os = "l4re", ))] @@ -868,10 +893,7 @@ pub type Stat = c::stat64; // On 32-bit, Linux's `struct stat64` has a 32-bit `st_mtime` and friends, so // we use our own struct, populated from `statx` where possible, to avoid the // y2038 bug. -#[cfg(all( - any(target_os = "android", target_os = "linux"), - target_pointer_width = "32", -))] +#[cfg(all(linux_kernel, target_pointer_width = "32"))] #[repr(C)] #[derive(Debug, Copy, Clone)] #[allow(missing_docs)] @@ -1053,11 +1075,13 @@ pub type FsWord = u32; #[derive(Copy, Clone)] pub struct copyfile_state_t(pub(crate) *mut c::c_void); -#[cfg(any(target_os = "android", target_os = "linux"))] +#[cfg(linux_kernel)] bitflags! { /// `MS_*` constants for use with [`mount`]. /// /// [`mount`]: crate::fs::mount + #[repr(transparent)] + #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub struct MountFlags: c::c_ulong { /// `MS_BIND` const BIND = c::MS_BIND; @@ -1107,11 +1131,13 @@ bitflags! { } } -#[cfg(any(target_os = "android", target_os = "linux"))] +#[cfg(linux_kernel)] bitflags! { /// `MS_*` constants for use with [`change_mount`]. /// /// [`change_mount`]: crate::fs::mount::change_mount + #[repr(transparent)] + #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub struct MountPropagationFlags: c::c_ulong { /// `MS_SHARED` const SHARED = c::MS_SHARED; @@ -1126,30 +1152,34 @@ bitflags! { } } -#[cfg(any(target_os = "android", target_os = "linux"))] +#[cfg(linux_kernel)] bitflags! { + #[repr(transparent)] + #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub(crate) struct InternalMountFlags: c::c_ulong { const REMOUNT = c::MS_REMOUNT; const MOVE = c::MS_MOVE; } } -#[cfg(any(target_os = "android", target_os = "linux"))] +#[cfg(linux_kernel)] pub(crate) struct MountFlagsArg(pub(crate) c::c_ulong); -#[cfg(any(target_os = "android", target_os = "linux"))] +#[cfg(linux_kernel)] bitflags! { /// `MNT_*` constants for use with [`unmount`]. /// /// [`unmount`]: crate::fs::mount::unmount - pub struct UnmountFlags: c::c_int { + #[repr(transparent)] + #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] + pub struct UnmountFlags: u32 { /// `MNT_FORCE` - const FORCE = c::MNT_FORCE; + const FORCE = bitcast!(c::MNT_FORCE); /// `MNT_DETACH` - const DETACH = c::MNT_DETACH; + const DETACH = bitcast!(c::MNT_DETACH); /// `MNT_EXPIRE` - const EXPIRE = c::MNT_EXPIRE; + const EXPIRE = bitcast!(c::MNT_EXPIRE); /// `UMOUNT_NOFOLLOW` - const NOFOLLOW = c::UMOUNT_NOFOLLOW; + const NOFOLLOW = bitcast!(c::UMOUNT_NOFOLLOW); } } |