1fcntl.h(3HEAD) Headers fcntl.h(3HEAD)
2
3
4
6 fcntl.h, fcntl - file control options
7
9 #include <fcntl.h>
10
11
13 The <fcntl.h> header defines the following requests and arguments for
14 use by the functions fcntl(2), open(2), and openat(2).
15
16
17 Values for cmd used by fcntl() (the following values are unique):
18
19 F_DUPFD Duplicate file descriptor.
20
21
22 F_DUP2FD Similar to F_DUPFD, but always returns arg.
23
24
25 F_GETFD Get file descriptor flags.
26
27
28 F_SETFD Set file descriptor flags.
29
30
31 F_GETFL Get file status flags.
32
33
34 F_SETFL Set file status flags.
35
36
37 F_GETOWN Get process or process group ID to receive SIGURG sig‐
38 nals.
39
40
41 F_SETOWN Set process or process group ID to receive SIGURG sig‐
42 nals.
43
44
45 F_FREESP Free storage space associated with a section of the
46 ordinary file fildes.
47
48
49 F_ALLOCSP Allocate space for a section of the ordinary file
50 fildes.
51
52
53 F_ALLOCSP64 Equivalent to F_ALLOCSP, but takes a struct flock64
54 argument rather than a struct flock argument.
55
56
57 F_GETLK Get record locking information.
58
59
60 F_GETLK64 Equivalent to F_GETLK, but takes a struct flock64 argu‐
61 ment rather than a struct flock argument.
62
63
64 F_SETLK Set record locking information.
65
66
67 F_SETLK64 Equivalent to F_SETLK, but takes a struct flock64 argu‐
68 ment rather than a struct flock argument.
69
70
71 F_SETLKW Set record locking information; wait if blocked.
72
73
74 F_SETLKW64 Equivalent to F_SETLKW, but takes a struct flock64 argu‐
75 ment rather than a struct flock argument.
76
77
78 F_SHARE Set share reservation.
79
80
81 F_UNSHARE Remove share reservation.
82
83
84
85 File descriptor flags used for fcntl():
86
87 FD_CLOEXEC Close the file descriptor upon execution of an exec func‐
88 tion (see exec(2)).
89
90
91
92 Values for l_type used for record locking with fcntl() (the following
93 values are unique):
94
95 F_RDLCK Shared or read lock.
96
97
98 F_UNLCK Unlock.
99
100
101 F_WRLCK Exclusive or write lock.
102
103
104
105 Values for f_access used for share reservations with fcntl() (the fol‐
106 lowing values are unique):
107
108 F_RDACC Read-only share reservation.
109
110
111 F_WRACC Write-only share reservation.
112
113
114 F_RWACC Read and write share reservation.
115
116
117
118 Values for f_deny used for share reservations with fcntl() (the follow‐
119 ing values are unique):
120
121 F_COMPAT Compatibility mode share reservation.
122
123
124 F_RDDNY Deny other read access share reservations.
125
126
127 F_WRDNY Deny other write access share reservations.
128
129
130 F_RWDNY Deny other read or write access share reservations.
131
132
133 F_NODNY Do not deny other read or write access share reservations.
134
135
136
137 File creation and assignment flags are used in the oflag argument by
138 open() and openat(). All of these values are bitwise distinct:
139
140 O_CREAT Create file if it does not exist.
141
142
143 O_EXCL Exclusive use flag.
144
145
146 O_NOCTTY Do not assign controlling tty.
147
148
149 O_TRUNC Truncate flag.
150
151
152 O_XATTR When opening a file, this flag affects the way in which
153 relative paths are resolved by open() and openat(). With
154 this flag set, the path argument is resolved as an extended
155 attribute reference on either the current working directory
156 (if open) or of the file referenced by the file descriptor
157 argument of openat().
158
159
160
161 File status flags used for fcntl(), open(), and open():
162
163 O_APPEND Set append mode.
164
165
166 O_NDELAY Non-blocking mode.
167
168
169 O_NONBLOCK Non-blocking mode (POSIX; see standards(5)).
170
171
172 O_DSYNC Write I/O operations on the file descriptor complete as
173 defined by synchronized I/O data integrity completion.
174
175
176 O_RSYNC Read I/O operations on the file descriptor complete at
177 the same level of integrity as specified by the O_DSYNC
178 and O_SYNC flags. If both O_DSYNC and O_RSYNC are set
179 in oflag, all I/O operations on the file descriptor com‐
180 plete as defined by synchronized I/O data integrity com‐
181 pletion. If both O_SYNC and O_RSYNC are set in oflag,
182 all I/O operations on the file descriptor complete as
183 defined by synchronized I/O file integrity completion.
184
185
186 O_SYNC When opening a regular file, this flag affects subsequent
187 writes. If set, each write(2) will wait for both the file
188 data and file status to be physically updated. Write I/O
189 operations on the file descriptor complete as defined by
190 synchronized I/O file integrity completion.
191
192
193
194 Mask for use with file access modes:
195
196 O_ACCMODE Mask for file access modes.
197
198
199
200 File access modes used for fcntl(), open(), and openat():
201
202 O_RDONLY Open for reading only.
203
204
205 O_RDWR Open for reading and writing.
206
207
208 O_WRONLY Open for writing only.
209
210
211
212 The following constants are used by system calls capable of resolving
213 paths relative to a provided open file descriptor:
214
215 AT_FDCWD Special value to pass in place of a file
216 descriptor to inform the called routine that
217 relative path arguments should be resolved from
218 the current working directory.
219
220
221 AT_SYMLINK_NOFOLLOW Flag passed to fstatat(2) and fchownat(2) to
222 change the bahavior of these functions when they
223 are given a file as an argument that is a sym‐
224 bolic link. In this case the functions operate
225 on the symbolic link file rather than the file
226 the link references.
227
228
229 AT_REMOVEDIR Flag passed to unlinkat(2) to tell it to assume
230 that its path argument refers to a directory and
231 to attempt to remove this directory.
232
233
234
235 The flock structure describes a file lock. It includes the following
236 members:
237
238 short l_type; /* Type of lock */
239 short l_whence; /* Flag for starting offset */
240 off_t l_start; /* Relative offset in bytes */
241 off_t l_len; /* Size; if 0 then until EOF */
242 long l_sysid; /* Returned with F_GETLK */
243 pid_t l_pid; /* Returned with F_GETLK */
244
245
246
247 The structure fshare describes a file share reservation. It includes
248 the following members:
249
250 short f_access; /* Type of reservation */
251 short f_deny; /* Type of reservations to deny */
252 long f_id; /* Process unique identifier */
253
254
256 See attributes(5) for descriptions of the following attributes:
257
258
259
260
261 ┌─────────────────────────────┬─────────────────────────────┐
262 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
263 ├─────────────────────────────┼─────────────────────────────┤
264 │Interface Stability │Committed │
265 ├─────────────────────────────┼─────────────────────────────┤
266 │Standard │See standards(5). │
267 └─────────────────────────────┴─────────────────────────────┘
268
270 creat(2), exec(2), fcntl(2), open(2), fdatasync(3C), fsync(3C),
271 fsattr(5), attributes(5), standards(5)
272
274 Data is successfully transferred for a write operation to a regular
275 file when the system ensures that all data written is readable on any
276 subsequent open of the file (even one that follows a system or power
277 failure) in the absence of a failure of the physical storage medium.
278
279
280 Data is successfully transferred for a read operation when an image of
281 the data on the physical storage medium is available to the requesting
282 process.
283
284
285 Synchronized I/O data integrity completion (see fdatasync(3C)):
286
287 o For reads, the operation has been completed or diagnosed if
288 unsuccessful. The read is complete only when an image of the
289 data has been successfully transferred to the requesting
290 process. If there were any pending write requests affecting
291 the data to be read at the time that the synchronized read
292 operation was requested, these write requests will be suc‐
293 cessfully transferred prior to reading the data.
294
295 o For writes, the operation has been completed or diagnosed if
296 unsuccessful. The write is complete only when the data spec‐
297 ified in the write request is successfully transferred, and
298 all file system information required to retrieve the data is
299 successfully transferred.
300
301
302 File attributes that are not necessary for data retrieval (access time,
303 modification time, status change time) need not be successfully trans‐
304 ferred prior to returning to the calling process.
305
306
307 Synchronized I/O file integrity completion (see fsync(3C)):
308
309 o Identical to a synchronized I/O data integrity completion
310 with the addition that all file attributes relative to the
311 I/O operation (including access time, modification time,
312 status change time) will be successfully transferred prior
313 to returning to the calling process.
314
315
316
317SunOS 5.11 5 Feb 2008 fcntl.h(3HEAD)