2 .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved.
3 .\" Copyright 1989 AT&T
4 .\" 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
5 .\" http://www.opengroup.org/bookstore/.
6 .\" 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 Sun OS 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.
7 .\" This notice shall appear on any product containing this material.
8 .\" 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.
9 .\" 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.
10 .\" 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]
11 .TH FCNTL.H 3HEAD "April 9, 2016"
13 fcntl.h, fcntl \- file control options
22 The \fB<fcntl.h>\fR header defines the following requests and arguments for use
23 by the functions \fBfcntl\fR(2), \fBopen\fR(2), and \fBopenat\fR(2).
26 Values for \fIcmd\fR used by \fBfcntl()\fR (the following values are unique):
33 Duplicate file descriptor.
42 Similar to \fBF_DUPFD\fR, but always returns \fIarg\fR.
51 Get file descriptor flags.
60 Set file descriptor flags.
69 Get file status flags.
78 Set file status flags.
87 Get process or process group \fBID\fR to receive \fBSIGURG\fR signals.
96 Set process or process group \fBID\fR to receive \fBSIGURG\fR signals.
105 Free storage space associated with a section of the ordinary file \fIfildes\fR.
111 \fB\fBF_ALLOCSP\fR\fR
114 Allocate space for a section of the ordinary file \fIfildes\fR.
120 \fB\fBF_ALLOCSP64\fR\fR
123 Equivalent to \fBF_ALLOCSP\fR, but takes a \fBstruct flock64\fR argument rather
124 than a \fBstruct flock\fR argument.
133 Get record locking information.
139 \fB\fBF_GETLK64\fR\fR
142 Equivalent to \fBF_GETLK\fR, but takes a \fBstruct flock64\fR argument rather
143 than a \fBstruct flock\fR argument.
152 Set record locking information.
158 \fB\fBF_SETLK64\fR\fR
161 Equivalent to \fBF_SETLK\fR, but takes a \fBstruct flock64\fR argument rather
162 than a \fBstruct flock\fR argument.
171 Set record locking information; wait if blocked.
177 \fB\fBF_SETLKW64\fR\fR
180 Equivalent to \fBF_SETLKW\fR, but takes a \fBstruct flock64\fR argument rather
181 than a \fBstruct flock\fR argument.
190 Set share reservation.
196 \fB\fBF_UNSHARE\fR\fR
199 Remove share reservation.
204 File descriptor flags used for \fBfcntl()\fR:
208 \fB\fBFD_CLOEXEC\fR\fR
211 Close the file descriptor upon execution of an \fBexec\fR function (see
217 Values for \fBl_type\fR used for record locking with \fBfcntl()\fR (the
218 following values are unique):
243 Exclusive or write lock.
248 Values for \fBf_access\fR used for share reservations with \fBfcntl()\fR (the
249 following values are unique):
256 Read-only share reservation.
265 Write-only share reservation.
274 Read and write share reservation.
279 Values for \fBf_deny\fR used for share reservations with \fBfcntl()\fR (the
280 following values are unique):
287 Compatibility mode share reservation.
296 Deny other read access share reservations.
305 Deny other write access share reservations.
314 Deny other read or write access share reservations.
323 Do not deny other read or write access share reservations.
328 File creation and assignment flags are used in the \fIoflag\fR argument by
329 \fBopen()\fR and \fBopenat()\fR. All of these values are bitwise distinct:
336 Create file if it does not exist.
354 Do not assign controlling tty.
372 When opening a file, this flag affects the way in which relative paths are
373 resolved by \fBopen()\fR and \fBopenat()\fR. With this flag set, the
374 \fIpath\fR argument is resolved as an extended attribute reference on either
375 the current working directory (if open) or of the file referenced by the file
376 descriptor argument of \fBopenat()\fR.
381 File status flags used for \fBfcntl()\fR, \fBopen()\fR, and \fBopen()\fR:
403 \fB\fBO_NONBLOCK\fR\fR
406 Non-blocking mode (POSIX; see \fBstandards\fR(5)).
415 Write I/O operations on the file descriptor complete as defined by synchronized
416 I/O data integrity completion.
425 Read I/O operations on the file descriptor complete at the same level of
426 integrity as specified by the \fBO_DSYNC\fR and \fBO_SYNC\fR flags. If both
427 \fBO_DSYNC\fR and \fBO_RSYNC\fR are set in \fIoflag\fR, all I/O operations on
428 the file descriptor complete as defined by synchronized I/O data integrity
429 completion. If both \fBO_SYNC\fR and \fBO_RSYNC\fR are set in \fIoflag\fR,
430 all I/O operations on the file descriptor complete as defined by synchronized
431 I/O file integrity completion.
440 When opening a regular file, this flag affects subsequent writes. If set, each
441 \fBwrite\fR(2) will wait for both the file data and file status to be
442 physically updated. Write I/O operations on the file descriptor complete as
443 defined by synchronized I/O file integrity completion.
448 Mask for use with file access modes:
452 \fB\fBO_ACCMODE\fR\fR
455 Mask for file access modes.
460 File access modes used for \fBfcntl()\fR, \fBopen()\fR, and \fBopenat()\fR:
467 Open for reading only.
476 Open for reading and writing.
485 Open for writing only.
490 The following constants are used by system calls capable of resolving paths
491 relative to a provided open file descriptor:
498 Special value to pass in place of a file descriptor to inform the called
499 routine that relative path arguments should be resolved from the current
506 \fB\fBAT_SYMLINK_NOFOLLOW\fR\fR
509 Flag passed to \fBfstatat\fR(2) and \fBfchownat\fR(2) to change the behavior of
510 these functions when they are given a file as an argument that is a symbolic
511 link. In this case the functions operate on the symbolic link file rather than
512 the file the link references.
518 \fB\fBAT_REMOVEDIR\fR\fR
521 Flag passed to \fBunlinkat\fR(2) to tell it to assume that its path argument
522 refers to a directory and to attempt to remove this directory.
527 The \fBflock\fR structure describes a file lock. It includes the following
532 short l_type; /* Type of lock */
533 short l_whence; /* Flag for starting offset */
534 off_t l_start; /* Relative offset in bytes */
535 off_t l_len; /* Size; if 0 then until EOF */
536 long l_sysid; /* Returned with F_GETLK */
537 pid_t l_pid; /* Returned with F_GETLK */
543 The structure \fBfshare\fR describes a file share reservation. It includes the
548 short f_access; /* Type of reservation */
549 short f_deny; /* Type of reservations to deny */
550 long f_id; /* Process unique identifier */
556 See \fBattributes\fR(5) for descriptions of the following attributes:
564 ATTRIBUTE TYPE ATTRIBUTE VALUE
566 Interface Stability Committed
568 Standard See \fBstandards\fR(5).
573 \fBcreat\fR(2), \fBexec\fR(2), \fBfcntl\fR(2), \fBopen\fR(2),
574 \fBfdatasync\fR(3C), \fBfsync\fR(3C), \fBfsattr\fR(5), \fBattributes\fR(5),
578 Data is successfully transferred for a write operation to a regular file when
579 the system ensures that all data written is readable on any subsequent open of
580 the file (even one that follows a system or power failure) in the absence of a
581 failure of the physical storage medium.
584 Data is successfully transferred for a read operation when an image of the data
585 on the physical storage medium is available to the requesting process.
588 Synchronized I/O data integrity completion (see \fBfdatasync\fR(3C)):
593 For reads, the operation has been completed or diagnosed if unsuccessful. The
594 read is complete only when an image of the data has been successfully
595 transferred to the requesting process. If there were any pending write requests
596 affecting the data to be read at the time that the synchronized read operation
597 was requested, these write requests will be successfully transferred prior to
604 For writes, the operation has been completed or diagnosed if unsuccessful. The
605 write is complete only when the data specified in the write request is
606 successfully transferred, and all file system information required to retrieve
607 the data is successfully transferred.
611 File attributes that are not necessary for data retrieval (access time,
612 modification time, status change time) need not be successfully transferred
613 prior to returning to the calling process.
616 Synchronized I/O file integrity completion (see \fBfsync\fR(3C)):
621 Identical to a synchronized I/O data integrity completion with the addition
622 that all file attributes relative to the I/O operation (including access time,
623 modification time, status change time) will be successfully transferred prior
624 to returning to the calling process.