Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 #ifndef _ASM_GENERIC_FCNTL_H
0003 #define _ASM_GENERIC_FCNTL_H
0004 
0005 #include <linux/types.h>
0006 
0007 /*
0008  * FMODE_EXEC is 0x20
0009  * FMODE_NONOTIFY is 0x4000000
0010  * These cannot be used by userspace O_* until internal and external open
0011  * flags are split.
0012  * -Eric Paris
0013  */
0014 
0015 /*
0016  * When introducing new O_* bits, please check its uniqueness in fcntl_init().
0017  */
0018 
0019 #define O_ACCMODE   00000003
0020 #define O_RDONLY    00000000
0021 #define O_WRONLY    00000001
0022 #define O_RDWR      00000002
0023 #ifndef O_CREAT
0024 #define O_CREAT     00000100    /* not fcntl */
0025 #endif
0026 #ifndef O_EXCL
0027 #define O_EXCL      00000200    /* not fcntl */
0028 #endif
0029 #ifndef O_NOCTTY
0030 #define O_NOCTTY    00000400    /* not fcntl */
0031 #endif
0032 #ifndef O_TRUNC
0033 #define O_TRUNC     00001000    /* not fcntl */
0034 #endif
0035 #ifndef O_APPEND
0036 #define O_APPEND    00002000
0037 #endif
0038 #ifndef O_NONBLOCK
0039 #define O_NONBLOCK  00004000
0040 #endif
0041 #ifndef O_DSYNC
0042 #define O_DSYNC     00010000    /* used to be O_SYNC, see below */
0043 #endif
0044 #ifndef FASYNC
0045 #define FASYNC      00020000    /* fcntl, for BSD compatibility */
0046 #endif
0047 #ifndef O_DIRECT
0048 #define O_DIRECT    00040000    /* direct disk access hint */
0049 #endif
0050 #ifndef O_LARGEFILE
0051 #define O_LARGEFILE 00100000
0052 #endif
0053 #ifndef O_DIRECTORY
0054 #define O_DIRECTORY 00200000    /* must be a directory */
0055 #endif
0056 #ifndef O_NOFOLLOW
0057 #define O_NOFOLLOW  00400000    /* don't follow links */
0058 #endif
0059 #ifndef O_NOATIME
0060 #define O_NOATIME   01000000
0061 #endif
0062 #ifndef O_CLOEXEC
0063 #define O_CLOEXEC   02000000    /* set close_on_exec */
0064 #endif
0065 
0066 /*
0067  * Before Linux 2.6.33 only O_DSYNC semantics were implemented, but using
0068  * the O_SYNC flag.  We continue to use the existing numerical value
0069  * for O_DSYNC semantics now, but using the correct symbolic name for it.
0070  * This new value is used to request true Posix O_SYNC semantics.  It is
0071  * defined in this strange way to make sure applications compiled against
0072  * new headers get at least O_DSYNC semantics on older kernels.
0073  *
0074  * This has the nice side-effect that we can simply test for O_DSYNC
0075  * wherever we do not care if O_DSYNC or O_SYNC is used.
0076  *
0077  * Note: __O_SYNC must never be used directly.
0078  */
0079 #ifndef O_SYNC
0080 #define __O_SYNC    04000000
0081 #define O_SYNC      (__O_SYNC|O_DSYNC)
0082 #endif
0083 
0084 #ifndef O_PATH
0085 #define O_PATH      010000000
0086 #endif
0087 
0088 #ifndef __O_TMPFILE
0089 #define __O_TMPFILE 020000000
0090 #endif
0091 
0092 /* a horrid kludge trying to make sure that this will fail on old kernels */
0093 #define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
0094 #define O_TMPFILE_MASK (__O_TMPFILE | O_DIRECTORY | O_CREAT)      
0095 
0096 #ifndef O_NDELAY
0097 #define O_NDELAY    O_NONBLOCK
0098 #endif
0099 
0100 #define F_DUPFD     0   /* dup */
0101 #define F_GETFD     1   /* get close_on_exec */
0102 #define F_SETFD     2   /* set/clear close_on_exec */
0103 #define F_GETFL     3   /* get file->f_flags */
0104 #define F_SETFL     4   /* set file->f_flags */
0105 #ifndef F_GETLK
0106 #define F_GETLK     5
0107 #define F_SETLK     6
0108 #define F_SETLKW    7
0109 #endif
0110 #ifndef F_SETOWN
0111 #define F_SETOWN    8   /* for sockets. */
0112 #define F_GETOWN    9   /* for sockets. */
0113 #endif
0114 #ifndef F_SETSIG
0115 #define F_SETSIG    10  /* for sockets. */
0116 #define F_GETSIG    11  /* for sockets. */
0117 #endif
0118 
0119 #if __BITS_PER_LONG == 32 || defined(__KERNEL__)
0120 #ifndef F_GETLK64
0121 #define F_GETLK64   12  /*  using 'struct flock64' */
0122 #define F_SETLK64   13
0123 #define F_SETLKW64  14
0124 #endif
0125 #endif /* __BITS_PER_LONG == 32 || defined(__KERNEL__) */
0126 
0127 #ifndef F_SETOWN_EX
0128 #define F_SETOWN_EX 15
0129 #define F_GETOWN_EX 16
0130 #endif
0131 
0132 #ifndef F_GETOWNER_UIDS
0133 #define F_GETOWNER_UIDS 17
0134 #endif
0135 
0136 /*
0137  * Open File Description Locks
0138  *
0139  * Usually record locks held by a process are released on *any* close and are
0140  * not inherited across a fork().
0141  *
0142  * These cmd values will set locks that conflict with process-associated
0143  * record  locks, but are "owned" by the open file description, not the
0144  * process. This means that they are inherited across fork() like BSD (flock)
0145  * locks, and they are only released automatically when the last reference to
0146  * the open file against which they were acquired is put.
0147  */
0148 #define F_OFD_GETLK 36
0149 #define F_OFD_SETLK 37
0150 #define F_OFD_SETLKW    38
0151 
0152 #define F_OWNER_TID 0
0153 #define F_OWNER_PID 1
0154 #define F_OWNER_PGRP    2
0155 
0156 struct f_owner_ex {
0157     int type;
0158     __kernel_pid_t  pid;
0159 };
0160 
0161 /* for F_[GET|SET]FL */
0162 #define FD_CLOEXEC  1   /* actually anything with low bit set goes */
0163 
0164 /* for posix fcntl() and lockf() */
0165 #ifndef F_RDLCK
0166 #define F_RDLCK     0
0167 #define F_WRLCK     1
0168 #define F_UNLCK     2
0169 #endif
0170 
0171 /* for old implementation of bsd flock () */
0172 #ifndef F_EXLCK
0173 #define F_EXLCK     4   /* or 3 */
0174 #define F_SHLCK     8   /* or 4 */
0175 #endif
0176 
0177 /* operations for bsd flock(), also used by the kernel implementation */
0178 #define LOCK_SH     1   /* shared lock */
0179 #define LOCK_EX     2   /* exclusive lock */
0180 #define LOCK_NB     4   /* or'd with one of the above to prevent
0181                    blocking */
0182 #define LOCK_UN     8   /* remove lock */
0183 
0184 /*
0185  * LOCK_MAND support has been removed from the kernel. We leave the symbols
0186  * here to not break legacy builds, but these should not be used in new code.
0187  */
0188 #define LOCK_MAND   32  /* This is a mandatory flock ... */
0189 #define LOCK_READ   64  /* which allows concurrent read operations */
0190 #define LOCK_WRITE  128 /* which allows concurrent write operations */
0191 #define LOCK_RW     192 /* which allows concurrent read & write ops */
0192 
0193 #define F_LINUX_SPECIFIC_BASE   1024
0194 
0195 #ifndef HAVE_ARCH_STRUCT_FLOCK
0196 struct flock {
0197     short   l_type;
0198     short   l_whence;
0199     __kernel_off_t  l_start;
0200     __kernel_off_t  l_len;
0201     __kernel_pid_t  l_pid;
0202 #ifdef  __ARCH_FLOCK_EXTRA_SYSID
0203     __ARCH_FLOCK_EXTRA_SYSID
0204 #endif
0205 #ifdef  __ARCH_FLOCK_PAD
0206     __ARCH_FLOCK_PAD
0207 #endif
0208 };
0209 
0210 struct flock64 {
0211     short  l_type;
0212     short  l_whence;
0213     __kernel_loff_t l_start;
0214     __kernel_loff_t l_len;
0215     __kernel_pid_t  l_pid;
0216 #ifdef  __ARCH_FLOCK64_PAD
0217     __ARCH_FLOCK64_PAD
0218 #endif
0219 };
0220 #endif /* HAVE_ARCH_STRUCT_FLOCK */
0221 
0222 #endif /* _ASM_GENERIC_FCNTL_H */