xref: /DragonOS/kernel/src/filesystem/vfs/fcntl.rs (revision 607783d7414735d1dc54afb0c7346ed8e13303a2)
1 const F_LINUX_SPECIFIC_BASE: u32 = 1024;
2 
3 /// fcntl syscall command
4 ///
5 /// for linux-specific fcntl commands, see:
6 /// https://opengrok.ringotek.cn/xref/linux-5.19.10/tools/include/uapi/linux/fcntl.h#8
7 #[derive(Debug, Copy, Clone, Eq, PartialEq, FromPrimitive, ToPrimitive)]
8 #[repr(u32)]
9 pub enum FcntlCommand {
10     /// dup
11     DupFd = 0,
12     /// get close-on-exec
13     GetFd = 1,
14     /// set/clear close-on-exec
15     SetFd = 2,
16     /// get file flags
17     GetFlags = 3,
18     /// set file flags
19     SetFlags = 4,
20     /// get record locking info
21     GetLock = 5,
22     /// set record locking info (non-blocking)
23     SetLock = 6,
24     /// set record locking info (blocking)
25     SetLockWait = 7,
26 
27     SetLease = F_LINUX_SPECIFIC_BASE + 0,
28     GetLease = F_LINUX_SPECIFIC_BASE + 1,
29 
30     /// Request nofications on a directory.
31     /// See below for events that may be notified.
32     Notify = F_LINUX_SPECIFIC_BASE + 2,
33 
34     /// Cancel a blocking posix lock; internal use only until we expose an
35     /// asynchronous lock api to userspace
36     CancelLock = F_LINUX_SPECIFIC_BASE + 5,
37     /// Create a file descriptor with FD_CLOEXEC set.
38     DupFdCloexec = F_LINUX_SPECIFIC_BASE + 6,
39 
40     /// Set pipe page size array
41     SetPipeSize = F_LINUX_SPECIFIC_BASE + 7,
42     /// Get pipe page size array
43     GetPipeSize = F_LINUX_SPECIFIC_BASE + 8,
44 
45     /// Set seals
46     AddSeals = F_LINUX_SPECIFIC_BASE + 9,
47     /// Get seals
48     GetSeals = F_LINUX_SPECIFIC_BASE + 10,
49 
50     /**
51      * Set/Get write life time hints. {GET,SET}_RW_HINT operate on the
52      * underlying inode, while {GET,SET}_FILE_RW_HINT operate only on
53      * the specific file.
54      */
55     GetRwHint = F_LINUX_SPECIFIC_BASE + 11,
56     SetRwHint = F_LINUX_SPECIFIC_BASE + 12,
57     GetFileRwHint = F_LINUX_SPECIFIC_BASE + 13,
58     SetFileRwHint = F_LINUX_SPECIFIC_BASE + 14,
59 }
60 
61 /// for F_[GET|SET]FL
62 pub const FD_CLOEXEC: u32 = 1;
63