| 1 |
|
| 2 | #ifndef _ASM_GENERIC_FCNTL_H
|
| 3 | #define _ASM_GENERIC_FCNTL_H
|
| 4 |
|
| 5 | #include <linux/types.h>
|
| 6 |
|
| 7 | |
| 8 | * FMODE_EXEC is 0x20
|
| 9 | * These cannot be used by userspace O_* until internal and external open
|
| 10 | * flags are split.
|
| 11 | * -Eric Paris
|
| 12 |
|
| 13 |
|
| 14 | |
| 15 | * When introducing new O_* bits, please check its uniqueness in fcntl_init().
|
| 16 |
|
| 17 |
|
| 18 | #define O_ACCMODE 3
|
| 19 | #define O_RDONLY 0
|
| 20 | #define O_WRONLY (1 << 0)
|
| 21 | #define O_RDWR (1 << 1)
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 | #ifndef O_CREAT
|
| 27 | #define O_CREAT (1 << 6)
|
| 28 | #endif
|
| 29 | #ifndef O_EXCL
|
| 30 | #define O_EXCL (1 << 7)
|
| 31 | #endif
|
| 32 | #ifndef O_NOCTTY
|
| 33 | #define O_NOCTTY (1 << 8)
|
| 34 | #endif
|
| 35 | #ifndef O_TRUNC
|
| 36 | #define O_TRUNC (1 << 9)
|
| 37 | #endif
|
| 38 | #ifndef O_APPEND
|
| 39 | #define O_APPEND (1 << 10)
|
| 40 | #endif
|
| 41 | #ifndef O_NONBLOCK
|
| 42 | #define O_NONBLOCK (1 << 11)
|
| 43 | #endif
|
| 44 | #ifndef O_DSYNC
|
| 45 | #define O_DSYNC (1 << 12)
|
| 46 | #endif
|
| 47 | #ifndef FASYNC
|
| 48 | #define FASYNC (1 << 13)
|
| 49 | #endif
|
| 50 | #ifndef O_DIRECT
|
| 51 | #define O_DIRECT (1 << 14)
|
| 52 | #endif
|
| 53 | #ifndef O_LARGEFILE
|
| 54 | #define O_LARGEFILE (1 << 15)
|
| 55 | #endif
|
| 56 | #ifndef O_DIRECTORY
|
| 57 | #define O_DIRECTORY (1 << 16)
|
| 58 | #endif
|
| 59 | #ifndef O_NOFOLLOW
|
| 60 | #define O_NOFOLLOW (1 << 17)
|
| 61 | #endif
|
| 62 | #ifndef O_NOATIME
|
| 63 | #define O_NOATIME (1 << 18)
|
| 64 | #endif
|
| 65 | #ifndef O_CLOEXEC
|
| 66 | #define O_CLOEXEC (1 << 19)
|
| 67 | #endif
|
| 68 |
|
| 69 | |
| 70 | * Before Linux 2.6.33 only O_DSYNC semantics were implemented, but using
|
| 71 | * the O_SYNC flag. We continue to use the existing numerical value
|
| 72 | * for O_DSYNC semantics now, but using the correct symbolic name for it.
|
| 73 | * This new value is used to request true Posix O_SYNC semantics. It is
|
| 74 | * defined in this strange way to make sure applications compiled against
|
| 75 | * new headers get at least O_DSYNC semantics on older kernels.
|
| 76 | *
|
| 77 | * This has the nice side-effect that we can simply test for O_DSYNC
|
| 78 | * wherever we do not care if O_DSYNC or O_SYNC is used.
|
| 79 | *
|
| 80 | * Note: __O_SYNC must never be used directly.
|
| 81 |
|
| 82 | #ifndef O_SYNC
|
| 83 | #define __O_SYNC (1 << 20)
|
| 84 | #define O_SYNC (__O_SYNC|O_DSYNC)
|
| 85 | #endif
|
| 86 |
|
| 87 | #ifndef O_PATH
|
| 88 | #define O_PATH (1 << 21)
|
| 89 | #endif
|
| 90 |
|
| 91 | #ifndef __O_TMPFILE
|
| 92 | #define __O_TMPFILE (1 << 22)
|
| 93 | #endif
|
| 94 |
|
| 95 | #ifndef O_EMPTYPATH
|
| 96 | #define O_EMPTYPATH (1 << 26)
|
| 97 | #endif
|
| 98 |
|
| 99 |
|
| 100 | #define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
|
| 101 |
|
| 102 | #ifndef O_NDELAY
|
| 103 | #define O_NDELAY O_NONBLOCK
|
| 104 | #endif
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 | #define F_DUPFD 0
|
| 111 | #define F_GETFD 1
|
| 112 | #define F_SETFD 2
|
| 113 | #define F_GETFL 3
|
| 114 | #define F_SETFL 4
|
| 115 | #ifndef F_GETLK
|
| 116 | #define F_GETLK 5
|
| 117 | #define F_SETLK 6
|
| 118 | #define F_SETLKW 7
|
| 119 | #endif
|
| 120 | #ifndef F_SETOWN
|
| 121 | #define F_SETOWN 8
|
| 122 | #define F_GETOWN 9
|
| 123 | #endif
|
| 124 | #ifndef F_SETSIG
|
| 125 | #define F_SETSIG 10
|
| 126 | #define F_GETSIG 11
|
| 127 | #endif
|
| 128 |
|
| 129 | #if __BITS_PER_LONG == 32 || defined(__KERNEL__)
|
| 130 | #ifndef F_GETLK64
|
| 131 | #define F_GETLK64 12
|
| 132 | #define F_SETLK64 13
|
| 133 | #define F_SETLKW64 14
|
| 134 | #endif
|
| 135 | #endif
|
| 136 |
|
| 137 | #ifndef F_SETOWN_EX
|
| 138 | #define F_SETOWN_EX 15
|
| 139 | #define F_GETOWN_EX 16
|
| 140 | #endif
|
| 141 |
|
| 142 | #ifndef F_GETOWNER_UIDS
|
| 143 | #define F_GETOWNER_UIDS 17
|
| 144 | #endif
|
| 145 |
|
| 146 | |
| 147 | * Open File Description Locks
|
| 148 | *
|
| 149 | * Usually record locks held by a process are released on *any* close and are
|
| 150 | * not inherited across a fork().
|
| 151 | *
|
| 152 | * These cmd values will set locks that conflict with process-associated
|
| 153 | * record locks, but are "owned" by the open file description, not the
|
| 154 | * process. This means that they are inherited across fork() like BSD (flock)
|
| 155 | * locks, and they are only released automatically when the last reference to
|
| 156 | * the the open file against which they were acquired is put.
|
| 157 |
|
| 158 | #define F_OFD_GETLK 36
|
| 159 | #define F_OFD_SETLK 37
|
| 160 | #define F_OFD_SETLKW 38
|
| 161 |
|
| 162 | #define F_OWNER_TID 0
|
| 163 | #define F_OWNER_PID 1
|
| 164 | #define F_OWNER_PGRP 2
|
| 165 |
|
| 166 | struct f_owner_ex {
|
| 167 | int type;
|
| 168 | __kernel_pid_t pid;
|
| 169 | };
|
| 170 |
|
| 171 |
|
| 172 | #define FD_CLOEXEC 1
|
| 173 |
|
| 174 |
|
| 175 | #ifndef F_RDLCK
|
| 176 | #define F_RDLCK 0
|
| 177 | #define F_WRLCK 1
|
| 178 | #define F_UNLCK 2
|
| 179 | #endif
|
| 180 |
|
| 181 |
|
| 182 | #ifndef F_EXLCK
|
| 183 | #define F_EXLCK 4
|
| 184 | #define F_SHLCK 8
|
| 185 | #endif
|
| 186 |
|
| 187 |
|
| 188 | #define LOCK_SH 1
|
| 189 | #define LOCK_EX 2
|
| 190 | #define LOCK_NB 4 |
| 191 | blocking
|
| 192 | #define LOCK_UN 8
|
| 193 |
|
| 194 | |
| 195 | * LOCK_MAND support has been removed from the kernel. We leave the symbols
|
| 196 | * here to not break legacy builds, but these should not be used in new code.
|
| 197 |
|
| 198 | #define LOCK_MAND 32
|
| 199 | #define LOCK_READ 64
|
| 200 | #define LOCK_WRITE 128
|
| 201 | #define LOCK_RW 192
|
| 202 |
|
| 203 | #define F_LINUX_SPECIFIC_BASE 1024
|
| 204 |
|
| 205 | #ifndef HAVE_ARCH_STRUCT_FLOCK
|
| 206 | struct flock {
|
| 207 | short l_type;
|
| 208 | short l_whence;
|
| 209 | __kernel_off_t l_start;
|
| 210 | __kernel_off_t l_len;
|
| 211 | __kernel_pid_t l_pid;
|
| 212 | #ifdef __ARCH_FLOCK_EXTRA_SYSID
|
| 213 | __ARCH_FLOCK_EXTRA_SYSID
|
| 214 | #endif
|
| 215 | #ifdef __ARCH_FLOCK_PAD
|
| 216 | __ARCH_FLOCK_PAD
|
| 217 | #endif
|
| 218 | };
|
| 219 |
|
| 220 | struct flock64 {
|
| 221 | short l_type;
|
| 222 | short l_whence;
|
| 223 | __kernel_loff_t l_start;
|
| 224 | __kernel_loff_t l_len;
|
| 225 | __kernel_pid_t l_pid;
|
| 226 | #ifdef __ARCH_FLOCK64_PAD
|
| 227 | __ARCH_FLOCK64_PAD
|
| 228 | #endif
|
| 229 | };
|
| 230 | #endif
|
| 231 |
|
| 232 | #endif
|