16d81180bSLoGin const F_LINUX_SPECIFIC_BASE: u32 = 1024; 26d81180bSLoGin 36d81180bSLoGin /// fcntl syscall command 46d81180bSLoGin /// 56d81180bSLoGin /// for linux-specific fcntl commands, see: 66d81180bSLoGin /// https://opengrok.ringotek.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 276d81180bSLoGin SetLease = F_LINUX_SPECIFIC_BASE + 0, 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 61*9b0abe6dSLoGin bitflags! { 62*9b0abe6dSLoGin 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*9b0abe6dSLoGin pub struct AtFlags: i32 { 70709498caSLoGin /// 特殊值,用于指示openat应使用当前工作目录。 71*9b0abe6dSLoGin const AT_FDCWD = -100; 72709498caSLoGin /// 不要跟随符号链接。 73*9b0abe6dSLoGin const AT_SYMLINK_NOFOLLOW = 0x100; 74709498caSLoGin /// AtEAccess: 使用有效ID进行访问测试,而不是实际ID。 75*9b0abe6dSLoGin const AT_EACCESS = 0x200; 76709498caSLoGin /// AtRemoveDir: 删除目录而不是取消链接文件。 77*9b0abe6dSLoGin const AT_REMOVEDIR = 0x200; 78709498caSLoGin 79709498caSLoGin /// 跟随符号链接。 80709498caSLoGin /// AT_SYMLINK_FOLLOW: 0x400 81*9b0abe6dSLoGin const AT_SYMLINK_FOLLOW = 0x400; 82709498caSLoGin /// 禁止终端自动挂载遍历。 83709498caSLoGin /// AT_NO_AUTOMOUNT: 0x800 84*9b0abe6dSLoGin const AT_NO_AUTOMOUNT = 0x800; 85709498caSLoGin /// 允许空的相对路径名。 86709498caSLoGin /// AT_EMPTY_PATH: 0x1000 87*9b0abe6dSLoGin const AT_EMPTY_PATH = 0x1000; 88709498caSLoGin /// statx()所需的同步类型。 89709498caSLoGin /// AT_STATX_SYNC_TYPE: 0x6000 90*9b0abe6dSLoGin const AT_STATX_SYNC_TYPE = 0x6000; 91709498caSLoGin /// 执行与stat()相同的操作。 92709498caSLoGin /// AT_STATX_SYNC_AS_STAT: 0x0000 93*9b0abe6dSLoGin const AT_STATX_SYNC_AS_STAT = 0x0000; 94709498caSLoGin /// 强制将属性与服务器同步。 95709498caSLoGin /// AT_STATX_FORCE_SYNC: 0x2000 96*9b0abe6dSLoGin const AT_STATX_FORCE_SYNC = 0x2000; 97709498caSLoGin /// 不要将属性与服务器同步。 98709498caSLoGin /// AT_STATX_DONT_SYNC: 0x4000 99*9b0abe6dSLoGin const AT_STATX_DONT_SYNC = 0x4000; 100709498caSLoGin /// 应用于整个子树。 101709498caSLoGin /// AT_RECURSIVE: 0x8000 102*9b0abe6dSLoGin const AT_RECURSIVE = 0x8000; 103709498caSLoGin } 104709498caSLoGin } 105709498caSLoGin 1066d81180bSLoGin /// for F_[GET|SET]FL 1076d81180bSLoGin pub const FD_CLOEXEC: u32 = 1; 108