summaryrefslogtreecommitdiff
path: root/usr/src/man/man3head/fcntl.h.3head
blob: 3e272db601143809286e586413bb8d966b8616a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
.\"
.\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
.\" permission to reproduce portions of its copyrighted documentation.
.\" Original documentation from The Open Group can be obtained online at
.\" http://www.opengroup.org/bookstore/.
.\"
.\" The Institute of Electrical and Electronics Engineers and The Open
.\" Group, have given us permission to reprint portions of their
.\" documentation.
.\"
.\" In the following statement, the phrase ``this text'' refers to portions
.\" of the system documentation.
.\"
.\" Portions of this text are reprinted and reproduced in electronic form
.\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
.\" Standard for Information Technology -- Portable Operating System
.\" Interface (POSIX), The Open Group Base Specifications Issue 6,
.\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
.\" Engineers, Inc and The Open Group.  In the event of any discrepancy
.\" between these versions and the original IEEE and The Open Group
.\" Standard, the original IEEE and The Open Group Standard is the referee
.\" document.  The original Standard can be obtained online at
.\" http://www.opengroup.org/unix/online.html.
.\"
.\" This notice shall appear on any product containing this material.
.\"
.\" The contents of this file are subject to the terms of the
.\" Common Development and Distribution License (the "License").
.\" You may not use this file except in compliance with the License.
.\"
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
.\" or http://www.opensolaris.org/os/licensing.
.\" See the License for the specific language governing permissions
.\" and limitations under the License.
.\"
.\" When distributing Covered Code, include this CDDL HEADER in each
.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
.\" If applicable, add the following below this CDDL HEADER, with the
.\" fields enclosed by brackets "[]" replaced with your own identifying
.\" information: Portions Copyright [yyyy] [name of copyright owner]
.\"
.\"
.\" Copyright 1989 AT&T
.\" Copyright (c) 2008, Sun Microsystems, Inc.  All Rights Reserved.
.\"
.TH FCNTL.H 3HEAD "January 20, 2020"
.SH NAME
fcntl.h, fcntl \- file control options
.SH SYNOPSIS
.LP
.nf
#include <fcntl.h>
.fi

.SH DESCRIPTION
.LP
The \fB<fcntl.h>\fR header defines the following requests and arguments for use
by the functions \fBfcntl\fR(2), \fBopen\fR(2), and \fBopenat\fR(2).
.sp
.LP
Values for \fIcmd\fR used by \fBfcntl()\fR (the following values are unique):
.sp
.ne 2
.na
\fB\fBF_DUPFD\fR\fR
.ad
.RS 15n
Duplicate file descriptor.
.RE

.sp
.ne 2
.na
\fB\fBF_DUP2FD\fR\fR
.ad
.RS 15n
Similar to \fBF_DUPFD\fR, but always returns \fIarg\fR.
.RE

.sp
.ne 2
.na
\fB\fBF_GETFD\fR\fR
.ad
.RS 15n
Get file descriptor flags.
.RE

.sp
.ne 2
.na
\fB\fBF_SETFD\fR\fR
.ad
.RS 15n
Set file descriptor flags.
.RE

.sp
.ne 2
.na
\fB\fBF_GETFL\fR\fR
.ad
.RS 15n
Get file status flags.
.RE

.sp
.ne 2
.na
\fB\fBF_SETFL\fR\fR
.ad
.RS 15n
Set file status flags.
.RE

.sp
.ne 2
.na
\fB\fBF_GETOWN\fR\fR
.ad
.RS 15n
Get process or process group \fBID\fR to receive \fBSIGURG\fR signals.
.RE

.sp
.ne 2
.na
\fB\fBF_SETOWN\fR\fR
.ad
.RS 15n
Set process or process group \fBID\fR to receive \fBSIGURG\fR signals.
.RE

.sp
.ne 2
.na
\fB\fBF_FREESP\fR\fR
.ad
.RS 15n
Free storage space associated with a section of the ordinary file \fIfildes\fR.
.RE

