9103 opengroup acknowledgement should be properly formatted in man pages
[unleashed.git] / usr / src / man / man3head / fcntl.h.3head
blobfa75967763514fb42cdb5f46d1d46cb1df64db0a
1 .\"
2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document.  The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright 1989 AT&T
44 .\" Copyright (c) 2008, Sun Microsystems, Inc.  All Rights Reserved.
45 .\"
46 .TH FCNTL.H 3HEAD "April 9, 2016"
47 .SH NAME
48 fcntl.h, fcntl \- file control options
49 .SH SYNOPSIS
50 .LP
51 .nf
52 #include <fcntl.h>
53 .fi
55 .SH DESCRIPTION
56 .LP
57 The \fB<fcntl.h>\fR header defines the following requests and arguments for use
58 by the functions \fBfcntl\fR(2), \fBopen\fR(2), and \fBopenat\fR(2).
59 .sp
60 .LP
61 Values for \fIcmd\fR used by \fBfcntl()\fR (the following values are unique):
62 .sp
63 .ne 2
64 .na
65 \fB\fBF_DUPFD\fR\fR
66 .ad
67 .RS 15n
68 Duplicate file descriptor.
69 .RE
71 .sp
72 .ne 2
73 .na
74 \fB\fBF_DUP2FD\fR\fR
75 .ad
76 .RS 15n
77 Similar to \fBF_DUPFD\fR, but always returns \fIarg\fR.
78 .RE
80 .sp
81 .ne 2
82 .na
83 \fB\fBF_GETFD\fR\fR
84 .ad
85 .RS 15n
86 Get file descriptor flags.
87 .RE
89 .sp
90 .ne 2
91 .na
92 \fB\fBF_SETFD\fR\fR
93 .ad
94 .RS 15n
95 Set file descriptor flags.
96 .RE
98 .sp
99 .ne 2
101 \fB\fBF_GETFL\fR\fR
103 .RS 15n
104 Get file status flags.
108 .ne 2
110 \fB\fBF_SETFL\fR\fR
112 .RS 15n
113 Set file status flags.
117 .ne 2
119 \fB\fBF_GETOWN\fR\fR
121 .RS 15n
122 Get process or process group \fBID\fR to receive \fBSIGURG\fR signals.
126 .ne 2
128 \fB\fBF_SETOWN\fR\fR
130 .RS 15n
131 Set process or process group \fBID\fR to receive \fBSIGURG\fR signals.
135 .ne 2
137 \fB\fBF_FREESP\fR\fR
139 .RS 15n
140 Free storage space associated with a section of the ordinary file \fIfildes\fR.
144 .ne 2
146 \fB\fBF_ALLOCSP\fR\fR
148 .RS 15n
149 Allocate space for a section of the ordinary file \fIfildes\fR.
153 .ne 2
155 \fB\fBF_ALLOCSP64\fR\fR
157 .RS 15n
158 Equivalent to \fBF_ALLOCSP\fR, but takes a \fBstruct flock64\fR argument rather
159 than a \fBstruct flock\fR argument.
163 .ne 2
165 \fB\fBF_GETLK\fR\fR
167 .RS 15n
168 Get record locking information.
172 .ne 2
174 \fB\fBF_GETLK64\fR\fR
176 .RS 15n
177 Equivalent to \fBF_GETLK\fR, but takes a \fBstruct flock64\fR argument rather
178 than a \fBstruct flock\fR argument.
182 .ne 2
184 \fB\fBF_SETLK\fR\fR
186 .RS 15n
187 Set record locking information.
191 .ne 2
193 \fB\fBF_SETLK64\fR\fR
195 .RS 15n
196 Equivalent to \fBF_SETLK\fR, but takes a \fBstruct flock64\fR argument rather
197 than a \fBstruct flock\fR argument.
201 .ne 2
203 \fB\fBF_SETLKW\fR\fR
205 .RS 15n
206 Set record locking information; wait if blocked.
210 .ne 2
212 \fB\fBF_SETLKW64\fR\fR
214 .RS 15n
215 Equivalent to \fBF_SETLKW\fR, but takes a \fBstruct flock64\fR argument rather
216 than a \fBstruct flock\fR argument.
220 .ne 2
222 \fB\fBF_SHARE\fR\fR
224 .RS 15n
225 Set share reservation.
229 .ne 2
231 \fB\fBF_UNSHARE\fR\fR
233 .RS 15n
234 Remove share reservation.
239 File descriptor flags used for \fBfcntl()\fR:
241 .ne 2
243 \fB\fBFD_CLOEXEC\fR\fR
245 .RS 14n
246 Close the file descriptor upon execution of an \fBexec\fR function (see
247 \fBexec\fR(2)).
252 Values for \fBl_type\fR used for record locking with \fBfcntl()\fR (the
253 following values are unique):
255 .ne 2
257 \fB\fBF_RDLCK\fR\fR
259 .RS 11n
260 Shared or read lock.
264 .ne 2
266 \fB\fBF_UNLCK\fR\fR
268 .RS 11n
269 Unlock.
273 .ne 2
275 \fB\fBF_WRLCK\fR\fR
277 .RS 11n
278 Exclusive or write lock.
283 Values for \fBf_access\fR used for share reservations with \fBfcntl()\fR (the
284 following values are unique):
286 .ne 2
288 \fB\fBF_RDACC\fR\fR
290 .RS 11n
291 Read-only share reservation.
295 .ne 2
297 \fB\fBF_WRACC\fR\fR
299 .RS 11n
300 Write-only share reservation.
304 .ne 2
306 \fB\fBF_RWACC\fR\fR
308 .RS 11n
309 Read and write share reservation.
314 Values for \fBf_deny\fR used for share reservations with \fBfcntl()\fR (the
315 following values are unique):
317 .ne 2
319 \fB\fBF_COMPAT\fR\fR
321 .RS 12n
322 Compatibility mode share reservation.
326 .ne 2
328 \fB\fBF_RDDNY\fR\fR
330 .RS 12n
331 Deny other read access share reservations.
335 .ne 2
337 \fB\fBF_WRDNY\fR\fR
339 .RS 12n
340 Deny other write access share reservations.
344 .ne 2
346 \fB\fBF_RWDNY\fR\fR
348 .RS 12n
349 Deny other read or write access share reservations.
353 .ne 2
355 \fB\fBF_NODNY\fR\fR
357 .RS 12n
358 Do not deny other read or write access share reservations.
363 File creation and assignment flags are used in the \fIoflag\fR argument by
364 \fBopen()\fR and \fBopenat()\fR. All of these values are bitwise distinct:
366 .ne 2
368 \fB\fBO_CREAT\fR\fR
370 .RS 12n
371 Create file if it does not exist.
375 .ne 2
377 \fB\fBO_EXCL\fR\fR
379 .RS 12n
380 Exclusive use flag.
384 .ne 2
386 \fB\fBO_NOCTTY\fR\fR
388 .RS 12n
389 Do not assign controlling tty.
393 .ne 2
395 \fB\fBO_TRUNC\fR\fR
397 .RS 12n
398 Truncate flag.
402 .ne 2
404 \fB\fBO_XATTR\fR\fR
406 .RS 12n
407 When opening a file, this flag affects the way in which relative paths are
408 resolved by \fBopen()\fR and \fBopenat()\fR.  With this flag set, the
409 \fIpath\fR argument is resolved as an extended attribute reference on either
410 the current working directory (if open) or of the file referenced by the file
411 descriptor argument of \fBopenat()\fR.
416 File status flags used for \fBfcntl()\fR, \fBopen()\fR, and \fBopen()\fR:
418 .ne 2
420 \fB\fBO_APPEND\fR\fR
422 .RS 14n
423 Set append mode.
427 .ne 2
429 \fB\fBO_NDELAY\fR\fR
431 .RS 14n
432 Non-blocking mode.
436 .ne 2
438 \fB\fBO_NONBLOCK\fR\fR
440 .RS 14n
441 Non-blocking mode (POSIX; see \fBstandards\fR(5)).
445 .ne 2
447 \fB\fBO_DSYNC\fR\fR
449 .RS 14n
450 Write I/O operations on the file descriptor complete as defined by synchronized
451 I/O data integrity completion.
455 .ne 2
457 \fB\fBO_RSYNC\fR\fR
459 .RS 14n
460 Read I/O operations on the file descriptor complete at the same level of
461 integrity as specified by the \fBO_DSYNC\fR and  \fBO_SYNC\fR flags. If both
462 \fBO_DSYNC\fR and \fBO_RSYNC\fR are set in \fIoflag\fR, all I/O operations on
463 the file descriptor complete as defined by synchronized I/O data integrity
464 completion.  If both  \fBO_SYNC\fR and \fBO_RSYNC\fR are set in \fIoflag\fR,
465 all I/O operations on the file descriptor complete as defined by synchronized
466 I/O file integrity completion.
470 .ne 2
472 \fB\fBO_SYNC\fR\fR
474 .RS 14n
475 When opening a regular file, this flag affects subsequent writes. If set, each
476 \fBwrite\fR(2) will wait for both the file data and file status to be
477 physically updated.  Write I/O operations on the file descriptor complete as
478 defined by synchronized I/O file integrity completion.
483 Mask for use with file access modes:
485 .ne 2
487 \fB\fBO_ACCMODE\fR\fR
489 .RS 13n
490 Mask for file access modes.
495 File access modes used for \fBfcntl()\fR, \fBopen()\fR, and \fBopenat()\fR:
497 .ne 2
499 \fB\fBO_RDONLY\fR\fR
501 .RS 12n
502 Open for reading only.
506 .ne 2
508 \fB\fBO_RDWR\fR\fR
510 .RS 12n
511 Open for reading and writing.
515 .ne 2
517 \fB\fBO_WRONLY\fR\fR
519 .RS 12n
520 Open for writing only.
525 The following constants are used by system calls capable of resolving paths
526 relative to a provided open file descriptor:
528 .ne 2
530 \fB\fBAT_FDCWD\fR\fR
532 .RS 23n
533 Special value to pass in place of a file descriptor to inform the called
534 routine that relative path arguments should be resolved from the current
535 working directory.
539 .ne 2
541 \fB\fBAT_SYMLINK_NOFOLLOW\fR\fR
543 .RS 23n
544 Flag passed to \fBfstatat\fR(2) and \fBfchownat\fR(2) to change the behavior of
545 these functions when they are given a file as an argument that is a symbolic
546 link. In this case the functions operate on the symbolic link file rather than
547 the file the link references.
551 .ne 2
553 \fB\fBAT_REMOVEDIR\fR\fR
555 .RS 23n
556 Flag passed to \fBunlinkat\fR(2) to tell it to assume that its path argument
557 refers to a directory and to attempt to remove this directory.
562 The \fBflock\fR structure describes a file lock. It includes the following
563 members:
565 .in +2
567 short   l_type;   /* Type of lock */
568 short   l_whence; /* Flag for starting offset */
569 off_t   l_start;  /* Relative offset in bytes */
570 off_t   l_len;    /* Size; if 0 then until EOF */
571 long    l_sysid;  /* Returned with F_GETLK */
572 pid_t   l_pid;    /* Returned with F_GETLK */
574 .in -2
578 The structure \fBfshare\fR describes a file share reservation. It includes the
579 following members:
581 .in +2
583 short   f_access; /* Type of reservation */
584 short   f_deny;   /* Type of reservations to deny */
585 long    f_id;     /* Process unique identifier */
587 .in -2
589 .SH ATTRIBUTES
591 See \fBattributes\fR(5) for descriptions of the following attributes:
596 box;
597 c | c
598 l | l .
599 ATTRIBUTE TYPE  ATTRIBUTE VALUE
601 Interface Stability     Committed
603 Standard        See \fBstandards\fR(5).
606 .SH SEE ALSO
608 \fBcreat\fR(2), \fBexec\fR(2), \fBfcntl\fR(2), \fBopen\fR(2),
609 \fBfdatasync\fR(3C), \fBfsync\fR(3C), \fBfsattr\fR(5), \fBattributes\fR(5),
610 \fBstandards\fR(5)
611 .SH NOTES
613 Data is successfully  transferred for a write operation to a regular file when
614 the system ensures that all data written is readable on any subsequent open of
615 the file (even one that follows a system or power failure) in the absence of a
616 failure of the physical storage medium.
619 Data is successfully transferred for a read operation when an image of the data
620 on the physical storage medium is available to the requesting process.
623 Synchronized I/O data integrity completion (see \fBfdatasync\fR(3C)):
624 .RS +4
626 .ie t \(bu
627 .el o
628 For reads, the operation has been completed or diagnosed if unsuccessful. The
629 read is complete only when an image of the data has been successfully
630 transferred to the requesting process. If there were any pending write requests
631 affecting the data to be read at the time that the synchronized read operation
632 was requested, these write requests will be successfully transferred prior to
633 reading the data.
635 .RS +4
637 .ie t \(bu
638 .el o
639 For writes, the operation has been completed or diagnosed if unsuccessful. The
640 write is complete only when the data specified in the write request is
641 successfully transferred, and all file system information required to retrieve
642 the data is successfully transferred.
646 File attributes that are not necessary for data retrieval (access time,
647 modification time, status change time) need not be successfully  transferred
648 prior to returning to the calling process.
651 Synchronized I/O file integrity completion (see \fBfsync\fR(3C)):
652 .RS +4
654 .ie t \(bu
655 .el o
656 Identical to a synchronized I/O data integrity completion with the addition
657 that all file attributes relative to the I/O operation (including access time,
658 modification time, status change time) will be successfully transferred prior
659 to returning to the calling process.