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