.sp
.ne 2
.na
\fB\fBF_ALLOCSP\fR\fR
.ad
.RS 15n
Allocate space for a section of the ordinary file \fIfildes\fR.
.RE

.sp
.ne 2
.na
\fB\fBF_ALLOCSP64\fR\fR
.ad
.RS 15n
Equivalent to \fBF_ALLOCSP\fR, but takes a \fBstruct flock64\fR argument rather
than a \fBstruct flock\fR argument.
.RE

.sp
.ne 2
.na
\fB\fBF_GETLK\fR\fR
.ad
.RS 15n
Get record locking information.
.RE

.sp
.ne 2
.na
\fB\fBF_GETLK64\fR\fR
.ad
.RS 15n
Equivalent to \fBF_GETLK\fR, but takes a \fBstruct flock64\fR argument rather
than a \fBstruct flock\fR argument.
.RE

.sp
.ne 2
.na
\fB\fBF_SETLK\fR\fR
.ad
.RS 15n
Set record locking information.
.RE

.sp
.ne 2
.na
\fB\fBF_SETLK64\fR\fR
.ad
.RS 15n
Equivalent to \fBF_SETLK\fR, but takes a \fBstruct flock64\fR argument rather
than a \fBstruct flock\fR argument.
.RE

.sp
.ne 2
.na
\fB\fBF_SETLKW\fR\fR
.ad
.RS 15n
Set record locking information; wait if blocked.
.RE

.sp
.ne 2
.na
\fB\fBF_SETLKW64\fR\fR
.ad
.RS 15n
Equivalent to \fBF_SETLKW\fR, but takes a \fBstruct flock64\fR argument rather
than a \fBstruct flock\fR argument.
.RE

.sp
.ne 2
.na
\fB\fBF_SHARE\fR\fR
.ad
.RS 15n
Set share reservation.
.RE

.sp
.ne 2
.na
\fB\fBF_UNSHARE\fR\fR
.ad
.RS 15n
Remove share reservation.
.RE

.sp
.LP
File descriptor flags used for \fBfcntl()\fR:
.sp
.ne 2
.na
\fB\fBFD_CLOEXEC\fR\fR
.ad
.RS 14n
Close the file descriptor upon execution of an \fBexec\fR function (see
\fBexec\fR(2)).
.RE

.sp
.LP
Values for \fBl_type\fR used for record locking with \fBfcntl()\fR (the
following values are unique):
.sp
.ne 2
.na
\fB\fBF_RDLCK\fR\fR
.ad
.RS 11n
Shared or read lock.
.RE

.sp
.ne 2
.na
\fB\fBF_UNLCK\fR\fR
.ad
.RS 11n
Unlock.
.RE

.sp
.ne 2
.na
\fB\fBF_WRLCK\fR\fR
.ad
.RS 11n
Exclusive or write lock.
.RE

.sp
.LP
Values for \fBf_access\fR used for share reservations with \fBfcntl()\fR (the
following values are unique):
.sp
.ne 2
.na
\fB\fBF_RDACC\fR\fR
.ad
.RS 11n
Read-only share reservation.
.RE

.sp
.ne 2
.na
\fB\fBF_WRACC\fR\fR
.ad
.RS 11n
Write-only share reservation.
.RE

.sp
.ne 2
.na
\fB\fBF_RWACC\fR\fR
.ad
.RS 11n
Read and write share reservation.
.RE

.sp
.LP
Values for \fBf_deny\fR used for share reservations with \fBfcntl()\fR (the
following values are unique):
.sp
.ne 2
.na
\fB\fBF_COMPAT\fR\fR
.ad
.RS 12n
Compatibility mode share reservation.
.RE

.sp
.ne 2
.na
\fB\fBF_RDDNY\fR\fR
.ad
.RS 12n
Deny other read access share reservations.
.RE

.sp
.ne 2
.na
\fB\fBF_WRDNY\fR\fR
.ad
.RS 12n
Deny other write access share reservations.
.RE

