xref: /openbmc/linux/include/uapi/asm-generic/fcntl.h (revision 60545d0d)
18a1ab315SDavid Howells #ifndef _ASM_GENERIC_FCNTL_H
28a1ab315SDavid Howells #define _ASM_GENERIC_FCNTL_H
38a1ab315SDavid Howells 
48a1ab315SDavid Howells #include <linux/types.h>
58a1ab315SDavid Howells 
68a1ab315SDavid Howells /*
78a1ab315SDavid Howells  * FMODE_EXEC is 0x20
88a1ab315SDavid Howells  * FMODE_NONOTIFY is 0x1000000
98a1ab315SDavid Howells  * These cannot be used by userspace O_* until internal and external open
108a1ab315SDavid Howells  * flags are split.
118a1ab315SDavid Howells  * -Eric Paris
128a1ab315SDavid Howells  */
138a1ab315SDavid Howells 
148a1ab315SDavid Howells /*
158a1ab315SDavid Howells  * When introducing new O_* bits, please check its uniqueness in fcntl_init().
168a1ab315SDavid Howells  */
178a1ab315SDavid Howells 
188a1ab315SDavid Howells #define O_ACCMODE	00000003
198a1ab315SDavid Howells #define O_RDONLY	00000000
208a1ab315SDavid Howells #define O_WRONLY	00000001
218a1ab315SDavid Howells #define O_RDWR		00000002
228a1ab315SDavid Howells #ifndef O_CREAT
238a1ab315SDavid Howells #define O_CREAT		00000100	/* not fcntl */
248a1ab315SDavid Howells #endif
258a1ab315SDavid Howells #ifndef O_EXCL
268a1ab315SDavid Howells #define O_EXCL		00000200	/* not fcntl */
278a1ab315SDavid Howells #endif
288a1ab315SDavid Howells #ifndef O_NOCTTY
298a1ab315SDavid Howells #define O_NOCTTY	00000400	/* not fcntl */
308a1ab315SDavid Howells #endif
318a1ab315SDavid Howells #ifndef O_TRUNC
328a1ab315SDavid Howells #define O_TRUNC		00001000	/* not fcntl */
338a1ab315SDavid Howells #endif
348a1ab315SDavid Howells #ifndef O_APPEND
358a1ab315SDavid Howells #define O_APPEND	00002000
368a1ab315SDavid Howells #endif
378a1ab315SDavid Howells #ifndef O_NONBLOCK
388a1ab315SDavid Howells #define O_NONBLOCK	00004000
398a1ab315SDavid Howells #endif
408a1ab315SDavid Howells #ifndef O_DSYNC
418a1ab315SDavid Howells #define O_DSYNC		00010000	/* used to be O_SYNC, see below */
428a1ab315SDavid Howells #endif
438a1ab315SDavid Howells #ifndef FASYNC
448a1ab315SDavid Howells #define FASYNC		00020000	/* fcntl, for BSD compatibility */
458a1ab315SDavid Howells #endif
468a1ab315SDavid Howells #ifndef O_DIRECT
478a1ab315SDavid Howells #define O_DIRECT	00040000	/* direct disk access hint */
488a1ab315SDavid Howells #endif
498a1ab315SDavid Howells #ifndef O_LARGEFILE
508a1ab315SDavid Howells #define O_LARGEFILE	00100000
518a1ab315SDavid Howells #endif
528a1ab315SDavid Howells #ifndef O_DIRECTORY
538a1ab315SDavid Howells #define O_DIRECTORY	00200000	/* must be a directory */
548a1ab315SDavid Howells #endif
558a1ab315SDavid Howells #ifndef O_NOFOLLOW
568a1ab315SDavid Howells #define O_NOFOLLOW	00400000	/* don't follow links */
578a1ab315SDavid Howells #endif
588a1ab315SDavid Howells #ifndef O_NOATIME
598a1ab315SDavid Howells #define O_NOATIME	01000000
608a1ab315SDavid Howells #endif
618a1ab315SDavid Howells #ifndef O_CLOEXEC
628a1ab315SDavid Howells #define O_CLOEXEC	02000000	/* set close_on_exec */
638a1ab315SDavid Howells #endif
648a1ab315SDavid Howells 
658a1ab315SDavid Howells /*
668a1ab315SDavid Howells  * Before Linux 2.6.33 only O_DSYNC semantics were implemented, but using
678a1ab315SDavid Howells  * the O_SYNC flag.  We continue to use the existing numerical value
688a1ab315SDavid Howells  * for O_DSYNC semantics now, but using the correct symbolic name for it.
698a1ab315SDavid Howells  * This new value is used to request true Posix O_SYNC semantics.  It is
708a1ab315SDavid Howells  * defined in this strange way to make sure applications compiled against
718a1ab315SDavid Howells  * new headers get at least O_DSYNC semantics on older kernels.
728a1ab315SDavid Howells  *
738a1ab315SDavid Howells  * This has the nice side-effect that we can simply test for O_DSYNC
748a1ab315SDavid Howells  * wherever we do not care if O_DSYNC or O_SYNC is used.
758a1ab315SDavid Howells  *
768a1ab315SDavid Howells  * Note: __O_SYNC must never be used directly.
778a1ab315SDavid Howells  */
788a1ab315SDavid Howells #ifndef O_SYNC
798a1ab315SDavid Howells #define __O_SYNC	04000000
808a1ab315SDavid Howells #define O_SYNC		(__O_SYNC|O_DSYNC)
818a1ab315SDavid Howells #endif
828a1ab315SDavid Howells 
838a1ab315SDavid Howells #ifndef O_PATH
848a1ab315SDavid Howells #define O_PATH		010000000
858a1ab315SDavid Howells #endif
868a1ab315SDavid Howells 
8760545d0dSAl Viro #ifndef O_TMPFILE
8860545d0dSAl Viro #define O_TMPFILE	020000000
8960545d0dSAl Viro #endif
9060545d0dSAl Viro 
918a1ab315SDavid Howells #ifndef O_NDELAY
928a1ab315SDavid Howells #define O_NDELAY	O_NONBLOCK
938a1ab315SDavid Howells #endif
948a1ab315SDavid Howells 
958a1ab315SDavid Howells #define F_DUPFD		0	/* dup */
968a1ab315SDavid Howells #define F_GETFD		1	/* get close_on_exec */
978a1ab315SDavid Howells #define F_SETFD		2	/* set/clear close_on_exec */
988a1ab315SDavid Howells #define F_GETFL		3	/* get file->f_flags */
998a1ab315SDavid Howells #define F_SETFL		4	/* set file->f_flags */
1008a1ab315SDavid Howells #ifndef F_GETLK
1018a1ab315SDavid Howells #define F_GETLK		5
1028a1ab315SDavid Howells #define F_SETLK		6
1038a1ab315SDavid Howells #define F_SETLKW	7
1048a1ab315SDavid Howells #endif
1058a1ab315SDavid Howells #ifndef F_SETOWN
1068a1ab315SDavid Howells #define F_SETOWN	8	/* for sockets. */
1078a1ab315SDavid Howells #define F_GETOWN	9	/* for sockets. */
1088a1ab315SDavid Howells #endif
1098a1ab315SDavid Howells #ifndef F_SETSIG
1108a1ab315SDavid Howells #define F_SETSIG	10	/* for sockets. */
1118a1ab315SDavid Howells #define F_GETSIG	11	/* for sockets. */
1128a1ab315SDavid Howells #endif
1138a1ab315SDavid Howells 
1148a1ab315SDavid Howells #ifndef CONFIG_64BIT
1158a1ab315SDavid Howells #ifndef F_GETLK64
1168a1ab315SDavid Howells #define F_GETLK64	12	/*  using 'struct flock64' */
1178a1ab315SDavid Howells #define F_SETLK64	13
1188a1ab315SDavid Howells #define F_SETLKW64	14
1198a1ab315SDavid Howells #endif
1208a1ab315SDavid Howells #endif
1218a1ab315SDavid Howells 
1228a1ab315SDavid Howells #ifndef F_SETOWN_EX
1238a1ab315SDavid Howells #define F_SETOWN_EX	15
1248a1ab315SDavid Howells #define F_GETOWN_EX	16
1258a1ab315SDavid Howells #endif
1268a1ab315SDavid Howells 
1278a1ab315SDavid Howells #ifndef F_GETOWNER_UIDS
1288a1ab315SDavid Howells #define F_GETOWNER_UIDS	17
1298a1ab315SDavid Howells #endif
1308a1ab315SDavid Howells 
1318a1ab315SDavid Howells #define F_OWNER_TID	0
1328a1ab315SDavid Howells #define F_OWNER_PID	1
1338a1ab315SDavid Howells #define F_OWNER_PGRP	2
1348a1ab315SDavid Howells 
1358a1ab315SDavid Howells struct f_owner_ex {
1368a1ab315SDavid Howells 	int	type;
1378a1ab315SDavid Howells 	__kernel_pid_t	pid;
1388a1ab315SDavid Howells };
1398a1ab315SDavid Howells 
1408a1ab315SDavid Howells /* for F_[GET|SET]FL */
1418a1ab315SDavid Howells #define FD_CLOEXEC	1	/* actually anything with low bit set goes */
1428a1ab315SDavid Howells 
1438a1ab315SDavid Howells /* for posix fcntl() and lockf() */
1448a1ab315SDavid Howells #ifndef F_RDLCK
1458a1ab315SDavid Howells #define F_RDLCK		0
1468a1ab315SDavid Howells #define F_WRLCK		1
1478a1ab315SDavid Howells #define F_UNLCK		2
1488a1ab315SDavid Howells #endif
1498a1ab315SDavid Howells 
1508a1ab315SDavid Howells /* for old implementation of bsd flock () */
1518a1ab315SDavid Howells #ifndef F_EXLCK
1528a1ab315SDavid Howells #define F_EXLCK		4	/* or 3 */
1538a1ab315SDavid Howells #define F_SHLCK		8	/* or 4 */
1548a1ab315SDavid Howells #endif
1558a1ab315SDavid Howells 
1568a1ab315SDavid Howells /* operations for bsd flock(), also used by the kernel implementation */
1578a1ab315SDavid Howells #define LOCK_SH		1	/* shared lock */
1588a1ab315SDavid Howells #define LOCK_EX		2	/* exclusive lock */
1598a1ab315SDavid Howells #define LOCK_NB		4	/* or'd with one of the above to prevent
1608a1ab315SDavid Howells 				   blocking */
1618a1ab315SDavid Howells #define LOCK_UN		8	/* remove lock */
1628a1ab315SDavid Howells 
1638a1ab315SDavid Howells #define LOCK_MAND	32	/* This is a mandatory flock ... */
1648a1ab315SDavid Howells #define LOCK_READ	64	/* which allows concurrent read operations */
1658a1ab315SDavid Howells #define LOCK_WRITE	128	/* which allows concurrent write operations */
1668a1ab315SDavid Howells #define LOCK_RW		192	/* which allows concurrent read & write ops */
1678a1ab315SDavid Howells 
1688a1ab315SDavid Howells #define F_LINUX_SPECIFIC_BASE	1024
1698a1ab315SDavid Howells 
1708a1ab315SDavid Howells #ifndef HAVE_ARCH_STRUCT_FLOCK
1718a1ab315SDavid Howells #ifndef __ARCH_FLOCK_PAD
1728a1ab315SDavid Howells #define __ARCH_FLOCK_PAD
1738a1ab315SDavid Howells #endif
1748a1ab315SDavid Howells 
1758a1ab315SDavid Howells struct flock {
1768a1ab315SDavid Howells 	short	l_type;
1778a1ab315SDavid Howells 	short	l_whence;
1788a1ab315SDavid Howells 	__kernel_off_t	l_start;
1798a1ab315SDavid Howells 	__kernel_off_t	l_len;
1808a1ab315SDavid Howells 	__kernel_pid_t	l_pid;
1818a1ab315SDavid Howells 	__ARCH_FLOCK_PAD
1828a1ab315SDavid Howells };
1838a1ab315SDavid Howells #endif
1848a1ab315SDavid Howells 
1858a1ab315SDavid Howells #ifndef CONFIG_64BIT
1868a1ab315SDavid Howells 
1878a1ab315SDavid Howells #ifndef HAVE_ARCH_STRUCT_FLOCK64
1888a1ab315SDavid Howells #ifndef __ARCH_FLOCK64_PAD
1898a1ab315SDavid Howells #define __ARCH_FLOCK64_PAD
1908a1ab315SDavid Howells #endif
1918a1ab315SDavid Howells 
1928a1ab315SDavid Howells struct flock64 {
1938a1ab315SDavid Howells 	short  l_type;
1948a1ab315SDavid Howells 	short  l_whence;
1958a1ab315SDavid Howells 	__kernel_loff_t l_start;
1968a1ab315SDavid Howells 	__kernel_loff_t l_len;
1978a1ab315SDavid Howells 	__kernel_pid_t  l_pid;
1988a1ab315SDavid Howells 	__ARCH_FLOCK64_PAD
1998a1ab315SDavid Howells };
2008a1ab315SDavid Howells #endif
2018a1ab315SDavid Howells #endif /* !CONFIG_64BIT */
2028a1ab315SDavid Howells 
2038a1ab315SDavid Howells #endif /* _ASM_GENERIC_FCNTL_H */
204