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