use super::super::c;
use bitflags::bitflags;
bitflags! {
pub struct Access: c::c_uint {
const READ_OK = linux_raw_sys::general::R_OK;
const WRITE_OK = linux_raw_sys::general::W_OK;
const EXEC_OK = linux_raw_sys::general::X_OK;
const EXISTS = linux_raw_sys::general::F_OK;
}
}
bitflags! {
pub struct AtFlags: c::c_uint {
const REMOVEDIR = linux_raw_sys::general::AT_REMOVEDIR;
const SYMLINK_FOLLOW = linux_raw_sys::general::AT_SYMLINK_FOLLOW;
const SYMLINK_NOFOLLOW = linux_raw_sys::general::AT_SYMLINK_NOFOLLOW;
const EMPTY_PATH = linux_raw_sys::general::AT_EMPTY_PATH;
const EACCESS = linux_raw_sys::general::AT_EACCESS;
const STATX_SYNC_AS_STAT = linux_raw_sys::general::AT_STATX_SYNC_AS_STAT;
const STATX_FORCE_SYNC = linux_raw_sys::general::AT_STATX_FORCE_SYNC;
const STATX_DONT_SYNC = linux_raw_sys::general::AT_STATX_DONT_SYNC;
}
}
bitflags! {
pub struct Mode: RawMode {
const RWXU = linux_raw_sys::general::S_IRWXU;
const RUSR = linux_raw_sys::general::S_IRUSR;
const WUSR = linux_raw_sys::general::S_IWUSR;
const XUSR = linux_raw_sys::general::S_IXUSR;
const RWXG = linux_raw_sys::general::S_IRWXG;
const RGRP = linux_raw_sys::general::S_IRGRP;
const WGRP = linux_raw_sys::general::S_IWGRP;
const XGRP = linux_raw_sys::general::S_IXGRP;
const RWXO = linux_raw_sys::general::S_IRWXO;
const ROTH = linux_raw_sys::general::S_IROTH;
const WOTH = linux_raw_sys::general::S_IWOTH;
const XOTH = linux_raw_sys::general::S_IXOTH;
const SUID = linux_raw_sys::general::S_ISUID;
const SGID = linux_raw_sys::general::S_ISGID;
const SVTX = linux_raw_sys::general::S_ISVTX;
}
}
impl Mode {
#[inline]
pub const fn from_raw_mode(st_mode: RawMode) -> Self {
Self::from_bits_truncate(st_mode)
}
#[inline]
pub const fn as_raw_mode(self) -> RawMode {
self.bits()
}
}
bitflags! {
pub struct OFlags: c::c_uint {
const ACCMODE = linux_raw_sys::general::O_ACCMODE;
const RWMODE = linux_raw_sys::general::O_RDONLY |
linux_raw_sys::general::O_WRONLY |
linux_raw_sys::general::O_RDWR;
const APPEND = linux_raw_sys::general::O_APPEND;
#[doc(alias = "CREAT")]
const CREATE = linux_raw_sys::general::O_CREAT;
const DIRECTORY = linux_raw_sys::general::O_DIRECTORY;
const DSYNC = linux_raw_sys::general::O_SYNC;
const EXCL = linux_raw_sys::general::O_EXCL;
const FSYNC = linux_raw_sys::general::O_SYNC;
const NOFOLLOW = linux_raw_sys::general::O_NOFOLLOW;
const NONBLOCK = linux_raw_sys::general::O_NONBLOCK;
const RDONLY = linux_raw_sys::general::O_RDONLY;
const WRONLY = linux_raw_sys::general::O_WRONLY;
const RDWR = linux_raw_sys::general::O_RDWR;
const NOCTTY = linux_raw_sys::general::O_NOCTTY;
const RSYNC = linux_raw_sys::general::O_SYNC;
const SYNC = linux_raw_sys::general::O_SYNC;
const TRUNC = linux_raw_sys::general::O_TRUNC;
const PATH = linux_raw_sys::general::O_PATH;
const CLOEXEC = linux_raw_sys::general::O_CLOEXEC;
const TMPFILE = linux_raw_sys::general::O_TMPFILE;
const NOATIME = linux_raw_sys::general::O_NOATIME;
}
}
bitflags! {
#[derive(Default)]
pub struct ResolveFlags: u64 {
const NO_XDEV = linux_raw_sys::general::RESOLVE_NO_XDEV as u64;
const NO_MAGICLINKS = linux_raw_sys::general::RESOLVE_NO_MAGICLINKS as u64;
const NO_SYMLINKS = linux_raw_sys::general::RESOLVE_NO_SYMLINKS as u64;
const BENEATH = linux_raw_sys::general::RESOLVE_BENEATH as u64;
const IN_ROOT = linux_raw_sys::general::RESOLVE_IN_ROOT as u64;
const CACHED = linux_raw_sys::general::RESOLVE_CACHED as u64;
}
}
bitflags! {
pub struct RenameFlags: c::c_uint {
const EXCHANGE = linux_raw_sys::general::RENAME_EXCHANGE;
const NOREPLACE = linux_raw_sys::general::RENAME_NOREPLACE;
const WHITEOUT = linux_raw_sys::general::RENAME_WHITEOUT;
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum FileType {
RegularFile = linux_raw_sys::general::S_IFREG as isize,
Directory = linux_raw_sys::general::S_IFDIR as isize,
Symlink = linux_raw_sys::general::S_IFLNK as isize,
Fifo = linux_raw_sys::general::S_IFIFO as isize,
Socket = linux_raw_sys::general::S_IFSOCK as isize,
CharacterDevice = linux_raw_sys::general::S_IFCHR as isize,
BlockDevice = linux_raw_sys::general::S_IFBLK as isize,
Unknown,
}
impl FileType {
#[inline]
pub const fn from_raw_mode(st_mode: RawMode) -> Self {
match st_mode & linux_raw_sys::general::S_IFMT {
linux_raw_sys::general::S_IFREG => Self::RegularFile,
linux_raw_sys::general::S_IFDIR => Self::Directory,
linux_raw_sys::general::S_IFLNK => Self::Symlink,
linux_raw_sys::general::S_IFIFO => Self::Fifo,
linux_raw_sys::general::S_IFSOCK => Self::Socket,
linux_raw_sys::general::S_IFCHR => Self::CharacterDevice,
linux_raw_sys::general::S_IFBLK => Self::BlockDevice,
_ => Self::Unknown,
}
}
#[inline]
pub const fn as_raw_mode(self) -> RawMode {
match self {
Self::RegularFile => linux_raw_sys::general::S_IFREG,
Self::Directory => linux_raw_sys::general::S_IFDIR,
Self::Symlink => linux_raw_sys::general::S_IFLNK,
Self::Fifo => linux_raw_sys::general::S_IFIFO,
Self::Socket => linux_raw_sys::general::S_IFSOCK,
Self::CharacterDevice => linux_raw_sys::general::S_IFCHR,
Self::BlockDevice => linux_raw_sys::general::S_IFBLK,
Self::Unknown => linux_raw_sys::general::S_IFMT,
}
}
#[inline]
pub(crate) const fn from_dirent_d_type(d_type: u8) -> Self {
match d_type as u32 {
linux_raw_sys::general::DT_REG => Self::RegularFile,
linux_raw_sys::general::DT_DIR => Self::Directory,
linux_raw_sys::general::DT_LNK => Self::Symlink,
linux_raw_sys::general::DT_SOCK => Self::Socket,
linux_raw_sys::general::DT_FIFO => Self::Fifo,
linux_raw_sys::general::DT_CHR => Self::CharacterDevice,
linux_raw_sys::general::DT_BLK => Self::BlockDevice,
_ => Self::Unknown,
}
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
#[repr(u32)]
pub enum Advice {
Normal = linux_raw_sys::general::POSIX_FADV_NORMAL,
Sequential = linux_raw_sys::general::POSIX_FADV_SEQUENTIAL,
Random = linux_raw_sys::general::POSIX_FADV_RANDOM,
NoReuse = linux_raw_sys::general::POSIX_FADV_NOREUSE,
WillNeed = linux_raw_sys::general::POSIX_FADV_WILLNEED,
DontNeed = linux_raw_sys::general::POSIX_FADV_DONTNEED,
}
bitflags! {
pub struct MemfdFlags: c::c_uint {
const CLOEXEC = linux_raw_sys::general::MFD_CLOEXEC;
const ALLOW_SEALING = linux_raw_sys::general::MFD_ALLOW_SEALING;
const HUGETLB = linux_raw_sys::general::MFD_HUGETLB;
const HUGE_64KB = linux_raw_sys::general::MFD_HUGE_64KB;
const HUGE_512KB = linux_raw_sys::general::MFD_HUGE_512KB;
const HUGE_1MB = linux_raw_sys::general::MFD_HUGE_1MB;
const HUGE_2MB = linux_raw_sys::general::MFD_HUGE_2MB;
const HUGE_8MB = linux_raw_sys::general::MFD_HUGE_8MB;
const HUGE_16MB = linux_raw_sys::general::MFD_HUGE_16MB;
const HUGE_32MB = linux_raw_sys::general::MFD_HUGE_32MB;
const HUGE_256MB = linux_raw_sys::general::MFD_HUGE_256MB;
const HUGE_512MB = linux_raw_sys::general::MFD_HUGE_512MB;
const HUGE_1GB = linux_raw_sys::general::MFD_HUGE_1GB;
const HUGE_2GB = linux_raw_sys::general::MFD_HUGE_2GB;
const HUGE_16GB = linux_raw_sys::general::MFD_HUGE_16GB;
}
}
bitflags! {
pub struct SealFlags: u32 {
const SEAL = linux_raw_sys::general::F_SEAL_SEAL;
const SHRINK = linux_raw_sys::general::F_SEAL_SHRINK;
const GROW = linux_raw_sys::general::F_SEAL_GROW;
const WRITE = linux_raw_sys::general::F_SEAL_WRITE;
const FUTURE_WRITE = linux_raw_sys::general::F_SEAL_FUTURE_WRITE;
}
}
bitflags! {
pub struct StatxFlags: u32 {
const TYPE = linux_raw_sys::general::STATX_TYPE;
const MODE = linux_raw_sys::general::STATX_MODE;
const NLINK = linux_raw_sys::general::STATX_NLINK;
const UID = linux_raw_sys::general::STATX_UID;
const GID = linux_raw_sys::general::STATX_GID;
const ATIME = linux_raw_sys::general::STATX_ATIME;
const MTIME = linux_raw_sys::general::STATX_MTIME;
const CTIME = linux_raw_sys::general::STATX_CTIME;
const INO = linux_raw_sys::general::STATX_INO;
const SIZE = linux_raw_sys::general::STATX_SIZE;
const BLOCKS = linux_raw_sys::general::STATX_BLOCKS;
const BASIC_STATS = linux_raw_sys::general::STATX_BASIC_STATS;
const BTIME = linux_raw_sys::general::STATX_BTIME;
const MNT_ID = linux_raw_sys::general::STATX_MNT_ID;
const ALL = linux_raw_sys::general::STATX_ALL;
}
}
bitflags! {
pub struct FallocateFlags: u32 {
const KEEP_SIZE = linux_raw_sys::general::FALLOC_FL_KEEP_SIZE;
const PUNCH_HOLE = linux_raw_sys::general::FALLOC_FL_PUNCH_HOLE;
const NO_HIDE_STALE = linux_raw_sys::general::FALLOC_FL_NO_HIDE_STALE;
const COLLAPSE_RANGE = linux_raw_sys::general::FALLOC_FL_COLLAPSE_RANGE;
const ZERO_RANGE = linux_raw_sys::general::FALLOC_FL_ZERO_RANGE;
const INSERT_RANGE = linux_raw_sys::general::FALLOC_FL_INSERT_RANGE;
const UNSHARE_RANGE = linux_raw_sys::general::FALLOC_FL_UNSHARE_RANGE;
}
}
bitflags! {
pub struct StatVfsMountFlags: u64 {
const MANDLOCK = linux_raw_sys::general::MS_MANDLOCK as u64;
const NOATIME = linux_raw_sys::general::MS_NOATIME as u64;
const NODEV = linux_raw_sys::general::MS_NODEV as u64;
const NODIRATIME = linux_raw_sys::general::MS_NODIRATIME as u64;
const NOEXEC = linux_raw_sys::general::MS_NOEXEC as u64;
const NOSUID = linux_raw_sys::general::MS_NOSUID as u64;
const RDONLY = linux_raw_sys::general::MS_RDONLY as u64;
const RELATIME = linux_raw_sys::general::MS_RELATIME as u64;
const SYNCHRONOUS = linux_raw_sys::general::MS_SYNCHRONOUS as u64;
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u32)]
pub enum FlockOperation {
LockShared = linux_raw_sys::general::LOCK_SH,
LockExclusive = linux_raw_sys::general::LOCK_EX,
Unlock = linux_raw_sys::general::LOCK_UN,
NonBlockingLockShared = linux_raw_sys::general::LOCK_SH | linux_raw_sys::general::LOCK_NB,
NonBlockingLockExclusive = linux_raw_sys::general::LOCK_EX | linux_raw_sys::general::LOCK_NB,
NonBlockingUnlock = linux_raw_sys::general::LOCK_UN | linux_raw_sys::general::LOCK_NB,
}
#[cfg(any(target_pointer_width = "32", target_arch = "mips64"))]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
#[allow(missing_docs)]
pub struct Stat {
pub st_dev: u64,
pub st_mode: u32,
pub st_nlink: u32,
pub st_uid: u32,
pub st_gid: u32,
pub st_rdev: u64,
pub st_size: i64,
pub st_blksize: u32,
pub st_blocks: u64,
pub st_atime: u64,
pub st_atime_nsec: u32,
pub st_mtime: u64,
pub st_mtime_nsec: u32,
pub st_ctime: u64,
pub st_ctime_nsec: u32,
pub st_ino: u64,
}
#[cfg(all(target_pointer_width = "64", not(target_arch = "mips64")))]
pub type Stat = linux_raw_sys::general::stat;
#[allow(clippy::module_name_repetitions)]
pub type StatFs = linux_raw_sys::general::statfs64;
#[allow(missing_docs)]
pub struct StatVfs {
pub f_bsize: u64,
pub f_frsize: u64,
pub f_blocks: u64,
pub f_bfree: u64,
pub f_bavail: u64,
pub f_files: u64,
pub f_ffree: u64,
pub f_favail: u64,
pub f_fsid: u64,
pub f_flag: StatVfsMountFlags,
pub f_namemax: u64,
}
pub type Statx = linux_raw_sys::general::statx;
pub type StatxTimestamp = linux_raw_sys::general::statx_timestamp;
#[cfg(not(any(
target_arch = "x86",
target_arch = "sparc",
target_arch = "avr",
target_arch = "arm",
)))]
pub type RawMode = linux_raw_sys::general::__kernel_mode_t;
#[cfg(any(
target_arch = "x86",
target_arch = "sparc",
target_arch = "avr",
target_arch = "arm",
))]
pub type RawMode = c::c_uint;
pub type Dev = u64;
#[cfg(not(target_arch = "mips64"))]
pub type FsWord = linux_raw_sys::general::__fsword_t;
#[cfg(target_arch = "mips64")]
pub type FsWord = i64;
pub use linux_raw_sys::general::{UTIME_NOW, UTIME_OMIT};
pub const PROC_SUPER_MAGIC: FsWord = linux_raw_sys::general::PROC_SUPER_MAGIC as FsWord;
pub const NFS_SUPER_MAGIC: FsWord = linux_raw_sys::general::NFS_SUPER_MAGIC as FsWord;
#[cfg(any(target_os = "android", target_os = "linux"))]
bitflags! {
pub struct MountFlags: c::c_uint {
const BIND = linux_raw_sys::general::MS_BIND;
const DIRSYNC = linux_raw_sys::general::MS_DIRSYNC;
const LAZYTIME = linux_raw_sys::general::MS_LAZYTIME;
#[doc(alias = "MANDLOCK")]
const PERMIT_MANDATORY_FILE_LOCKING = linux_raw_sys::general::MS_MANDLOCK;
const NOATIME = linux_raw_sys::general::MS_NOATIME;
const NODEV = linux_raw_sys::general::MS_NODEV;
const NODIRATIME = linux_raw_sys::general::MS_NODIRATIME;
const NOEXEC = linux_raw_sys::general::MS_NOEXEC;
const NOSUID = linux_raw_sys::general::MS_NOSUID;
const RDONLY = linux_raw_sys::general::MS_RDONLY;
const REC = linux_raw_sys::general::MS_REC;
const RELATIME = linux_raw_sys::general::MS_RELATIME;
const SILENT = linux_raw_sys::general::MS_SILENT;
const STRICTATIME = linux_raw_sys::general::MS_STRICTATIME;
const SYNCHRONOUS = linux_raw_sys::general::MS_SYNCHRONOUS;
const NOSYMFOLLOW = linux_raw_sys::general::MS_NOSYMFOLLOW;
}
}
#[cfg(any(target_os = "android", target_os = "linux"))]
bitflags! {
pub struct MountPropagationFlags: c::c_uint {
const SHARED = linux_raw_sys::general::MS_SHARED;
const PRIVATE = linux_raw_sys::general::MS_PRIVATE;
const SLAVE = linux_raw_sys::general::MS_SLAVE;
const UNBINDABLE = linux_raw_sys::general::MS_UNBINDABLE;
const REC = linux_raw_sys::general::MS_REC;
}
}
#[cfg(any(target_os = "android", target_os = "linux"))]
bitflags! {
pub(crate) struct InternalMountFlags: c::c_uint {
const REMOUNT = linux_raw_sys::general::MS_REMOUNT;
const MOVE = linux_raw_sys::general::MS_MOVE;
}
}
#[cfg(any(target_os = "android", target_os = "linux"))]
pub(crate) struct MountFlagsArg(pub(crate) c::c_uint);