16d81180bSLoGin const F_LINUX_SPECIFIC_BASE: u32 = 1024; 26d81180bSLoGin 36d81180bSLoGin /// fcntl syscall command 46d81180bSLoGin /// 56d81180bSLoGin /// for linux-specific fcntl commands, see: 6e7071df6SLoGin /// https://code.dragonos.org.cn/xref/linux-5.19.10/tools/include/uapi/linux/fcntl.h#8 76d81180bSLoGin #[derive(Debug, Copy, Clone, Eq, PartialEq, FromPrimitive, ToPrimitive)] 86d81180bSLoGin #[repr(u32)] 96d81180bSLoGin pub enum FcntlCommand { 106d81180bSLoGin /// dup 116d81180bSLoGin DupFd = 0, 126d81180bSLoGin /// get close-on-exec 136d81180bSLoGin GetFd = 1, 146d81180bSLoGin /// set/clear close-on-exec 156d81180bSLoGin SetFd = 2, 166d81180bSLoGin /// get file flags 176d81180bSLoGin GetFlags = 3, 186d81180bSLoGin /// set file flags 196d81180bSLoGin SetFlags = 4, 206d81180bSLoGin /// get record locking info 216d81180bSLoGin GetLock = 5, 226d81180bSLoGin /// set record locking info (non-blocking) 236d81180bSLoGin SetLock = 6, 246d81180bSLoGin /// set record locking info (blocking) 256d81180bSLoGin SetLockWait = 7, 266d81180bSLoGin 27*b5b571e0SLoGin SetLease = F_LINUX_SPECIFIC_BASE, 286d81180bSLoGin GetLease = F_LINUX_SPECIFIC_BASE + 1, 296d81180bSLoGin 306d81180bSLoGin /// Request nofications on a directory. 316d81180bSLoGin /// See below for events that may be notified. 326d81180bSLoGin Notify = F_LINUX_SPECIFIC_BASE + 2, 336d81180bSLoGin 346d81180bSLoGin /// Cancel a blocking posix lock; internal use only until we expose an 356d81180bSLoGin /// asynchronous lock api to userspace 366d81180bSLoGin CancelLock = F_LINUX_SPECIFIC_BASE + 5, 376d81180bSLoGin /// Create a file descriptor with FD_CLOEXEC set. 386d81180bSLoGin DupFdCloexec = F_LINUX_SPECIFIC_BASE + 6, 396d81180bSLoGin 406d81180bSLoGin /// Set pipe page size array 416d81180bSLoGin SetPipeSize = F_LINUX_SPECIFIC_BASE + 7, 426d81180bSLoGin /// Get pipe page size array 436d81180bSLoGin GetPipeSize = F_LINUX_SPECIFIC_BASE + 8, 446d81180bSLoGin 456d81180bSLoGin /// Set seals 466d81180bSLoGin AddSeals = F_LINUX_SPECIFIC_BASE + 9, 476d81180bSLoGin /// Get seals 486d81180bSLoGin GetSeals = F_LINUX_SPECIFIC_BASE + 10, 496d81180bSLoGin 506d81180bSLoGin /** 516d81180bSLoGin * Set/Get write life time hints. {GET,SET}_RW_HINT operate on the 526d81180bSLoGin * underlying inode, while {GET,SET}_FILE_RW_HINT operate only on 536d81180bSLoGin * the specific file. 546d81180bSLoGin */ 556d81180bSLoGin GetRwHint = F_LINUX_SPECIFIC_BASE + 11, 566d81180bSLoGin SetRwHint = F_LINUX_SPECIFIC_BASE + 12, 576d81180bSLoGin GetFileRwHint = F_LINUX_SPECIFIC_BASE + 13, 586d81180bSLoGin SetFileRwHint = F_LINUX_SPECIFIC_BASE + 14, 596d81180bSLoGin } 606d81180bSLoGin 619b0abe6dSLoGin bitflags! { 629b0abe6dSLoGin 63709498caSLoGin /// The constants AT_REMOVEDIR and AT_EACCESS have the same value. AT_EACCESS is 64709498caSLoGin /// meaningful only to faccessat, while AT_REMOVEDIR is meaningful only to 65709498caSLoGin /// unlinkat. The two functions do completely different things and therefore, 66709498caSLoGin /// the flags can be allowed to overlap. For example, passing AT_REMOVEDIR to 67709498caSLoGin /// faccessat would be undefined behavior and thus treating it equivalent to 68709498caSLoGin /// AT_EACCESS is valid undefined behavior. 69*b5b571e0SLoGin #[allow(clippy::bad_bit_mask)] 709b0abe6dSLoGin pub struct AtFlags: i32 { 71709498caSLoGin /// 特殊值,用于指示openat应使用当前工作目录。 729b0abe6dSLoGin const AT_FDCWD = -100; 73709498caSLoGin /// 不要跟随符号链接。 749b0abe6dSLoGin const AT_SYMLINK_NOFOLLOW = 0x100; 75709498caSLoGin /// AtEAccess: 使用有效ID进行访问测试,而不是实际ID。 769b0abe6dSLoGin const AT_EACCESS = 0x200; 77709498caSLoGin /// AtRemoveDir: 删除目录而不是取消链接文件。 789b0abe6dSLoGin const AT_REMOVEDIR = 0x200; 79709498caSLoGin 80709498caSLoGin /// 跟随符号链接。 81709498caSLoGin /// AT_SYMLINK_FOLLOW: 0x400 829b0abe6dSLoGin const AT_SYMLINK_FOLLOW = 0x400; 83709498caSLoGin /// 禁止终端自动挂载遍历。 84709498caSLoGin /// AT_NO_AUTOMOUNT: 0x800 859b0abe6dSLoGin const AT_NO_AUTOMOUNT = 0x800; 86709498caSLoGin /// 允许空的相对路径名。 87709498caSLoGin /// AT_EMPTY_PATH: 0x1000 889b0abe6dSLoGin const AT_EMPTY_PATH = 0x1000; 89709498caSLoGin /// statx()所需的同步类型。 90709498caSLoGin /// AT_STATX_SYNC_TYPE: 0x6000 919b0abe6dSLoGin const AT_STATX_SYNC_TYPE = 0x6000; 92709498caSLoGin /// 执行与stat()相同的操作。 93709498caSLoGin /// AT_STATX_SYNC_AS_STAT: 0x0000 949b0abe6dSLoGin const AT_STATX_SYNC_AS_STAT = 0x0000; 95709498caSLoGin /// 强制将属性与服务器同步。 96709498caSLoGin /// AT_STATX_FORCE_SYNC: 0x2000 979b0abe6dSLoGin const AT_STATX_FORCE_SYNC = 0x2000; 98709498caSLoGin /// 不要将属性与服务器同步。 99709498caSLoGin /// AT_STATX_DONT_SYNC: 0x4000 1009b0abe6dSLoGin const AT_STATX_DONT_SYNC = 0x4000; 101709498caSLoGin /// 应用于整个子树。 102709498caSLoGin /// AT_RECURSIVE: 0x8000 1039b0abe6dSLoGin const AT_RECURSIVE = 0x8000; 104709498caSLoGin } 105709498caSLoGin } 106709498caSLoGin 1076d81180bSLoGin /// for F_[GET|SET]FL 1086d81180bSLoGin pub const FD_CLOEXEC: u32 = 1; 109