| 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | 
|---|
| 2 | #ifndef _UAPI_LINUX_FCNTL_H | 
|---|
| 3 | #define _UAPI_LINUX_FCNTL_H | 
|---|
| 4 |  | 
|---|
| 5 | #include <asm/fcntl.h> | 
|---|
| 6 | #include <linux/openat2.h> | 
|---|
| 7 |  | 
|---|
| 8 | #define F_SETLEASE	(F_LINUX_SPECIFIC_BASE + 0) | 
|---|
| 9 | #define F_GETLEASE	(F_LINUX_SPECIFIC_BASE + 1) | 
|---|
| 10 |  | 
|---|
| 11 | /* | 
|---|
| 12 | * Request nofications on a directory. | 
|---|
| 13 | * See below for events that may be notified. | 
|---|
| 14 | */ | 
|---|
| 15 | #define F_NOTIFY	(F_LINUX_SPECIFIC_BASE + 2) | 
|---|
| 16 |  | 
|---|
| 17 | #define F_DUPFD_QUERY	(F_LINUX_SPECIFIC_BASE + 3) | 
|---|
| 18 |  | 
|---|
| 19 | /* Was the file just created? */ | 
|---|
| 20 | #define F_CREATED_QUERY	(F_LINUX_SPECIFIC_BASE + 4) | 
|---|
| 21 |  | 
|---|
| 22 | /* | 
|---|
| 23 | * Cancel a blocking posix lock; internal use only until we expose an | 
|---|
| 24 | * asynchronous lock api to userspace: | 
|---|
| 25 | */ | 
|---|
| 26 | #define F_CANCELLK	(F_LINUX_SPECIFIC_BASE + 5) | 
|---|
| 27 |  | 
|---|
| 28 | /* Create a file descriptor with FD_CLOEXEC set. */ | 
|---|
| 29 | #define F_DUPFD_CLOEXEC	(F_LINUX_SPECIFIC_BASE + 6) | 
|---|
| 30 |  | 
|---|
| 31 | /* | 
|---|
| 32 | * Set and get of pipe page size array | 
|---|
| 33 | */ | 
|---|
| 34 | #define F_SETPIPE_SZ	(F_LINUX_SPECIFIC_BASE + 7) | 
|---|
| 35 | #define F_GETPIPE_SZ	(F_LINUX_SPECIFIC_BASE + 8) | 
|---|
| 36 |  | 
|---|
| 37 | /* | 
|---|
| 38 | * Set/Get seals | 
|---|
| 39 | */ | 
|---|
| 40 | #define F_ADD_SEALS	(F_LINUX_SPECIFIC_BASE + 9) | 
|---|
| 41 | #define F_GET_SEALS	(F_LINUX_SPECIFIC_BASE + 10) | 
|---|
| 42 |  | 
|---|
| 43 | /* | 
|---|
| 44 | * Types of seals | 
|---|
| 45 | */ | 
|---|
| 46 | #define F_SEAL_SEAL	0x0001	/* prevent further seals from being set */ | 
|---|
| 47 | #define F_SEAL_SHRINK	0x0002	/* prevent file from shrinking */ | 
|---|
| 48 | #define F_SEAL_GROW	0x0004	/* prevent file from growing */ | 
|---|
| 49 | #define F_SEAL_WRITE	0x0008	/* prevent writes */ | 
|---|
| 50 | #define F_SEAL_FUTURE_WRITE	0x0010  /* prevent future writes while mapped */ | 
|---|
| 51 | #define F_SEAL_EXEC	0x0020  /* prevent chmod modifying exec bits */ | 
|---|
| 52 | /* (1U << 31) is reserved for signed error codes */ | 
|---|
| 53 |  | 
|---|
| 54 | /* | 
|---|
| 55 | * Set/Get write life time hints. {GET,SET}_RW_HINT operate on the | 
|---|
| 56 | * underlying inode, while {GET,SET}_FILE_RW_HINT operate only on | 
|---|
| 57 | * the specific file. | 
|---|
| 58 | */ | 
|---|
| 59 | #define F_GET_RW_HINT		(F_LINUX_SPECIFIC_BASE + 11) | 
|---|
| 60 | #define F_SET_RW_HINT		(F_LINUX_SPECIFIC_BASE + 12) | 
|---|
| 61 | #define F_GET_FILE_RW_HINT	(F_LINUX_SPECIFIC_BASE + 13) | 
|---|
| 62 | #define F_SET_FILE_RW_HINT	(F_LINUX_SPECIFIC_BASE + 14) | 
|---|
| 63 |  | 
|---|
| 64 | /* | 
|---|
| 65 | * Valid hint values for F_{GET,SET}_RW_HINT. 0 is "not set", or can be | 
|---|
| 66 | * used to clear any hints previously set. | 
|---|
| 67 | */ | 
|---|
| 68 | #define RWH_WRITE_LIFE_NOT_SET	0 | 
|---|
| 69 | #define RWH_WRITE_LIFE_NONE	1 | 
|---|
| 70 | #define RWH_WRITE_LIFE_SHORT	2 | 
|---|
| 71 | #define RWH_WRITE_LIFE_MEDIUM	3 | 
|---|
| 72 | #define RWH_WRITE_LIFE_LONG	4 | 
|---|
| 73 | #define RWH_WRITE_LIFE_EXTREME	5 | 
|---|
| 74 |  | 
|---|
| 75 | /* | 
|---|
| 76 | * The originally introduced spelling is remained from the first | 
|---|
| 77 | * versions of the patch set that introduced the feature, see commit | 
|---|
| 78 | * v4.13-rc1~212^2~51. | 
|---|
| 79 | */ | 
|---|
| 80 | #define RWF_WRITE_LIFE_NOT_SET	RWH_WRITE_LIFE_NOT_SET | 
|---|
| 81 |  | 
|---|
| 82 | /* | 
|---|
| 83 | * Types of directory notifications that may be requested. | 
|---|
| 84 | */ | 
|---|
| 85 | #define DN_ACCESS	0x00000001	/* File accessed */ | 
|---|
| 86 | #define DN_MODIFY	0x00000002	/* File modified */ | 
|---|
| 87 | #define DN_CREATE	0x00000004	/* File created */ | 
|---|
| 88 | #define DN_DELETE	0x00000008	/* File removed */ | 
|---|
| 89 | #define DN_RENAME	0x00000010	/* File renamed */ | 
|---|
| 90 | #define DN_ATTRIB	0x00000020	/* File changed attibutes */ | 
|---|
| 91 | #define DN_MULTISHOT	0x80000000	/* Don't remove notifier */ | 
|---|
| 92 |  | 
|---|
| 93 | /* Reserved kernel ranges [-100], [-10000, -40000]. */ | 
|---|
| 94 | #define AT_FDCWD		-100    /* Special value for dirfd used to | 
|---|
| 95 | indicate openat should use the | 
|---|
| 96 | current working directory. */ | 
|---|
| 97 |  | 
|---|
| 98 | /* | 
|---|
| 99 | * The concept of process and threads in userland and the kernel is a confusing | 
|---|
| 100 | * one - within the kernel every thread is a 'task' with its own individual PID, | 
|---|
| 101 | * however from userland's point of view threads are grouped by a single PID, | 
|---|
| 102 | * which is that of the 'thread group leader', typically the first thread | 
|---|
| 103 | * spawned. | 
|---|
| 104 | * | 
|---|
| 105 | * To cut the Gideon knot, for internal kernel usage, we refer to | 
|---|
| 106 | * PIDFD_SELF_THREAD to refer to the current thread (or task from a kernel | 
|---|
| 107 | * perspective), and PIDFD_SELF_THREAD_GROUP to refer to the current thread | 
|---|
| 108 | * group leader... | 
|---|
| 109 | */ | 
|---|
| 110 | #define PIDFD_SELF_THREAD		-10000 /* Current thread. */ | 
|---|
| 111 | #define PIDFD_SELF_THREAD_GROUP		-10001 /* Current thread group leader. */ | 
|---|
| 112 |  | 
|---|
| 113 | #define FD_PIDFS_ROOT			-10002 /* Root of the pidfs filesystem */ | 
|---|
| 114 | #define FD_NSFS_ROOT			-10003 /* Root of the nsfs filesystem */ | 
|---|
| 115 | #define FD_INVALID			-10009 /* Invalid file descriptor: -10000 - EBADF = -10009 */ | 
|---|
| 116 |  | 
|---|
| 117 | /* Generic flags for the *at(2) family of syscalls. */ | 
|---|
| 118 |  | 
|---|
| 119 | /* Reserved for per-syscall flags	0xff. */ | 
|---|
| 120 | #define AT_SYMLINK_NOFOLLOW		0x100   /* Do not follow symbolic | 
|---|
| 121 | links. */ | 
|---|
| 122 | /* Reserved for per-syscall flags	0x200 */ | 
|---|
| 123 | #define AT_SYMLINK_FOLLOW		0x400   /* Follow symbolic links. */ | 
|---|
| 124 | #define AT_NO_AUTOMOUNT			0x800	/* Suppress terminal automount | 
|---|
| 125 | traversal. */ | 
|---|
| 126 | #define AT_EMPTY_PATH			0x1000	/* Allow empty relative | 
|---|
| 127 | pathname to operate on dirfd | 
|---|
| 128 | directly. */ | 
|---|
| 129 | /* | 
|---|
| 130 | * These flags are currently statx(2)-specific, but they could be made generic | 
|---|
| 131 | * in the future and so they should not be used for other per-syscall flags. | 
|---|
| 132 | */ | 
|---|
| 133 | #define AT_STATX_SYNC_TYPE		0x6000	/* Type of synchronisation required from statx() */ | 
|---|
| 134 | #define AT_STATX_SYNC_AS_STAT		0x0000	/* - Do whatever stat() does */ | 
|---|
| 135 | #define AT_STATX_FORCE_SYNC		0x2000	/* - Force the attributes to be sync'd with the server */ | 
|---|
| 136 | #define AT_STATX_DONT_SYNC		0x4000	/* - Don't sync attributes with the server */ | 
|---|
| 137 |  | 
|---|
| 138 | #define AT_RECURSIVE			0x8000	/* Apply to the entire subtree */ | 
|---|
| 139 |  | 
|---|
| 140 | /* | 
|---|
| 141 | * Per-syscall flags for the *at(2) family of syscalls. | 
|---|
| 142 | * | 
|---|
| 143 | * These are flags that are so syscall-specific that a user passing these flags | 
|---|
| 144 | * to the wrong syscall is so "clearly wrong" that we can safely call such | 
|---|
| 145 | * usage "undefined behaviour". | 
|---|
| 146 | * | 
|---|
| 147 | * For example, the constants AT_REMOVEDIR and AT_EACCESS have the same value. | 
|---|
| 148 | * AT_EACCESS is meaningful only to faccessat, while AT_REMOVEDIR is meaningful | 
|---|
| 149 | * only to unlinkat. The two functions do completely different things and | 
|---|
| 150 | * therefore, the flags can be allowed to overlap. For example, passing | 
|---|
| 151 | * AT_REMOVEDIR to faccessat would be undefined behavior and thus treating it | 
|---|
| 152 | * equivalent to AT_EACCESS is valid undefined behavior. | 
|---|
| 153 | * | 
|---|
| 154 | * Note for implementers: When picking a new per-syscall AT_* flag, try to | 
|---|
| 155 | * reuse already existing flags first. This leaves us with as many unused bits | 
|---|
| 156 | * as possible, so we can use them for generic bits in the future if necessary. | 
|---|
| 157 | */ | 
|---|
| 158 |  | 
|---|
| 159 | /* Flags for renameat2(2) (must match legacy RENAME_* flags). */ | 
|---|
| 160 | #define AT_RENAME_NOREPLACE	0x0001 | 
|---|
| 161 | #define AT_RENAME_EXCHANGE	0x0002 | 
|---|
| 162 | #define AT_RENAME_WHITEOUT	0x0004 | 
|---|
| 163 |  | 
|---|
| 164 | /* Flag for faccessat(2). */ | 
|---|
| 165 | #define AT_EACCESS		0x200	/* Test access permitted for | 
|---|
| 166 | effective IDs, not real IDs.  */ | 
|---|
| 167 | /* Flag for unlinkat(2). */ | 
|---|
| 168 | #define AT_REMOVEDIR		0x200   /* Remove directory instead of | 
|---|
| 169 | unlinking file.  */ | 
|---|
| 170 | /* Flags for name_to_handle_at(2). */ | 
|---|
| 171 | #define AT_HANDLE_FID		0x200	/* File handle is needed to compare | 
|---|
| 172 | object identity and may not be | 
|---|
| 173 | usable with open_by_handle_at(2). */ | 
|---|
| 174 | #define AT_HANDLE_MNT_ID_UNIQUE	0x001	/* Return the u64 unique mount ID. */ | 
|---|
| 175 | #define AT_HANDLE_CONNECTABLE	0x002	/* Request a connectable file handle */ | 
|---|
| 176 |  | 
|---|
| 177 | /* Flags for execveat2(2). */ | 
|---|
| 178 | #define AT_EXECVE_CHECK		0x10000	/* Only perform a check if execution | 
|---|
| 179 | would be allowed. */ | 
|---|
| 180 |  | 
|---|
| 181 | #endif /* _UAPI_LINUX_FCNTL_H */ | 
|---|
| 182 |  | 
|---|