Replace FSF snail mail address with URLs.
[glibc.git] / sysdeps / mach / hurd / bits / fcntl.h
blob4224bf18ff54670b82cd96c9211b056616b1f9b2
1 /* O_*, F_*, FD_* bit values for GNU.
2 Copyright (C) 1993,1994,1996,1997,1998,1999,2000,2001,2004,2007
3 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef _FCNTL_H
21 # error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
22 #endif
24 #include <sys/types.h>
26 /* File access modes. These are understood by io servers; they can be
27 passed in `dir_lookup', and are returned by `io_get_openmodes'.
28 Consequently they can be passed to `open', `hurd_file_name_lookup', and
29 `file_name_lookup'; and are returned by `fcntl' with the F_GETFL
30 command. */
32 /* In GNU, read and write are bits (unlike BSD). */
33 #ifdef __USE_GNU
34 # define O_READ O_RDONLY /* Open for reading. */
35 # define O_WRITE O_WRONLY /* Open for writing. */
36 # define O_EXEC 0x0004 /* Open for execution. */
37 # define O_NORW 0 /* Open without R/W access. */
38 #endif
39 /* POSIX.1 standard names. */
40 #define O_RDONLY 0x0001 /* Open read-only. */
41 #define O_WRONLY 0x0002 /* Open write-only. */
42 #define O_RDWR (O_RDONLY|O_WRONLY) /* Open for reading and writing. */
43 #define O_ACCMODE O_RDWR /* Mask for file access modes. */
45 #define O_LARGEFILE 0
48 /* File name translation flags. These are understood by io servers;
49 they can be passed in `dir_lookup', and consequently to `open',
50 `hurd_file_name_lookup', and `file_name_lookup'. */
52 #define O_CREAT 0x0010 /* Create file if it doesn't exist. */
53 #define O_EXCL 0x0020 /* Fail if file already exists. */
54 #ifdef __USE_GNU
55 # define O_NOLINK 0x0040 /* No name mappings on final component. */
56 # define O_NOTRANS 0x0080 /* No translator on final component. */
58 # define O_NOFOLLOW 0x00100000 /* Produce ENOENT if file is a symlink. */
59 # define O_DIRECTORY 0x00200000 /* Produce ENOTDIR if not a directory. */
60 #endif
63 /* I/O operating modes. These are understood by io servers; they can be
64 passed in `dir_lookup' and set or fetched with `io_*_openmodes'.
65 Consequently they can be passed to `open', `hurd_file_name_lookup',
66 `file_name_lookup', and `fcntl' with the F_SETFL command; and are
67 returned by `fcntl' with the F_GETFL command. */
69 #define O_APPEND 0x0100 /* Writes always append to the file. */
70 #define O_ASYNC 0x0200 /* Send SIGIO to owner when data is ready. */
71 #define O_FSYNC 0x0400 /* Synchronous writes. */
72 #define O_SYNC O_FSYNC
73 #ifdef __USE_GNU
74 # define O_NOATIME 0x0800 /* Don't set access time on read (owner). */
75 #endif
76 #ifdef __USE_MISC
77 # define O_SHLOCK 0x00020000 /* Open with shared file lock. */
78 # define O_EXLOCK 0x00040000 /* Open with exclusive file lock. */
79 #endif
81 /* These are lesser flavors of partial synchronization that are
82 implied by our one flag (O_FSYNC). */
83 #if defined __USE_POSIX199309 || defined __USE_UNIX98
84 # define O_DSYNC O_SYNC /* Synchronize data. */
85 # define O_RSYNC O_SYNC /* Synchronize read operations. */
86 #endif
89 /* The name O_NONBLOCK is unfortunately overloaded; it is both a file name
90 translation flag and an I/O operating mode. O_NDELAY is the deprecated
91 BSD name for the same flag, overloaded in the same way.
93 When used in `dir_lookup' (and consequently `open', `hurd_file_name_lookup',
94 or `file_name_lookup'), O_NONBLOCK says the open should return immediately
95 instead of blocking for any significant length of time (e.g., to wait
96 for carrier detect on a serial line). It is also saved as an I/O
97 operating mode, and after open has the following meaning.
99 When used in `io_*_openmodes' (and consequently `fcntl' with the F_SETFL
100 command), the O_NONBLOCK flag means to do nonblocking i/o: any i/o
101 operation that would block for any significant length of time will instead
102 fail with EAGAIN. */
104 #define O_NONBLOCK 0x0008 /* Non-blocking open or non-blocking I/O. */
105 #ifdef __USE_BSD
106 # define O_NDELAY O_NONBLOCK /* Deprecated. */
107 #endif
110 #ifdef __USE_GNU
111 /* Mask of bits which are understood by io servers. */
112 # define O_HURD (0xffff | O_EXLOCK | O_SHLOCK)
113 #endif
116 /* Open-time action flags. These are understood by `hurd_file_name_lookup'
117 and consequently by `open' and `file_name_lookup'. They are not preserved
118 once the file has been opened. */
120 #define O_TRUNC 0x00010000 /* Truncate file to zero length. */
121 #ifdef __USE_GNU
122 # define O_CLOEXEC 0x00400000 /* Set FD_CLOEXEC. */
123 #endif
126 /* Controlling terminal flags. These are understood only by `open',
127 and are not preserved once the file has been opened. */
129 #ifdef __USE_GNU
130 # define O_IGNORE_CTTY 0x00080000 /* Don't do any ctty magic at all. */
131 #endif
132 /* `open' never assigns a controlling terminal in GNU. */
133 #define O_NOCTTY 0 /* Don't assign a controlling terminal. */
136 #ifdef __USE_BSD
137 /* Bits in the file status flags returned by F_GETFL. */
138 # define FREAD O_RDONLY
139 # define FWRITE O_WRONLY
141 /* Traditional BSD names the O_* bits. */
142 # define FASYNC O_ASYNC
143 # define FCREAT O_CREAT
144 # define FEXCL O_EXCL
145 # define FTRUNC O_TRUNC
146 # define FNOCTTY O_NOCTTY
147 # define FFSYNC O_FSYNC
148 # define FSYNC O_SYNC
149 # define FAPPEND O_APPEND
150 # define FNONBLOCK O_NONBLOCK
151 # define FNDELAY O_NDELAY
152 #endif
155 /* Values for the second argument to `fcntl'. */
156 #define F_DUPFD 0 /* Duplicate file descriptor. */
157 #define F_GETFD 1 /* Get file descriptor flags. */
158 #define F_SETFD 2 /* Set file descriptor flags. */
159 #define F_GETFL 3 /* Get file status flags. */
160 #define F_SETFL 4 /* Set file status flags. */
161 #if defined __USE_BSD || defined __USE_UNIX98
162 # define F_GETOWN 5 /* Get owner (receiver of SIGIO). */
163 # define F_SETOWN 6 /* Set owner (receiver of SIGIO). */
164 #endif
165 #define F_GETLK 7 /* Get record locking info. */
166 #define F_SETLK 8 /* Set record locking info (non-blocking). */
167 #define F_SETLKW 9 /* Set record locking info (blocking). */
169 #ifdef __USE_GNU
170 # define F_DUPFD_CLOEXEC 1030 /* Duplicate, set FD_CLOEXEC on new one. */
171 #endif
174 /* File descriptor flags used with F_GETFD and F_SETFD. */
175 #define FD_CLOEXEC 1 /* Close on exec. */
178 #include <bits/types.h>
180 /* The structure describing an advisory lock. This is the type of the third
181 argument to `fcntl' for the F_GETLK, F_SETLK, and F_SETLKW requests. */
182 struct flock
184 int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
185 int l_whence; /* Where `l_start' is relative to (like `lseek'). */
186 #ifndef __USE_FILE_OFFSET64
187 __off_t l_start; /* Offset where the lock begins. */
188 __off_t l_len; /* Size of the locked area; zero means until EOF. */
189 #else
190 __off64_t l_start; /* Offset where the lock begins. */
191 __off64_t l_len; /* Size of the locked area; zero means until EOF. */
192 #endif
193 __pid_t l_pid; /* Process holding the lock. */
196 #ifdef __USE_LARGEFILE64
197 struct flock64
199 int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
200 int l_whence; /* Where `l_start' is relative to (like `lseek'). */
201 __off64_t l_start; /* Offset where the lock begins. */
202 __off64_t l_len; /* Size of the locked area; zero means until EOF. */
203 __pid_t l_pid; /* Process holding the lock. */
205 #endif
207 /* Values for the `l_type' field of a `struct flock'. */
208 #define F_RDLCK 1 /* Read lock. */
209 #define F_WRLCK 2 /* Write lock. */
210 #define F_UNLCK 3 /* Remove lock. */
212 /* Advise to `posix_fadvise'. */
213 #ifdef __USE_XOPEN2K
214 # define POSIX_FADV_NORMAL 0 /* No further special treatment. */
215 # define POSIX_FADV_RANDOM 1 /* Expect random page references. */
216 # define POSIX_FADV_SEQUENTIAL 2 /* Expect sequential page references. */
217 # define POSIX_FADV_WILLNEED 3 /* Will need these pages. */
218 # define POSIX_FADV_DONTNEED 4 /* Don't need these pages. */
219 # define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */
220 #endif