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