.sp
.ne 2
.na
\fB\fBF_RWDNY\fR\fR
.ad
.RS 12n
Deny other read or write access share reservations.
.RE

.sp
.ne 2
.na
\fB\fBF_NODNY\fR\fR
.ad
.RS 12n
Do not deny other read or write access share reservations.
.RE

.sp
.LP
File creation and assignment flags are used in the \fIoflag\fR argument by
\fBopen()\fR and \fBopenat()\fR. All of these values are bitwise distinct:
.sp
.ne 2
.na
\fB\fBO_CREAT\fR\fR
.ad
.RS 12n
Create file if it does not exist.
.RE

.sp
.ne 2
.na
.B O_DIRECTORY
.ad
.RS 12n
Fail unless the path is a directory.
.RE

.sp
.ne 2
.na
\fB\fBO_EXCL\fR\fR
.ad
.RS 12n
Exclusive use flag.
.RE

.sp
.ne 2
.na
\fB\fBO_NOCTTY\fR\fR
.ad
.RS 12n
Do not assign controlling tty.
.RE

.sp
.ne 2
.na
\fB\fBO_TRUNC\fR\fR
.ad
.RS 12n
Truncate flag.
.RE

.sp
.ne 2
.na
\fB\fBO_XATTR\fR\fR
.ad
.RS 12n
When opening a file, this flag affects the way in which relative paths are
resolved by \fBopen()\fR and \fBopenat()\fR.  With this flag set, the
\fIpath\fR argument is resolved as an extended attribute reference on either
the current working directory (if open) or of the file referenced by the file
descriptor argument of \fBopenat()\fR.
.RE

.sp
.LP
File status flags used for \fBfcntl()\fR, \fBopen()\fR, and \fBopen()\fR:
.sp
.ne 2
.na
\fB\fBO_APPEND\fR\fR
.ad
.RS 14n
Set append mode.
.RE

.sp
.ne 2
.na
.B O_CLOEXEC
.ad
.RS 12n
The file should be closed on any calls to \fBexec\fR(2).
.RE

.sp
.ne 2
.na
\fB\fBO_NDELAY\fR\fR
.ad
.RS 14n
Non-blocking mode.
.RE

.sp
.ne 2
.na
\fB\fBO_NONBLOCK\fR\fR
.ad
.RS 14n
Non-blocking mode (POSIX; see \fBstandards\fR(5)).
.RE

.sp
.ne 2
.na
\fB\fBO_DSYNC\fR\fR
.ad
.RS 14n
Write I/O operations on the file descriptor complete as defined by synchronized
I/O data integrity completion.
.RE

.sp
.ne 2
.na
\fB\fBO_RSYNC\fR\fR
.ad
.RS 14n
Read I/O operations on the file descriptor complete at the same level of
integrity as specified by the \fBO_DSYNC\fR and  \fBO_SYNC\fR flags. If both
\fBO_DSYNC\fR and \fBO_RSYNC\fR are set in \fIoflag\fR, all I/O operations on
the file descriptor complete as defined by synchronized I/O data integrity
completion.  If both  \fBO_SYNC\fR and \fBO_RSYNC\fR are set in \fIoflag\fR,
all I/O operations on the file descriptor complete as defined by synchronized
I/O file integrity completion.
.RE

.sp
.ne 2
.na
\fB\fBO_SYNC\fR\fR
.ad
.RS 14n
When opening a regular file, this flag affects subsequent writes. If set, each
\fBwrite\fR(2) will wait for both the file data and file status to be
physically updated.  Write I/O operations on the file descriptor complete as
defined by synchronized I/O file integrity completion.
.RE

.sp
.LP
Mask for use with file access modes:
.sp
.ne 2
.na
\fB\fBO_ACCMODE\fR\fR
.ad
.RS 13n
Mask for file access modes.
.RE

.sp
.LP
File access modes used for \fBfcntl()\fR, \fBopen()\fR, and \fBopenat()\fR:
.sp
.ne 2
.na
\fB\fBO_RDONLY\fR\fR
.ad
.RS 12n
Open for reading only.
.RE

