1 /* O_*, F_*, FD_* bit values for Linux/SPARC.
2 Copyright (C) 1995, 1996, 1997, 1998, 2000, 2003, 2004, 2006, 2007
3 Free Software Foundation, Inc.
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.h> directly; include <fcntl.h> instead."
23 #include <sys/types.h>
25 # include <bits/uio.h>
28 /* open/fcntl - O_SYNC is only implemented on blocks devices and on files
29 located on an ext2 file system */
30 #define O_RDONLY 0x0000
31 #define O_WRONLY 0x0001
33 #define O_ACCMODE 0x0003
34 #define O_APPEND 0x0008
35 #define O_ASYNC 0x0040
36 #define O_CREAT 0x0200 /* not fcntl */
37 #define O_TRUNC 0x0400 /* not fcntl */
38 #define O_EXCL 0x0800 /* not fcntl */
40 #define O_NONBLOCK 0x4000
41 #define O_NDELAY (0x0004 | O_NONBLOCK)
42 #define O_NOCTTY 0x8000 /* not fcntl */
45 # define O_DIRECTORY 0x10000 /* must be a directory */
46 # define O_NOFOLLOW 0x20000 /* don't follow links */
47 # define O_CLOEXEC 0x400000 /* Set close_on_exit. */
51 # define O_DIRECT 0x100000 /* direct disk access hint */
52 # define O_NOATIME 0x200000 /* Do not set atime. */
53 # define O_PATH 0x1000000 /* Resolve pathname but do not open file. */
56 #ifdef __USE_LARGEFILE64
57 # define O_LARGEFILE 0x40000
60 /* For now Linux has no synchronisity options for data and read
61 operations. We define the symbols here but let them do the same as
62 O_SYNC since this is a superset. */
63 #if defined __USE_POSIX199309 || defined __USE_UNIX98
64 # define O_DSYNC O_SYNC /* Synchronize data. */
65 # define O_RSYNC O_SYNC /* Synchronize read operations. */
68 /* For now Linux has synchronisity options for data and read operations.
69 We define the symbols here but let them do the same as O_SYNC since
70 this is a superset. */
71 #if defined __USE_POSIX199309 || defined __USE_UNIX98
72 # define O_DSYNC O_SYNC /* Synchronize data. */
73 # define O_RSYNC O_SYNC /* Synchronize read operations. */
76 /* Values for the second argument to `fcntl'. */
77 #define F_DUPFD 0 /* Duplicate file descriptor. */
78 #define F_GETFD 1 /* Get file descriptor flags. */
79 #define F_SETFD 2 /* Set file descriptor flags. */
80 #define F_GETFL 3 /* Get file status flags. */
81 #define F_SETFL 4 /* Set file status flags. */
82 #if defined __USE_BSD || defined __USE_UNIX98
83 # define F_GETOWN 5 /* Get owner of socket (receiver of SIGIO). */
84 # define F_SETOWN 6 /* Set owner of socket (receiver of SIGIO). */
86 #ifndef __USE_FILE_OFFSET64
87 # define F_GETLK 7 /* Get record locking info. */
88 # define F_SETLK 8 /* Set record locking info (non-blocking). */
89 # define F_SETLKW 9 /* Set record locking info (blocking). */
91 # define F_GETLK F_GETLK64 /* Get record locking info. */
92 # define F_SETLK F_SETLK64 /* Set record locking info (non-blocking).*/
93 # define F_SETLKW F_SETLKW64 /* Set record locking info (blocking). */
97 # define F_SETSIG 10 /* Set number of signal to be sent. */
98 # define F_GETSIG 11 /* Get number of signal to be sent. */
102 # define F_SETLEASE 1024 /* Set a lease. */
103 # define F_GETLEASE 1025 /* Enquire what lease is active. */
104 # define F_NOTIFY 1026 /* Request notfications on a directory. */
105 # define F_DUPFD_CLOEXEC 1030 /* Duplicate file descriptor with
106 close-on-exit set on new fd. */
107 # define F_SETPIPE_SZ 1031 /* Set pipe page size array. */
108 # define F_GETPIPE_SZ 1032 /* Get pipe page size array. */
111 #define F_GETLK64 12 /* Get record locking info. */
112 #define F_SETLK64 13 /* Set record locking info (non-blocking). */
113 #define F_SETLKW64 14 /* Set record locking info (blocking). */
115 /* for F_[GET|SET]FD */
116 #define FD_CLOEXEC 1 /* actually anything with low bit set goes */
118 /* For posix fcntl() and `l_type' field of a `struct flock' for lockf(). */
119 #define F_RDLCK 1 /* Read lock. */
120 #define F_WRLCK 2 /* Write lock. */
121 #define F_UNLCK 3 /* Remove lock. */
123 /* for old implementation of bsd flock () */
124 #define F_EXLCK 4 /* or 3 */
125 #define F_SHLCK 8 /* or 4 */
128 /* Operations for bsd flock(), also used by the kernel implementation */
129 # define LOCK_SH 1 /* shared lock */
130 # define LOCK_EX 2 /* exclusive lock */
131 # define LOCK_NB 4 /* or'd with one of the above to prevent
133 # define LOCK_UN 8 /* remove lock */
137 # define LOCK_MAND 32 /* This is a mandatory flock: */
138 # define LOCK_READ 64 /* ... which allows concurrent read operations. */
139 # define LOCK_WRITE 128 /* ... which allows concurrent write operations. */
140 # define LOCK_RW 192 /* ... Which allows concurrent read & write operations. */
144 /* Types of directory notifications that may be requested with F_NOTIFY. */
145 # define DN_ACCESS 0x00000001 /* File accessed. */
146 # define DN_MODIFY 0x00000002 /* File modified. */
147 # define DN_CREATE 0x00000004 /* File created. */
148 # define DN_DELETE 0x00000008 /* File removed. */
149 # define DN_RENAME 0x00000010 /* File renamed. */
150 # define DN_ATTRIB 0x00000020 /* File changed attibutes. */
151 # define DN_MULTISHOT 0x80000000 /* Don't remove notifier. */
156 short int l_type
; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
157 short int l_whence
; /* Where `l_start' is relative to (like `lseek'). */
158 #ifndef __USE_FILE_OFFSET64
159 __off_t l_start
; /* Offset where the lock begins. */
160 __off_t l_len
; /* Size of the locked area; zero means until EOF. */
162 __off64_t l_start
; /* Offset where the lock begins. */
163 __off64_t l_len
; /* Size of the locked area; zero means until EOF. */
165 __pid_t l_pid
; /* Process holding the lock. */
166 short int __uclibc_unused
;
169 #ifdef __USE_LARGEFILE64
172 short int l_type
; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
173 short int l_whence
; /* Where `l_start' is relative to (like `lseek'). */
174 __off64_t l_start
; /* Offset where the lock begins. */
175 __off64_t l_len
; /* Size of the locked area; zero means until EOF. */
176 __pid_t l_pid
; /* Process holding the lock. */
177 short int __uclibc_unused
;
181 /* Define some more compatibility macros to be backward compatible with
182 BSD systems which did not managed to hide these kernel macros. */
184 # define FAPPEND O_APPEND
185 # define FFSYNC O_FSYNC
186 # define FASYNC O_ASYNC
187 # define FNONBLOCK O_NONBLOCK
188 # define FNDELAY O_NDELAY
189 #endif /* Use BSD. */
191 /* Advise to `posix_fadvise'. */
193 # define POSIX_FADV_NORMAL 0 /* No further special treatment. */
194 # define POSIX_FADV_RANDOM 1 /* Expect random page references. */
195 # define POSIX_FADV_SEQUENTIAL 2 /* Expect sequential page references. */
196 # define POSIX_FADV_WILLNEED 3 /* Will need these pages. */
197 # define POSIX_FADV_DONTNEED 4 /* Don't need these pages. */
198 # define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */
202 #if defined __USE_GNU && defined __UCLIBC_LINUX_SPECIFIC__
203 /* Flags for SYNC_FILE_RANGE. */
204 # define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
205 in the range before performing the
207 # define SYNC_FILE_RANGE_WRITE 2 /* Initiate writeout of all those
208 dirty pages in the range which are
209 not presently under writeback. */
210 # define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
211 the range after performing the
214 /* Flags for SPLICE and VMSPLICE. */
215 # define SPLICE_F_MOVE 1 /* Move pages instead of copying. */
216 # define SPLICE_F_NONBLOCK 2 /* Don't block on the pipe splicing
217 (but we may still block on the fd
218 we splice from/to). */
219 # define SPLICE_F_MORE 4 /* Expect more data. */
220 # define SPLICE_F_GIFT 8 /* Pages passed in are a gift. */
225 #if defined __USE_GNU && defined __UCLIBC_LINUX_SPECIFIC__
227 /* Provide kernel hint to read ahead. */
228 extern ssize_t
readahead (int __fd
, __off64_t __offset
, size_t __count
)
232 /* Selective file content synch'ing. */
233 extern int sync_file_range (int __fd
, __off64_t __from
, __off64_t __to
,
234 unsigned int __flags
);
236 /* Splice address range into a pipe. */
237 extern ssize_t
vmsplice (int __fdout
, const struct iovec
*__iov
,
238 size_t __count
, unsigned int __flags
);
240 /* Splice two files together. */
241 extern ssize_t
splice (int __fdin
, __off64_t
*__offin
, int __fdout
,
242 __off64_t
*__offout
, size_t __len
,
243 unsigned int __flags
);
245 /* In-kernel implementation of tee for pipe buffers. */
246 extern ssize_t
tee (int __fdin
, int __fdout
, size_t __len
,
247 unsigned int __flags
);