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