xref: /openbmc/linux/include/uapi/asm-generic/fcntl.h (revision 43b45063)
16f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
28a1ab315SDavid Howells #ifndef _ASM_GENERIC_FCNTL_H
38a1ab315SDavid Howells #define _ASM_GENERIC_FCNTL_H
48a1ab315SDavid Howells 
58a1ab315SDavid Howells #include <linux/types.h>
68a1ab315SDavid Howells 
78a1ab315SDavid Howells /*
88a1ab315SDavid Howells  * FMODE_EXEC is 0x20
975069f2bSDavid Drysdale  * FMODE_NONOTIFY is 0x4000000
108a1ab315SDavid Howells  * These cannot be used by userspace O_* until internal and external open
118a1ab315SDavid Howells  * flags are split.
128a1ab315SDavid Howells  * -Eric Paris
138a1ab315SDavid Howells  */
148a1ab315SDavid Howells 
158a1ab315SDavid Howells /*
168a1ab315SDavid Howells  * When introducing new O_* bits, please check its uniqueness in fcntl_init().
178a1ab315SDavid Howells  */
188a1ab315SDavid Howells 
198a1ab315SDavid Howells #define O_ACCMODE	00000003
208a1ab315SDavid Howells #define O_RDONLY	00000000
218a1ab315SDavid Howells #define O_WRONLY	00000001
228a1ab315SDavid Howells #define O_RDWR		00000002
238a1ab315SDavid Howells #ifndef O_CREAT
248a1ab315SDavid Howells #define O_CREAT		00000100	/* not fcntl */
258a1ab315SDavid Howells #endif
268a1ab315SDavid Howells #ifndef O_EXCL
278a1ab315SDavid Howells #define O_EXCL		00000200	/* not fcntl */
288a1ab315SDavid Howells #endif
298a1ab315SDavid Howells #ifndef O_NOCTTY
308a1ab315SDavid Howells #define O_NOCTTY	00000400	/* not fcntl */
318a1ab315SDavid Howells #endif
328a1ab315SDavid Howells #ifndef O_TRUNC
338a1ab315SDavid Howells #define O_TRUNC		00001000	/* not fcntl */
348a1ab315SDavid Howells #endif
358a1ab315SDavid Howells #ifndef O_APPEND
368a1ab315SDavid Howells #define O_APPEND	00002000
378a1ab315SDavid Howells #endif
388a1ab315SDavid Howells #ifndef O_NONBLOCK
398a1ab315SDavid Howells #define O_NONBLOCK	00004000
408a1ab315SDavid Howells #endif
418a1ab315SDavid Howells #ifndef O_DSYNC
428a1ab315SDavid Howells #define O_DSYNC		00010000	/* used to be O_SYNC, see below */
438a1ab315SDavid Howells #endif
448a1ab315SDavid Howells #ifndef FASYNC
458a1ab315SDavid Howells #define FASYNC		00020000	/* fcntl, for BSD compatibility */
468a1ab315SDavid Howells #endif
478a1ab315SDavid Howells #ifndef O_DIRECT
488a1ab315SDavid Howells #define O_DIRECT	00040000	/* direct disk access hint */
498a1ab315SDavid Howells #endif
508a1ab315SDavid Howells #ifndef O_LARGEFILE
518a1ab315SDavid Howells #define O_LARGEFILE	00100000
528a1ab315SDavid Howells #endif
538a1ab315SDavid Howells #ifndef O_DIRECTORY
548a1ab315SDavid Howells #define O_DIRECTORY	00200000	/* must be a directory */
558a1ab315SDavid Howells #endif
568a1ab315SDavid Howells #ifndef O_NOFOLLOW
578a1ab315SDavid Howells #define O_NOFOLLOW	00400000	/* don't follow links */
588a1ab315SDavid Howells #endif
598a1ab315SDavid Howells #ifndef O_NOATIME
608a1ab315SDavid Howells #define O_NOATIME	01000000
618a1ab315SDavid Howells #endif
628a1ab315SDavid Howells #ifndef O_CLOEXEC
638a1ab315SDavid Howells #define O_CLOEXEC	02000000	/* set close_on_exec */
648a1ab315SDavid Howells #endif
658a1ab315SDavid Howells 
668a1ab315SDavid Howells /*
678a1ab315SDavid Howells  * Before Linux 2.6.33 only O_DSYNC semantics were implemented, but using
688a1ab315SDavid Howells  * the O_SYNC flag.  We continue to use the existing numerical value
698a1ab315SDavid Howells  * for O_DSYNC semantics now, but using the correct symbolic name for it.
708a1ab315SDavid Howells  * This new value is used to request true Posix O_SYNC semantics.  It is
718a1ab315SDavid Howells  * defined in this strange way to make sure applications compiled against
728a1ab315SDavid Howells  * new headers get at least O_DSYNC semantics on older kernels.
738a1ab315SDavid Howells  *
748a1ab315SDavid Howells  * This has the nice side-effect that we can simply test for O_DSYNC
758a1ab315SDavid Howells  * wherever we do not care if O_DSYNC or O_SYNC is used.
768a1ab315SDavid Howells  *
778a1ab315SDavid Howells  * Note: __O_SYNC must never be used directly.
788a1ab315SDavid Howells  */
798a1ab315SDavid Howells #ifndef O_SYNC
808a1ab315SDavid Howells #define __O_SYNC	04000000
818a1ab315SDavid Howells #define O_SYNC		(__O_SYNC|O_DSYNC)
828a1ab315SDavid Howells #endif
838a1ab315SDavid Howells 
848a1ab315SDavid Howells #ifndef O_PATH
858a1ab315SDavid Howells #define O_PATH		010000000
868a1ab315SDavid Howells #endif
878a1ab315SDavid Howells 
88bb458c64SAl Viro #ifndef __O_TMPFILE
89bb458c64SAl Viro #define __O_TMPFILE	020000000
9060545d0dSAl Viro #endif
9160545d0dSAl Viro 
92bb458c64SAl Viro /* a horrid kludge trying to make sure that this will fail on old kernels */
93ba57ea64SAl Viro #define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
94bb458c64SAl Viro 
958a1ab315SDavid Howells #ifndef O_NDELAY
968a1ab315SDavid Howells #define O_NDELAY	O_NONBLOCK
978a1ab315SDavid Howells #endif
988a1ab315SDavid Howells 
998a1ab315SDavid Howells #define F_DUPFD		0	/* dup */
1008a1ab315SDavid Howells #define F_GETFD		1	/* get close_on_exec */
1018a1ab315SDavid Howells #define F_SETFD		2	/* set/clear close_on_exec */
1028a1ab315SDavid Howells #define F_GETFL		3	/* get file->f_flags */
1038a1ab315SDavid Howells #define F_SETFL		4	/* set file->f_flags */
1048a1ab315SDavid Howells #ifndef F_GETLK
1058a1ab315SDavid Howells #define F_GETLK		5
1068a1ab315SDavid Howells #define F_SETLK		6
1078a1ab315SDavid Howells #define F_SETLKW	7
1088a1ab315SDavid Howells #endif
1098a1ab315SDavid Howells #ifndef F_SETOWN
1108a1ab315SDavid Howells #define F_SETOWN	8	/* for sockets. */
1118a1ab315SDavid Howells #define F_GETOWN	9	/* for sockets. */
1128a1ab315SDavid Howells #endif
1138a1ab315SDavid Howells #ifndef F_SETSIG
1148a1ab315SDavid Howells #define F_SETSIG	10	/* for sockets. */
1158a1ab315SDavid Howells #define F_GETSIG	11	/* for sockets. */
1168a1ab315SDavid Howells #endif
1178a1ab315SDavid Howells 
118306f7cc1SChristoph Hellwig #if __BITS_PER_LONG == 32 || defined(__KERNEL__)
1198a1ab315SDavid Howells #ifndef F_GETLK64
1208a1ab315SDavid Howells #define F_GETLK64	12	/*  using 'struct flock64' */
1218a1ab315SDavid Howells #define F_SETLK64	13
1228a1ab315SDavid Howells #define F_SETLKW64	14
1238a1ab315SDavid Howells #endif
124306f7cc1SChristoph Hellwig #endif /* __BITS_PER_LONG == 32 || defined(__KERNEL__) */
1258a1ab315SDavid Howells 
1268a1ab315SDavid Howells #ifndef F_SETOWN_EX
1278a1ab315SDavid Howells #define F_SETOWN_EX	15
1288a1ab315SDavid Howells #define F_GETOWN_EX	16
1298a1ab315SDavid Howells #endif
1308a1ab315SDavid Howells 
1318a1ab315SDavid Howells #ifndef F_GETOWNER_UIDS
1328a1ab315SDavid Howells #define F_GETOWNER_UIDS	17
1338a1ab315SDavid Howells #endif
1348a1ab315SDavid Howells 
1355d50ffd7SJeff Layton /*
1360d3f7a2dSJeff Layton  * Open File Description Locks
1375d50ffd7SJeff Layton  *
1380d3f7a2dSJeff Layton  * Usually record locks held by a process are released on *any* close and are
1395d50ffd7SJeff Layton  * not inherited across a fork().
1405d50ffd7SJeff Layton  *
1410d3f7a2dSJeff Layton  * These cmd values will set locks that conflict with process-associated
1420d3f7a2dSJeff Layton  * record  locks, but are "owned" by the open file description, not the
1430d3f7a2dSJeff Layton  * process. This means that they are inherited across fork() like BSD (flock)
1440d3f7a2dSJeff Layton  * locks, and they are only released automatically when the last reference to
1450d3f7a2dSJeff Layton  * the the open file against which they were acquired is put.
1465d50ffd7SJeff Layton  */
1470d3f7a2dSJeff Layton #define F_OFD_GETLK	36
1480d3f7a2dSJeff Layton #define F_OFD_SETLK	37
1490d3f7a2dSJeff Layton #define F_OFD_SETLKW	38
1505d50ffd7SJeff Layton 
1518a1ab315SDavid Howells #define F_OWNER_TID	0
1528a1ab315SDavid Howells #define F_OWNER_PID	1
1538a1ab315SDavid Howells #define F_OWNER_PGRP	2
1548a1ab315SDavid Howells 
1558a1ab315SDavid Howells struct f_owner_ex {
1568a1ab315SDavid Howells 	int	type;
1578a1ab315SDavid Howells 	__kernel_pid_t	pid;
1588a1ab315SDavid Howells };
1598a1ab315SDavid Howells 
1608a1ab315SDavid Howells /* for F_[GET|SET]FL */
1618a1ab315SDavid Howells #define FD_CLOEXEC	1	/* actually anything with low bit set goes */
1628a1ab315SDavid Howells 
1638a1ab315SDavid Howells /* for posix fcntl() and lockf() */
1648a1ab315SDavid Howells #ifndef F_RDLCK
1658a1ab315SDavid Howells #define F_RDLCK		0
1668a1ab315SDavid Howells #define F_WRLCK		1
1678a1ab315SDavid Howells #define F_UNLCK		2
1688a1ab315SDavid Howells #endif
1698a1ab315SDavid Howells 
1708a1ab315SDavid Howells /* for old implementation of bsd flock () */
1718a1ab315SDavid Howells #ifndef F_EXLCK
1728a1ab315SDavid Howells #define F_EXLCK		4	/* or 3 */
1738a1ab315SDavid Howells #define F_SHLCK		8	/* or 4 */
1748a1ab315SDavid Howells #endif
1758a1ab315SDavid Howells 
1768a1ab315SDavid Howells /* operations for bsd flock(), also used by the kernel implementation */
1778a1ab315SDavid Howells #define LOCK_SH		1	/* shared lock */
1788a1ab315SDavid Howells #define LOCK_EX		2	/* exclusive lock */
1798a1ab315SDavid Howells #define LOCK_NB		4	/* or'd with one of the above to prevent
1808a1ab315SDavid Howells 				   blocking */
1818a1ab315SDavid Howells #define LOCK_UN		8	/* remove lock */
1828a1ab315SDavid Howells 
18390f7d7a0SJeff Layton /*
18490f7d7a0SJeff Layton  * LOCK_MAND support has been removed from the kernel. We leave the symbols
18590f7d7a0SJeff Layton  * here to not break legacy builds, but these should not be used in new code.
18690f7d7a0SJeff Layton  */
1878a1ab315SDavid Howells #define LOCK_MAND	32	/* This is a mandatory flock ... */
1888a1ab315SDavid Howells #define LOCK_READ	64	/* which allows concurrent read operations */
1898a1ab315SDavid Howells #define LOCK_WRITE	128	/* which allows concurrent write operations */
1908a1ab315SDavid Howells #define LOCK_RW		192	/* which allows concurrent read & write ops */
1918a1ab315SDavid Howells 
1928a1ab315SDavid Howells #define F_LINUX_SPECIFIC_BASE	1024
1938a1ab315SDavid Howells 
194*9b31e608SFlorian Fainelli #ifndef HAVE_ARCH_STRUCT_FLOCK
1958a1ab315SDavid Howells struct flock {
1968a1ab315SDavid Howells 	short	l_type;
1978a1ab315SDavid Howells 	short	l_whence;
1988a1ab315SDavid Howells 	__kernel_off_t	l_start;
1998a1ab315SDavid Howells 	__kernel_off_t	l_len;
2008a1ab315SDavid Howells 	__kernel_pid_t	l_pid;
2019f79b8b7SChristoph Hellwig #ifdef	__ARCH_FLOCK_EXTRA_SYSID
2029f79b8b7SChristoph Hellwig 	__ARCH_FLOCK_EXTRA_SYSID
2039f79b8b7SChristoph Hellwig #endif
2049f79b8b7SChristoph Hellwig #ifdef	__ARCH_FLOCK_PAD
2058a1ab315SDavid Howells 	__ARCH_FLOCK_PAD
2069f79b8b7SChristoph Hellwig #endif
2078a1ab315SDavid Howells };
2088a1ab315SDavid Howells 
2098a1ab315SDavid Howells struct flock64 {
2108a1ab315SDavid Howells 	short  l_type;
2118a1ab315SDavid Howells 	short  l_whence;
2128a1ab315SDavid Howells 	__kernel_loff_t l_start;
2138a1ab315SDavid Howells 	__kernel_loff_t l_len;
2148a1ab315SDavid Howells 	__kernel_pid_t  l_pid;
2159f79b8b7SChristoph Hellwig #ifdef	__ARCH_FLOCK64_PAD
2168a1ab315SDavid Howells 	__ARCH_FLOCK64_PAD
2178a1ab315SDavid Howells #endif
2189f79b8b7SChristoph Hellwig };
219*9b31e608SFlorian Fainelli #endif /* HAVE_ARCH_STRUCT_FLOCK */
2208a1ab315SDavid Howells 
2218a1ab315SDavid Howells #endif /* _ASM_GENERIC_FCNTL_H */
222