]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/bits/fcntl-linux.h
1 /* O_*, F_*, FD_* bit values for Linux.
2 Copyright (C) 2001-2013 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
20 # error "Never use <bits/fcntl-linux.h> directly; include <fcntl.h> instead."
23 /* This file contains shared definitions between Linux architectures
24 and is included by <bits/fcntl.h> to declare them. The various
25 #ifndef cases allow the architecture specific file to define those
26 values with different values.
28 A minimal <bits/fcntl.h> contains just:
31 #ifdef __USE_LARGEFILE64
34 #include <bits/fcntl-linux.h>
38 # include <bits/uio.h>
42 #define O_ACCMODE 0003
47 # define O_CREAT 0100 /* Not fcntl. */
50 # define O_EXCL 0200 /* Not fcntl. */
53 # define O_NOCTTY 0400 /* Not fcntl. */
56 # define O_TRUNC 01000 /* Not fcntl. */
59 # define O_APPEND 02000
62 # define O_NONBLOCK 04000
65 # define O_NDELAY O_NONBLOCK
68 # define O_SYNC 04010000
70 #define O_FSYNC O_SYNC
72 # define O_ASYNC 020000
75 # define __O_LARGEFILE 0100000
79 # define __O_DIRECTORY 0200000
82 # define __O_NOFOLLOW 0400000
85 # define __O_CLOEXEC 02000000
88 # define __O_DIRECT 040000
91 # define __O_NOATIME 01000000
94 # define __O_PATH 010000000
97 # define __O_DSYNC 010000
101 # ifndef __USE_FILE_OFFSET64
102 # define F_GETLK 5 /* Get record locking info. */
103 # define F_SETLK 6 /* Set record locking info (non-blocking). */
104 # define F_SETLKW 7 /* Set record locking info (blocking). */
106 # define F_GETLK F_GETLK64 /* Get record locking info. */
107 # define F_SETLK F_SETLK64 /* Set record locking info (non-blocking).*/
108 # define F_SETLKW F_SETLKW64 /* Set record locking info (blocking). */
112 # define F_GETLK64 12 /* Get record locking info. */
113 # define F_SETLK64 13 /* Set record locking info (non-blocking). */
114 # define F_SETLKW64 14 /* Set record locking info (blocking). */
117 #ifdef __USE_LARGEFILE64
118 # define O_LARGEFILE __O_LARGEFILE
121 #ifdef __USE_XOPEN2K8
122 # define O_DIRECTORY __O_DIRECTORY /* Must be a directory. */
123 # define O_NOFOLLOW __O_NOFOLLOW /* Do not follow links. */
124 # define O_CLOEXEC __O_CLOEXEC /* Set close_on_exec. */
128 # define O_DIRECT __O_DIRECT /* Direct disk access. */
129 # define O_NOATIME __O_NOATIME /* Do not set atime. */
130 # define O_PATH __O_PATH /* Resolve pathname but do not open file. */
133 /* For now, Linux has no separate synchronicitiy options for read
134 operations. We define O_RSYNC therefore as the same as O_SYNC
135 since this is a superset. */
136 #if defined __USE_POSIX199309 || defined __USE_UNIX98
137 # define O_DSYNC __O_DSYNC /* Synchronize data. */
138 # if defined __O_RSYNC
139 # define O_RSYNC __O_RSYNC /* Synchronize read operations. */
141 # define O_RSYNC O_SYNC /* Synchronize read operations. */
145 /* Values for the second argument to `fcntl'. */
146 #define F_DUPFD 0 /* Duplicate file descriptor. */
147 #define F_GETFD 1 /* Get file descriptor flags. */
148 #define F_SETFD 2 /* Set file descriptor flags. */
149 #define F_GETFL 3 /* Get file status flags. */
150 #define F_SETFL 4 /* Set file status flags. */
153 # define __F_SETOWN 8
154 # define __F_GETOWN 9
157 #if defined __USE_BSD || defined __USE_UNIX98 || defined __USE_XOPEN2K8
158 # define F_SETOWN __F_SETOWN /* Get owner (process receiving SIGIO). */
159 # define F_GETOWN __F_GETOWN /* Set owner (process receiving SIGIO). */
163 # define __F_SETSIG 10 /* Set number of signal to be sent. */
164 # define __F_GETSIG 11 /* Get number of signal to be sent. */
166 #ifndef __F_SETOWN_EX
167 # define __F_SETOWN_EX 15 /* Get owner (thread receiving SIGIO). */
168 # define __F_GETOWN_EX 16 /* Set owner (thread receiving SIGIO). */
172 # define F_SETSIG __F_SETSIG /* Set number of signal to be sent. */
173 # define F_GETSIG __F_GETSIG /* Get number of signal to be sent. */
174 # define F_SETOWN_EX __F_SETOWN_EX /* Get owner (thread receiving SIGIO). */
175 # define F_GETOWN_EX __F_GETOWN_EX /* Set owner (thread receiving SIGIO). */
179 # define F_SETLEASE 1024 /* Set a lease. */
180 # define F_GETLEASE 1025 /* Enquire what lease is active. */
181 # define F_NOTIFY 1026 /* Request notifications on a directory. */
182 # define F_SETPIPE_SZ 1031 /* Set pipe page size array. */
183 # define F_GETPIPE_SZ 1032 /* Set pipe page size array. */
185 #ifdef __USE_XOPEN2K8
186 # define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
187 close-on-exit set. */
190 /* For F_[GET|SET]FD. */
191 #define FD_CLOEXEC 1 /* Actually anything with low bit set goes */
194 /* For posix fcntl() and `l_type' field of a `struct flock' for lockf(). */
195 # define F_RDLCK 0 /* Read lock. */
196 # define F_WRLCK 1 /* Write lock. */
197 # define F_UNLCK 2 /* Remove lock. */
201 /* For old implementation of BSD flock. */
203 # define F_EXLCK 4 /* or 3 */
204 # define F_SHLCK 8 /* or 4 */
208 /* Operations for BSD flock, also used by the kernel implementation. */
209 # define LOCK_SH 1 /* Shared lock. */
210 # define LOCK_EX 2 /* Exclusive lock. */
211 # define LOCK_NB 4 /* Or'd with one of the above to prevent
213 # define LOCK_UN 8 /* Remove lock. */
217 # define LOCK_MAND 32 /* This is a mandatory flock: */
218 # define LOCK_READ 64 /* ... which allows concurrent read operations. */
219 # define LOCK_WRITE 128 /* ... which allows concurrent write operations. */
220 # define LOCK_RW 192 /* ... Which allows concurrent read & write operations. */
224 /* Types of directory notifications that may be requested with F_NOTIFY. */
225 # define DN_ACCESS 0x00000001 /* File accessed. */
226 # define DN_MODIFY 0x00000002 /* File modified. */
227 # define DN_CREATE 0x00000004 /* File created. */
228 # define DN_DELETE 0x00000008 /* File removed. */
229 # define DN_RENAME 0x00000010 /* File renamed. */
230 # define DN_ATTRIB 0x00000020 /* File changed attributes. */
231 # define DN_MULTISHOT 0x80000000 /* Don't remove notifier. */
239 F_OWNER_TID
= 0, /* Kernel thread. */
240 F_OWNER_PID
, /* Process. */
241 F_OWNER_PGRP
, /* Process group. */
242 F_OWNER_GID
= F_OWNER_PGRP
/* Alternative, obsolete name. */
245 /* Structure to use with F_GETOWN_EX and F_SETOWN_EX. */
248 enum __pid_type type
; /* Owner type of ID. */
249 __pid_t pid
; /* ID of owner. */
253 /* Define some more compatibility macros to be backward compatible with
254 BSD systems which did not managed to hide these kernel macros. */
256 # define FAPPEND O_APPEND
257 # define FFSYNC O_FSYNC
258 # define FASYNC O_ASYNC
259 # define FNONBLOCK O_NONBLOCK
260 # define FNDELAY O_NDELAY
261 #endif /* Use BSD. */
263 #ifndef __POSIX_FADV_DONTNEED
264 # define __POSIX_FADV_DONTNEED 4
265 # define __POSIX_FADV_NOREUSE 5
267 /* Advise to `posix_fadvise'. */
269 # define POSIX_FADV_NORMAL 0 /* No further special treatment. */
270 # define POSIX_FADV_RANDOM 1 /* Expect random page references. */
271 # define POSIX_FADV_SEQUENTIAL 2 /* Expect sequential page references. */
272 # define POSIX_FADV_WILLNEED 3 /* Will need these pages. */
273 # define POSIX_FADV_DONTNEED __POSIX_FADV_DONTNEED /* Don't need these pages. */
274 # define POSIX_FADV_NOREUSE __POSIX_FADV_NOREUSE /* Data will be accessed once. */
279 /* Flags for SYNC_FILE_RANGE. */
280 # define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
281 in the range before performing the
283 # define SYNC_FILE_RANGE_WRITE 2 /* Initiate writeout of all those
284 dirty pages in the range which are
285 not presently under writeback. */
286 # define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
287 the range after performing the
290 /* Flags for SPLICE and VMSPLICE. */
291 # define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
292 # define SPLICE_F_NONBLOCK 2 /* Don't block on the pipe splicing
293 (but we may still block on the fd
294 we splice from/to). */
295 # define SPLICE_F_MORE 4 /* Expect more data. */
296 # define SPLICE_F_GIFT 8 /* Pages passed in are a gift. */
299 /* File handle structure. */
302 unsigned int handle_bytes
;
304 /* File identifier. */
305 unsigned char f_handle
[0];
308 /* Maximum handle size (for now). */
309 # define MAX_HANDLE_SZ 128
316 /* Provide kernel hint to read ahead. */
317 extern ssize_t
readahead (int __fd
, __off64_t __offset
, size_t __count
)
321 /* Selective file content synch'ing.
323 This function is a possible cancellation point and therefore not
324 marked with __THROW. */
325 extern int sync_file_range (int __fd
, __off64_t __offset
, __off64_t __count
,
326 unsigned int __flags
);
329 /* Splice address range into a pipe.
331 This function is a possible cancellation point and therefore not
332 marked with __THROW. */
333 extern ssize_t
vmsplice (int __fdout
, const struct iovec
*__iov
,
334 size_t __count
, unsigned int __flags
);
336 /* Splice two files together.
338 This function is a possible cancellation point and therefore not
339 marked with __THROW. */
340 extern ssize_t
splice (int __fdin
, __off64_t
*__offin
, int __fdout
,
341 __off64_t
*__offout
, size_t __len
,
342 unsigned int __flags
);
344 /* In-kernel implementation of tee for pipe buffers.
346 This function is a possible cancellation point and therefore not
347 marked with __THROW. */
348 extern ssize_t
tee (int __fdin
, int __fdout
, size_t __len
,
349 unsigned int __flags
);
351 /* Reserve storage for the data of the file associated with FD.
353 This function is a possible cancellation point and therefore not
354 marked with __THROW. */
355 # ifndef __USE_FILE_OFFSET64
356 extern int fallocate (int __fd
, int __mode
, __off_t __offset
, __off_t __len
);
359 extern int __REDIRECT (fallocate
, (int __fd
, int __mode
, __off64_t __offset
,
363 # define fallocate fallocate64
366 # ifdef __USE_LARGEFILE64
367 extern int fallocate64 (int __fd
, int __mode
, __off64_t __offset
,
372 /* Map file name to file handle. */
373 extern int name_to_handle_at (int __dfd
, const char *__name
,
374 struct file_handle
*__handle
, int *__mnt_id
,
375 int __flags
) __THROW
;
377 /* Open file using the file handle.
379 This function is a possible cancellation point and therefore not
380 marked with __THROW. */
381 extern int open_by_handle_at (int __mountdirfd
, struct file_handle
*__handle
,