xref: /aosp_15_r20/external/libbpf/include/uapi/linux/fcntl.h (revision f7c14bbac8cf49633f2740db462ea43457973ec4)
1*f7c14bbaSAndroid Build Coastguard Worker /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2*f7c14bbaSAndroid Build Coastguard Worker #ifndef _UAPI_LINUX_FCNTL_H
3*f7c14bbaSAndroid Build Coastguard Worker #define _UAPI_LINUX_FCNTL_H
4*f7c14bbaSAndroid Build Coastguard Worker 
5*f7c14bbaSAndroid Build Coastguard Worker #include <asm/fcntl.h>
6*f7c14bbaSAndroid Build Coastguard Worker #include <linux/openat2.h>
7*f7c14bbaSAndroid Build Coastguard Worker 
8*f7c14bbaSAndroid Build Coastguard Worker #define F_SETLEASE	(F_LINUX_SPECIFIC_BASE + 0)
9*f7c14bbaSAndroid Build Coastguard Worker #define F_GETLEASE	(F_LINUX_SPECIFIC_BASE + 1)
10*f7c14bbaSAndroid Build Coastguard Worker 
11*f7c14bbaSAndroid Build Coastguard Worker /*
12*f7c14bbaSAndroid Build Coastguard Worker  * Cancel a blocking posix lock; internal use only until we expose an
13*f7c14bbaSAndroid Build Coastguard Worker  * asynchronous lock api to userspace:
14*f7c14bbaSAndroid Build Coastguard Worker  */
15*f7c14bbaSAndroid Build Coastguard Worker #define F_CANCELLK	(F_LINUX_SPECIFIC_BASE + 5)
16*f7c14bbaSAndroid Build Coastguard Worker 
17*f7c14bbaSAndroid Build Coastguard Worker /* Create a file descriptor with FD_CLOEXEC set. */
18*f7c14bbaSAndroid Build Coastguard Worker #define F_DUPFD_CLOEXEC	(F_LINUX_SPECIFIC_BASE + 6)
19*f7c14bbaSAndroid Build Coastguard Worker 
20*f7c14bbaSAndroid Build Coastguard Worker /*
21*f7c14bbaSAndroid Build Coastguard Worker  * Request nofications on a directory.
22*f7c14bbaSAndroid Build Coastguard Worker  * See below for events that may be notified.
23*f7c14bbaSAndroid Build Coastguard Worker  */
24*f7c14bbaSAndroid Build Coastguard Worker #define F_NOTIFY	(F_LINUX_SPECIFIC_BASE+2)
25*f7c14bbaSAndroid Build Coastguard Worker 
26*f7c14bbaSAndroid Build Coastguard Worker /*
27*f7c14bbaSAndroid Build Coastguard Worker  * Set and get of pipe page size array
28*f7c14bbaSAndroid Build Coastguard Worker  */
29*f7c14bbaSAndroid Build Coastguard Worker #define F_SETPIPE_SZ	(F_LINUX_SPECIFIC_BASE + 7)
30*f7c14bbaSAndroid Build Coastguard Worker #define F_GETPIPE_SZ	(F_LINUX_SPECIFIC_BASE + 8)
31*f7c14bbaSAndroid Build Coastguard Worker 
32*f7c14bbaSAndroid Build Coastguard Worker /*
33*f7c14bbaSAndroid Build Coastguard Worker  * Set/Get seals
34*f7c14bbaSAndroid Build Coastguard Worker  */
35*f7c14bbaSAndroid Build Coastguard Worker #define F_ADD_SEALS	(F_LINUX_SPECIFIC_BASE + 9)
36*f7c14bbaSAndroid Build Coastguard Worker #define F_GET_SEALS	(F_LINUX_SPECIFIC_BASE + 10)
37*f7c14bbaSAndroid Build Coastguard Worker 
38*f7c14bbaSAndroid Build Coastguard Worker /*
39*f7c14bbaSAndroid Build Coastguard Worker  * Types of seals
40*f7c14bbaSAndroid Build Coastguard Worker  */
41*f7c14bbaSAndroid Build Coastguard Worker #define F_SEAL_SEAL	0x0001	/* prevent further seals from being set */
42*f7c14bbaSAndroid Build Coastguard Worker #define F_SEAL_SHRINK	0x0002	/* prevent file from shrinking */
43*f7c14bbaSAndroid Build Coastguard Worker #define F_SEAL_GROW	0x0004	/* prevent file from growing */
44*f7c14bbaSAndroid Build Coastguard Worker #define F_SEAL_WRITE	0x0008	/* prevent writes */
45*f7c14bbaSAndroid Build Coastguard Worker #define F_SEAL_FUTURE_WRITE	0x0010  /* prevent future writes while mapped */
46*f7c14bbaSAndroid Build Coastguard Worker #define F_SEAL_EXEC	0x0020  /* prevent chmod modifying exec bits */
47*f7c14bbaSAndroid Build Coastguard Worker /* (1U << 31) is reserved for signed error codes */
48*f7c14bbaSAndroid Build Coastguard Worker 
49*f7c14bbaSAndroid Build Coastguard Worker /*
50*f7c14bbaSAndroid Build Coastguard Worker  * Set/Get write life time hints. {GET,SET}_RW_HINT operate on the
51*f7c14bbaSAndroid Build Coastguard Worker  * underlying inode, while {GET,SET}_FILE_RW_HINT operate only on
52*f7c14bbaSAndroid Build Coastguard Worker  * the specific file.
53*f7c14bbaSAndroid Build Coastguard Worker  */
54*f7c14bbaSAndroid Build Coastguard Worker #define F_GET_RW_HINT		(F_LINUX_SPECIFIC_BASE + 11)
55*f7c14bbaSAndroid Build Coastguard Worker #define F_SET_RW_HINT		(F_LINUX_SPECIFIC_BASE + 12)
56*f7c14bbaSAndroid Build Coastguard Worker #define F_GET_FILE_RW_HINT	(F_LINUX_SPECIFIC_BASE + 13)
57*f7c14bbaSAndroid Build Coastguard Worker #define F_SET_FILE_RW_HINT	(F_LINUX_SPECIFIC_BASE + 14)
58*f7c14bbaSAndroid Build Coastguard Worker 
59*f7c14bbaSAndroid Build Coastguard Worker /*
60*f7c14bbaSAndroid Build Coastguard Worker  * Valid hint values for F_{GET,SET}_RW_HINT. 0 is "not set", or can be
61*f7c14bbaSAndroid Build Coastguard Worker  * used to clear any hints previously set.
62*f7c14bbaSAndroid Build Coastguard Worker  */
63*f7c14bbaSAndroid Build Coastguard Worker #define RWH_WRITE_LIFE_NOT_SET	0
64*f7c14bbaSAndroid Build Coastguard Worker #define RWH_WRITE_LIFE_NONE	1
65*f7c14bbaSAndroid Build Coastguard Worker #define RWH_WRITE_LIFE_SHORT	2
66*f7c14bbaSAndroid Build Coastguard Worker #define RWH_WRITE_LIFE_MEDIUM	3
67*f7c14bbaSAndroid Build Coastguard Worker #define RWH_WRITE_LIFE_LONG	4
68*f7c14bbaSAndroid Build Coastguard Worker #define RWH_WRITE_LIFE_EXTREME	5
69*f7c14bbaSAndroid Build Coastguard Worker 
70*f7c14bbaSAndroid Build Coastguard Worker /*
71*f7c14bbaSAndroid Build Coastguard Worker  * The originally introduced spelling is remained from the first
72*f7c14bbaSAndroid Build Coastguard Worker  * versions of the patch set that introduced the feature, see commit
73*f7c14bbaSAndroid Build Coastguard Worker  * v4.13-rc1~212^2~51.
74*f7c14bbaSAndroid Build Coastguard Worker  */
75*f7c14bbaSAndroid Build Coastguard Worker #define RWF_WRITE_LIFE_NOT_SET	RWH_WRITE_LIFE_NOT_SET
76*f7c14bbaSAndroid Build Coastguard Worker 
77*f7c14bbaSAndroid Build Coastguard Worker /*
78*f7c14bbaSAndroid Build Coastguard Worker  * Types of directory notifications that may be requested.
79*f7c14bbaSAndroid Build Coastguard Worker  */
80*f7c14bbaSAndroid Build Coastguard Worker #define DN_ACCESS	0x00000001	/* File accessed */
81*f7c14bbaSAndroid Build Coastguard Worker #define DN_MODIFY	0x00000002	/* File modified */
82*f7c14bbaSAndroid Build Coastguard Worker #define DN_CREATE	0x00000004	/* File created */
83*f7c14bbaSAndroid Build Coastguard Worker #define DN_DELETE	0x00000008	/* File removed */
84*f7c14bbaSAndroid Build Coastguard Worker #define DN_RENAME	0x00000010	/* File renamed */
85*f7c14bbaSAndroid Build Coastguard Worker #define DN_ATTRIB	0x00000020	/* File changed attibutes */
86*f7c14bbaSAndroid Build Coastguard Worker #define DN_MULTISHOT	0x80000000	/* Don't remove notifier */
87*f7c14bbaSAndroid Build Coastguard Worker 
88*f7c14bbaSAndroid Build Coastguard Worker /*
89*f7c14bbaSAndroid Build Coastguard Worker  * The constants AT_REMOVEDIR and AT_EACCESS have the same value.  AT_EACCESS is
90*f7c14bbaSAndroid Build Coastguard Worker  * meaningful only to faccessat, while AT_REMOVEDIR is meaningful only to
91*f7c14bbaSAndroid Build Coastguard Worker  * unlinkat.  The two functions do completely different things and therefore,
92*f7c14bbaSAndroid Build Coastguard Worker  * the flags can be allowed to overlap.  For example, passing AT_REMOVEDIR to
93*f7c14bbaSAndroid Build Coastguard Worker  * faccessat would be undefined behavior and thus treating it equivalent to
94*f7c14bbaSAndroid Build Coastguard Worker  * AT_EACCESS is valid undefined behavior.
95*f7c14bbaSAndroid Build Coastguard Worker  */
96*f7c14bbaSAndroid Build Coastguard Worker #define AT_FDCWD		-100    /* Special value used to indicate
97*f7c14bbaSAndroid Build Coastguard Worker                                            openat should use the current
98*f7c14bbaSAndroid Build Coastguard Worker                                            working directory. */
99*f7c14bbaSAndroid Build Coastguard Worker #define AT_SYMLINK_NOFOLLOW	0x100   /* Do not follow symbolic links.  */
100*f7c14bbaSAndroid Build Coastguard Worker #define AT_EACCESS		0x200	/* Test access permitted for
101*f7c14bbaSAndroid Build Coastguard Worker                                            effective IDs, not real IDs.  */
102*f7c14bbaSAndroid Build Coastguard Worker #define AT_REMOVEDIR		0x200   /* Remove directory instead of
103*f7c14bbaSAndroid Build Coastguard Worker                                            unlinking file.  */
104*f7c14bbaSAndroid Build Coastguard Worker #define AT_SYMLINK_FOLLOW	0x400   /* Follow symbolic links.  */
105*f7c14bbaSAndroid Build Coastguard Worker #define AT_NO_AUTOMOUNT		0x800	/* Suppress terminal automount traversal */
106*f7c14bbaSAndroid Build Coastguard Worker #define AT_EMPTY_PATH		0x1000	/* Allow empty relative pathname */
107*f7c14bbaSAndroid Build Coastguard Worker 
108*f7c14bbaSAndroid Build Coastguard Worker #define AT_STATX_SYNC_TYPE	0x6000	/* Type of synchronisation required from statx() */
109*f7c14bbaSAndroid Build Coastguard Worker #define AT_STATX_SYNC_AS_STAT	0x0000	/* - Do whatever stat() does */
110*f7c14bbaSAndroid Build Coastguard Worker #define AT_STATX_FORCE_SYNC	0x2000	/* - Force the attributes to be sync'd with the server */
111*f7c14bbaSAndroid Build Coastguard Worker #define AT_STATX_DONT_SYNC	0x4000	/* - Don't sync attributes with the server */
112*f7c14bbaSAndroid Build Coastguard Worker 
113*f7c14bbaSAndroid Build Coastguard Worker #define AT_RECURSIVE		0x8000	/* Apply to the entire subtree */
114*f7c14bbaSAndroid Build Coastguard Worker 
115*f7c14bbaSAndroid Build Coastguard Worker /* Flags for name_to_handle_at(2). We reuse AT_ flag space to save bits... */
116*f7c14bbaSAndroid Build Coastguard Worker #define AT_HANDLE_FID		AT_REMOVEDIR	/* file handle is needed to
117*f7c14bbaSAndroid Build Coastguard Worker 					compare object identity and may not
118*f7c14bbaSAndroid Build Coastguard Worker 					be usable to open_by_handle_at(2) */
119*f7c14bbaSAndroid Build Coastguard Worker #if defined(__KERNEL__)
120*f7c14bbaSAndroid Build Coastguard Worker #define AT_GETATTR_NOSEC	0x80000000
121*f7c14bbaSAndroid Build Coastguard Worker #endif
122*f7c14bbaSAndroid Build Coastguard Worker 
123*f7c14bbaSAndroid Build Coastguard Worker #endif /* _UAPI_LINUX_FCNTL_H */
124