16f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2607ca46eSDavid Howells #ifndef _UAPI_LINUX_FCNTL_H 3607ca46eSDavid Howells #define _UAPI_LINUX_FCNTL_H 4607ca46eSDavid Howells 5607ca46eSDavid Howells #include <asm/fcntl.h> 6fddb5d43SAleksa Sarai #include <linux/openat2.h> 7607ca46eSDavid Howells 8607ca46eSDavid Howells #define F_SETLEASE (F_LINUX_SPECIFIC_BASE + 0) 9607ca46eSDavid Howells #define F_GETLEASE (F_LINUX_SPECIFIC_BASE + 1) 10607ca46eSDavid Howells 11607ca46eSDavid Howells /* 12c62b758bSLinus Torvalds * Request nofications on a directory. 13c62b758bSLinus Torvalds * See below for events that may be notified. 14c62b758bSLinus Torvalds */ 15c62b758bSLinus Torvalds #define F_NOTIFY (F_LINUX_SPECIFIC_BASE + 2) 16c62b758bSLinus Torvalds 17c62b758bSLinus Torvalds #define F_DUPFD_QUERY (F_LINUX_SPECIFIC_BASE + 3) 18c62b758bSLinus Torvalds 19820a1858SChristian Brauner /* Was the file just created? */ 20820a1858SChristian Brauner #define F_CREATED_QUERY (F_LINUX_SPECIFIC_BASE + 4) 21820a1858SChristian Brauner 22c62b758bSLinus Torvalds /* 23607ca46eSDavid Howells * Cancel a blocking posix lock; internal use only until we expose an 24607ca46eSDavid Howells * asynchronous lock api to userspace: 25607ca46eSDavid Howells */ 26607ca46eSDavid Howells #define F_CANCELLK (F_LINUX_SPECIFIC_BASE + 5) 27607ca46eSDavid Howells 28607ca46eSDavid Howells /* Create a file descriptor with FD_CLOEXEC set. */ 29607ca46eSDavid Howells #define F_DUPFD_CLOEXEC (F_LINUX_SPECIFIC_BASE + 6) 30607ca46eSDavid Howells 31607ca46eSDavid Howells /* 32607ca46eSDavid Howells * Set and get of pipe page size array 33607ca46eSDavid Howells */ 34607ca46eSDavid Howells #define F_SETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 7) 35607ca46eSDavid Howells #define F_GETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 8) 36607ca46eSDavid Howells 37607ca46eSDavid Howells /* 3840e041a2SDavid Herrmann * Set/Get seals 3940e041a2SDavid Herrmann */ 4040e041a2SDavid Herrmann #define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9) 4140e041a2SDavid Herrmann #define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10) 4240e041a2SDavid Herrmann 4340e041a2SDavid Herrmann /* 4440e041a2SDavid Herrmann * Types of seals 4540e041a2SDavid Herrmann */ 4640e041a2SDavid Herrmann #define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */ 4740e041a2SDavid Herrmann #define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */ 4840e041a2SDavid Herrmann #define F_SEAL_GROW 0x0004 /* prevent file from growing */ 4940e041a2SDavid Herrmann #define F_SEAL_WRITE 0x0008 /* prevent writes */ 50ab3948f5SJoel Fernandes (Google) #define F_SEAL_FUTURE_WRITE 0x0010 /* prevent future writes while mapped */ 516fd73538SDaniel Verkamp #define F_SEAL_EXEC 0x0020 /* prevent chmod modifying exec bits */ 5240e041a2SDavid Herrmann /* (1U << 31) is reserved for signed error codes */ 5340e041a2SDavid Herrmann 5440e041a2SDavid Herrmann /* 55c75b1d94SJens Axboe * Set/Get write life time hints. {GET,SET}_RW_HINT operate on the 56c75b1d94SJens Axboe * underlying inode, while {GET,SET}_FILE_RW_HINT operate only on 57c75b1d94SJens Axboe * the specific file. 58c75b1d94SJens Axboe */ 59c75b1d94SJens Axboe #define F_GET_RW_HINT (F_LINUX_SPECIFIC_BASE + 11) 60c75b1d94SJens Axboe #define F_SET_RW_HINT (F_LINUX_SPECIFIC_BASE + 12) 61c75b1d94SJens Axboe #define F_GET_FILE_RW_HINT (F_LINUX_SPECIFIC_BASE + 13) 62c75b1d94SJens Axboe #define F_SET_FILE_RW_HINT (F_LINUX_SPECIFIC_BASE + 14) 63c75b1d94SJens Axboe 64c75b1d94SJens Axboe /* 65c75b1d94SJens Axboe * Valid hint values for F_{GET,SET}_RW_HINT. 0 is "not set", or can be 66c75b1d94SJens Axboe * used to clear any hints previously set. 67c75b1d94SJens Axboe */ 689a7f12edSEugene Syromiatnikov #define RWH_WRITE_LIFE_NOT_SET 0 69c75b1d94SJens Axboe #define RWH_WRITE_LIFE_NONE 1 70c75b1d94SJens Axboe #define RWH_WRITE_LIFE_SHORT 2 71c75b1d94SJens Axboe #define RWH_WRITE_LIFE_MEDIUM 3 72c75b1d94SJens Axboe #define RWH_WRITE_LIFE_LONG 4 73c75b1d94SJens Axboe #define RWH_WRITE_LIFE_EXTREME 5 74c75b1d94SJens Axboe 75c75b1d94SJens Axboe /* 769a7f12edSEugene Syromiatnikov * The originally introduced spelling is remained from the first 779a7f12edSEugene Syromiatnikov * versions of the patch set that introduced the feature, see commit 789a7f12edSEugene Syromiatnikov * v4.13-rc1~212^2~51. 799a7f12edSEugene Syromiatnikov */ 809a7f12edSEugene Syromiatnikov #define RWF_WRITE_LIFE_NOT_SET RWH_WRITE_LIFE_NOT_SET 819a7f12edSEugene Syromiatnikov 829a7f12edSEugene Syromiatnikov /* 83607ca46eSDavid Howells * Types of directory notifications that may be requested. 84607ca46eSDavid Howells */ 85607ca46eSDavid Howells #define DN_ACCESS 0x00000001 /* File accessed */ 86607ca46eSDavid Howells #define DN_MODIFY 0x00000002 /* File modified */ 87607ca46eSDavid Howells #define DN_CREATE 0x00000004 /* File created */ 88607ca46eSDavid Howells #define DN_DELETE 0x00000008 /* File removed */ 89607ca46eSDavid Howells #define DN_RENAME 0x00000010 /* File renamed */ 90607ca46eSDavid Howells #define DN_ATTRIB 0x00000020 /* File changed attibutes */ 91607ca46eSDavid Howells #define DN_MULTISHOT 0x80000000 /* Don't remove notifier */ 92607ca46eSDavid Howells 93b4fef22cSAleksa Sarai #define AT_FDCWD -100 /* Special value for dirfd used to 94b4fef22cSAleksa Sarai indicate openat should use the 95b4fef22cSAleksa Sarai current working directory. */ 96607ca46eSDavid Howells 97b4fef22cSAleksa Sarai 98b4fef22cSAleksa Sarai /* Generic flags for the *at(2) family of syscalls. */ 99b4fef22cSAleksa Sarai 100b4fef22cSAleksa Sarai /* Reserved for per-syscall flags 0xff. */ 101b4fef22cSAleksa Sarai #define AT_SYMLINK_NOFOLLOW 0x100 /* Do not follow symbolic 102b4fef22cSAleksa Sarai links. */ 103b4fef22cSAleksa Sarai /* Reserved for per-syscall flags 0x200 */ 104b4fef22cSAleksa Sarai #define AT_SYMLINK_FOLLOW 0x400 /* Follow symbolic links. */ 105b4fef22cSAleksa Sarai #define AT_NO_AUTOMOUNT 0x800 /* Suppress terminal automount 106b4fef22cSAleksa Sarai traversal. */ 107b4fef22cSAleksa Sarai #define AT_EMPTY_PATH 0x1000 /* Allow empty relative 108b4fef22cSAleksa Sarai pathname to operate on dirfd 109b4fef22cSAleksa Sarai directly. */ 110b4fef22cSAleksa Sarai /* 111b4fef22cSAleksa Sarai * These flags are currently statx(2)-specific, but they could be made generic 112b4fef22cSAleksa Sarai * in the future and so they should not be used for other per-syscall flags. 113b4fef22cSAleksa Sarai */ 114a528d35eSDavid Howells #define AT_STATX_SYNC_TYPE 0x6000 /* Type of synchronisation required from statx() */ 115a528d35eSDavid Howells #define AT_STATX_SYNC_AS_STAT 0x0000 /* - Do whatever stat() does */ 116a528d35eSDavid Howells #define AT_STATX_FORCE_SYNC 0x2000 /* - Force the attributes to be sync'd with the server */ 117a528d35eSDavid Howells #define AT_STATX_DONT_SYNC 0x4000 /* - Don't sync attributes with the server */ 118a528d35eSDavid Howells 119a07b2000SAl Viro #define AT_RECURSIVE 0x8000 /* Apply to the entire subtree */ 120a07b2000SAl Viro 121b4fef22cSAleksa Sarai /* 122b4fef22cSAleksa Sarai * Per-syscall flags for the *at(2) family of syscalls. 123b4fef22cSAleksa Sarai * 124b4fef22cSAleksa Sarai * These are flags that are so syscall-specific that a user passing these flags 125b4fef22cSAleksa Sarai * to the wrong syscall is so "clearly wrong" that we can safely call such 126b4fef22cSAleksa Sarai * usage "undefined behaviour". 127b4fef22cSAleksa Sarai * 128b4fef22cSAleksa Sarai * For example, the constants AT_REMOVEDIR and AT_EACCESS have the same value. 129b4fef22cSAleksa Sarai * AT_EACCESS is meaningful only to faccessat, while AT_REMOVEDIR is meaningful 130b4fef22cSAleksa Sarai * only to unlinkat. The two functions do completely different things and 131b4fef22cSAleksa Sarai * therefore, the flags can be allowed to overlap. For example, passing 132b4fef22cSAleksa Sarai * AT_REMOVEDIR to faccessat would be undefined behavior and thus treating it 133b4fef22cSAleksa Sarai * equivalent to AT_EACCESS is valid undefined behavior. 134b4fef22cSAleksa Sarai * 135b4fef22cSAleksa Sarai * Note for implementers: When picking a new per-syscall AT_* flag, try to 136b4fef22cSAleksa Sarai * reuse already existing flags first. This leaves us with as many unused bits 137b4fef22cSAleksa Sarai * as possible, so we can use them for generic bits in the future if necessary. 138b4fef22cSAleksa Sarai */ 139b4fef22cSAleksa Sarai 140b4fef22cSAleksa Sarai /* Flags for renameat2(2) (must match legacy RENAME_* flags). */ 141b4fef22cSAleksa Sarai #define AT_RENAME_NOREPLACE 0x0001 142b4fef22cSAleksa Sarai #define AT_RENAME_EXCHANGE 0x0002 143b4fef22cSAleksa Sarai #define AT_RENAME_WHITEOUT 0x0004 144b4fef22cSAleksa Sarai 145b4fef22cSAleksa Sarai /* Flag for faccessat(2). */ 146b4fef22cSAleksa Sarai #define AT_EACCESS 0x200 /* Test access permitted for 147b4fef22cSAleksa Sarai effective IDs, not real IDs. */ 148b4fef22cSAleksa Sarai /* Flag for unlinkat(2). */ 149b4fef22cSAleksa Sarai #define AT_REMOVEDIR 0x200 /* Remove directory instead of 150b4fef22cSAleksa Sarai unlinking file. */ 151b4fef22cSAleksa Sarai /* Flags for name_to_handle_at(2). */ 152b4fef22cSAleksa Sarai #define AT_HANDLE_FID 0x200 /* File handle is needed to compare 153b4fef22cSAleksa Sarai object identity and may not be 154b4fef22cSAleksa Sarai usable with open_by_handle_at(2). */ 1554356d575SAleksa Sarai #define AT_HANDLE_MNT_ID_UNIQUE 0x001 /* Return the u64 unique mount ID. */ 156c374196bSAmir Goldstein #define AT_HANDLE_CONNECTABLE 0x002 /* Request a connectable file handle */ 157b4fef22cSAleksa Sarai 158*a5874fdeSMickaël Salaün /* Flags for execveat2(2). */ 159*a5874fdeSMickaël Salaün #define AT_EXECVE_CHECK 0x10000 /* Only perform a check if execution 160*a5874fdeSMickaël Salaün would be allowed. */ 161*a5874fdeSMickaël Salaün 162607ca46eSDavid Howells #endif /* _UAPI_LINUX_FCNTL_H */ 163