.sp
.ne 2
.na
\fB\fBO_RDWR\fR\fR
.ad
.RS 12n
Open for reading and writing.
.RE

.sp
.ne 2
.na
\fB\fBO_WRONLY\fR\fR
.ad
.RS 12n
Open for writing only.
.RE

.sp
.LP
The following constants are used by system calls capable of resolving paths
relative to a provided open file descriptor:
.sp
.ne 2
.na
\fB\fBAT_FDCWD\fR\fR
.ad
.RS 23n
Special value to pass in place of a file descriptor to inform the called
routine that relative path arguments should be resolved from the current
working directory.
.RE

.sp
.ne 2
.na
\fB\fBAT_SYMLINK_NOFOLLOW\fR\fR
.ad
.RS 23n
Flag passed to \fBfstatat\fR(2) and \fBfchownat\fR(2) to change the behavior of
these functions when they are given a file as an argument that is a symbolic
link. In this case the functions operate on the symbolic link file rather than
the file the link references.
.RE

.sp
.ne 2
.na
\fB\fBAT_REMOVEDIR\fR\fR
.ad
.RS 23n
Flag passed to \fBunlinkat\fR(2) to tell it to assume that its path argument
refers to a directory and to attempt to remove this directory.
.RE

.sp
.LP
The \fBflock\fR structure describes a file lock. It includes the following
members:
.sp
.in +2
.nf
short   l_type;   /* Type of lock */
short   l_whence; /* Flag for starting offset */
off_t   l_start;  /* Relative offset in bytes */
off_t   l_len;    /* Size; if 0 then until EOF */
long    l_sysid;  /* Returned with F_GETLK */
pid_t   l_pid;    /* Returned with F_GETLK */
.fi
.in -2

.sp
.LP
The structure \fBfshare\fR describes a file share reservation. It includes the
following members:
.sp
.in +2
.nf
short   f_access; /* Type of reservation */
short   f_deny;   /* Type of reservations to deny */
long    f_id;     /* Process unique identifier */
.fi
.in -2

.SH ATTRIBUTES
.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface Stability	Committed
_
Standard	See \fBstandards\fR(5).
.TE

.SH SEE ALSO
.LP
\fBcreat\fR(2), \fBexec\fR(2), \fBfcntl\fR(2), \fBopen\fR(2),
\fBfdatasync\fR(3C), \fBfsync\fR(3C), \fBfsattr\fR(5), \fBattributes\fR(5),
\fBstandards\fR(5)
.SH NOTES
.LP
Data is successfully  transferred for a write operation to a regular file when
the system ensures that all data written is readable on any subsequent open of
the file (even one that follows a system or power failure) in the absence of a
failure of the physical storage medium.
.sp
.LP
Data is successfully transferred for a read operation when an image of the data
on the physical storage medium is available to the requesting process.
.sp
.LP
Synchronized I/O data integrity completion (see \fBfdatasync\fR(3C)):
.RS +4
.TP
.ie t \(bu
.el o
For reads, the operation has been completed or diagnosed if unsuccessful. The
read is complete only when an image of the data has been successfully
transferred to the requesting process. If there were any pending write requests
affecting the data to be read at the time that the synchronized read operation
was requested, these write requests will be successfully transferred prior to
reading the data.
.RE
.RS +4
.TP
.ie t \(bu
.el o
For writes, the operation has been completed or diagnosed if unsuccessful. The
write is complete only when the data specified in the write request is
successfully transferred, and all file system information required to retrieve
the data is successfully transferred.
.RE
.sp
.LP
File attributes that are not necessary for data retrieval (access time,
modification time, status change time) need not be successfully  transferred
prior to returning to the calling process.
.sp
.LP
Synchronized I/O file integrity completion (see \fBfsync\fR(3C)):
.RS +4
.TP
.ie t \(bu
.el o
Identical to a synchronized I/O data integrity completion with the addition
that all file attributes relative to the I/O operation (including access time,
modification time, status change time) will be successfully transferred prior
to returning to the calling process.
.RE