xref: /linux/include/uapi/linux/fcntl.h (revision e045e18dbf3eaac32cdeb2799a5ec84fa694636c)
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 /*
12607ca46eSDavid Howells  * Cancel a blocking posix lock; internal use only until we expose an
13607ca46eSDavid Howells  * asynchronous lock api to userspace:
14607ca46eSDavid Howells  */
15607ca46eSDavid Howells #define F_CANCELLK	(F_LINUX_SPECIFIC_BASE + 5)
16607ca46eSDavid Howells 
17607ca46eSDavid Howells /* Create a file descriptor with FD_CLOEXEC set. */
18607ca46eSDavid Howells #define F_DUPFD_CLOEXEC	(F_LINUX_SPECIFIC_BASE + 6)
19607ca46eSDavid Howells 
20607ca46eSDavid Howells /*
21607ca46eSDavid Howells  * Request nofications on a directory.
22607ca46eSDavid Howells  * See below for events that may be notified.
23607ca46eSDavid Howells  */
24607ca46eSDavid Howells #define F_NOTIFY	(F_LINUX_SPECIFIC_BASE+2)
25607ca46eSDavid Howells 
26607ca46eSDavid Howells /*
27607ca46eSDavid Howells  * Set and get of pipe page size array
28607ca46eSDavid Howells  */
29607ca46eSDavid Howells #define F_SETPIPE_SZ	(F_LINUX_SPECIFIC_BASE + 7)
30607ca46eSDavid Howells #define F_GETPIPE_SZ	(F_LINUX_SPECIFIC_BASE + 8)
31607ca46eSDavid Howells 
32607ca46eSDavid Howells /*
3340e041a2SDavid Herrmann  * Set/Get seals
3440e041a2SDavid Herrmann  */
3540e041a2SDavid Herrmann #define F_ADD_SEALS	(F_LINUX_SPECIFIC_BASE + 9)
3640e041a2SDavid Herrmann #define F_GET_SEALS	(F_LINUX_SPECIFIC_BASE + 10)
3740e041a2SDavid Herrmann 
3840e041a2SDavid Herrmann /*
3940e041a2SDavid Herrmann  * Types of seals
4040e041a2SDavid Herrmann  */
4140e041a2SDavid Herrmann #define F_SEAL_SEAL	0x0001	/* prevent further seals from being set */
4240e041a2SDavid Herrmann #define F_SEAL_SHRINK	0x0002	/* prevent file from shrinking */
4340e041a2SDavid Herrmann #define F_SEAL_GROW	0x0004	/* prevent file from growing */
4440e041a2SDavid Herrmann #define F_SEAL_WRITE	0x0008	/* prevent writes */
45ab3948f5SJoel Fernandes (Google) #define F_SEAL_FUTURE_WRITE	0x0010  /* prevent future writes while mapped */
466fd73538SDaniel Verkamp #define F_SEAL_EXEC	0x0020  /* prevent chmod modifying exec bits */
4740e041a2SDavid Herrmann /* (1U << 31) is reserved for signed error codes */
4840e041a2SDavid Herrmann 
4940e041a2SDavid Herrmann /*
50c75b1d94SJens Axboe  * Set/Get write life time hints. {GET,SET}_RW_HINT operate on the
51c75b1d94SJens Axboe  * underlying inode, while {GET,SET}_FILE_RW_HINT operate only on
52c75b1d94SJens Axboe  * the specific file.
53c75b1d94SJens Axboe  */
54c75b1d94SJens Axboe #define F_GET_RW_HINT		(F_LINUX_SPECIFIC_BASE + 11)
55c75b1d94SJens Axboe #define F_SET_RW_HINT		(F_LINUX_SPECIFIC_BASE + 12)
56c75b1d94SJens Axboe #define F_GET_FILE_RW_HINT	(F_LINUX_SPECIFIC_BASE + 13)
57c75b1d94SJens Axboe #define F_SET_FILE_RW_HINT	(F_LINUX_SPECIFIC_BASE + 14)
58c75b1d94SJens Axboe 
59c75b1d94SJens Axboe /*
60c75b1d94SJens Axboe  * Valid hint values for F_{GET,SET}_RW_HINT. 0 is "not set", or can be
61c75b1d94SJens Axboe  * used to clear any hints previously set.
62c75b1d94SJens Axboe  */
639a7f12edSEugene Syromiatnikov #define RWH_WRITE_LIFE_NOT_SET	0
64c75b1d94SJens Axboe #define RWH_WRITE_LIFE_NONE	1
65c75b1d94SJens Axboe #define RWH_WRITE_LIFE_SHORT	2
66c75b1d94SJens Axboe #define RWH_WRITE_LIFE_MEDIUM	3
67c75b1d94SJens Axboe #define RWH_WRITE_LIFE_LONG	4
68c75b1d94SJens Axboe #define RWH_WRITE_LIFE_EXTREME	5
69c75b1d94SJens Axboe 
70c75b1d94SJens Axboe /*
719a7f12edSEugene Syromiatnikov  * The originally introduced spelling is remained from the first
729a7f12edSEugene Syromiatnikov  * versions of the patch set that introduced the feature, see commit
739a7f12edSEugene Syromiatnikov  * v4.13-rc1~212^2~51.
749a7f12edSEugene Syromiatnikov  */
759a7f12edSEugene Syromiatnikov #define RWF_WRITE_LIFE_NOT_SET	RWH_WRITE_LIFE_NOT_SET
769a7f12edSEugene Syromiatnikov 
779a7f12edSEugene Syromiatnikov /*
78607ca46eSDavid Howells  * Types of directory notifications that may be requested.
79607ca46eSDavid Howells  */
80607ca46eSDavid Howells #define DN_ACCESS	0x00000001	/* File accessed */
81607ca46eSDavid Howells #define DN_MODIFY	0x00000002	/* File modified */
82607ca46eSDavid Howells #define DN_CREATE	0x00000004	/* File created */
83607ca46eSDavid Howells #define DN_DELETE	0x00000008	/* File removed */
84607ca46eSDavid Howells #define DN_RENAME	0x00000010	/* File renamed */
85607ca46eSDavid Howells #define DN_ATTRIB	0x00000020	/* File changed attibutes */
86607ca46eSDavid Howells #define DN_MULTISHOT	0x80000000	/* Don't remove notifier */
87607ca46eSDavid Howells 
88c8ffd8bcSMiklos Szeredi /*
89c8ffd8bcSMiklos Szeredi  * The constants AT_REMOVEDIR and AT_EACCESS have the same value.  AT_EACCESS is
90c8ffd8bcSMiklos Szeredi  * meaningful only to faccessat, while AT_REMOVEDIR is meaningful only to
91c8ffd8bcSMiklos Szeredi  * unlinkat.  The two functions do completely different things and therefore,
92c8ffd8bcSMiklos Szeredi  * the flags can be allowed to overlap.  For example, passing AT_REMOVEDIR to
93c8ffd8bcSMiklos Szeredi  * faccessat would be undefined behavior and thus treating it equivalent to
94c8ffd8bcSMiklos Szeredi  * AT_EACCESS is valid undefined behavior.
95c8ffd8bcSMiklos Szeredi  */
96607ca46eSDavid Howells #define AT_FDCWD		-100    /* Special value used to indicate
97607ca46eSDavid Howells                                            openat should use the current
98607ca46eSDavid Howells                                            working directory. */
99607ca46eSDavid Howells #define AT_SYMLINK_NOFOLLOW	0x100   /* Do not follow symbolic links.  */
100c8ffd8bcSMiklos Szeredi #define AT_EACCESS		0x200	/* Test access permitted for
101c8ffd8bcSMiklos Szeredi                                            effective IDs, not real IDs.  */
102607ca46eSDavid Howells #define AT_REMOVEDIR		0x200   /* Remove directory instead of
103607ca46eSDavid Howells                                            unlinking file.  */
104607ca46eSDavid Howells #define AT_SYMLINK_FOLLOW	0x400   /* Follow symbolic links.  */
105607ca46eSDavid Howells #define AT_NO_AUTOMOUNT		0x800	/* Suppress terminal automount traversal */
106607ca46eSDavid Howells #define AT_EMPTY_PATH		0x1000	/* Allow empty relative pathname */
107607ca46eSDavid Howells 
108a528d35eSDavid Howells #define AT_STATX_SYNC_TYPE	0x6000	/* Type of synchronisation required from statx() */
109a528d35eSDavid Howells #define AT_STATX_SYNC_AS_STAT	0x0000	/* - Do whatever stat() does */
110a528d35eSDavid Howells #define AT_STATX_FORCE_SYNC	0x2000	/* - Force the attributes to be sync'd with the server */
111a528d35eSDavid Howells #define AT_STATX_DONT_SYNC	0x4000	/* - Don't sync attributes with the server */
112a528d35eSDavid Howells 
113a07b2000SAl Viro #define AT_RECURSIVE		0x8000	/* Apply to the entire subtree */
114a07b2000SAl Viro 
11596b2b072SAmir Goldstein /* Flags for name_to_handle_at(2). We reuse AT_ flag space to save bits... */
11696b2b072SAmir Goldstein #define AT_HANDLE_FID		AT_REMOVEDIR	/* file handle is needed to
11796b2b072SAmir Goldstein 					compare object identity and may not
11896b2b072SAmir Goldstein 					be usable to open_by_handle_at(2) */
119*8a924db2SStefan Berger #if defined(__KERNEL__)
120*8a924db2SStefan Berger #define AT_GETATTR_NOSEC	0x80000000
121*8a924db2SStefan Berger #endif
12296b2b072SAmir Goldstein 
123607ca46eSDavid Howells #endif /* _UAPI_LINUX_FCNTL_H */
124