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