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/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
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.
25 .\" This notice shall appear on any product containing this material.
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.
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.
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]
43 .\" Copyright 1989 AT&T
44 .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved.
46 .TH FCNTL.H 3HEAD "April 9, 2016"
48 fcntl.h, fcntl \- file control options
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).
61 Values for \fIcmd\fR used by \fBfcntl()\fR (the following values are unique):
68 Duplicate file descriptor.
77 Similar to \fBF_DUPFD\fR, but always returns \fIarg\fR.
86 Get file descriptor flags.
95 Set file descriptor flags.
104 Get file status flags.
113 Set file status flags.
122 Get process or process group \fBID\fR to receive \fBSIGURG\fR signals.
131 Set process or process group \fBID\fR to receive \fBSIGURG\fR signals.
140 Free storage space associated with a section of the ordinary file \fIfildes\fR.
146 \fB\fBF_ALLOCSP\fR\fR
149 Allocate space for a section of the ordinary file \fIfildes\fR.
155 \fB\fBF_ALLOCSP64\fR\fR
158 Equivalent to \fBF_ALLOCSP\fR, but takes a \fBstruct flock64\fR argument rather
159 than a \fBstruct flock\fR argument.
168 Get record locking information.
174 \fB\fBF_GETLK64\fR\fR
177 Equivalent to \fBF_GETLK\fR, but takes a \fBstruct flock64\fR argument rather
178 than a \fBstruct flock\fR argument.
187 Set record locking information.
193 \fB\fBF_SETLK64\fR\fR
196 Equivalent to \fBF_SETLK\fR, but takes a \fBstruct flock64\fR argument rather
197 than a \fBstruct flock\fR argument.
206 Set record locking information; wait if blocked.
212 \fB\fBF_SETLKW64\fR\fR
215 Equivalent to \fBF_SETLKW\fR, but takes a \fBstruct flock64\fR argument rather
216 than a \fBstruct flock\fR argument.
225 Set share reservation.
231 \fB\fBF_UNSHARE\fR\fR
234 Remove share reservation.
239 File descriptor flags used for \fBfcntl()\fR:
243 \fB\fBFD_CLOEXEC\fR\fR
246 Close the file descriptor upon execution of an \fBexec\fR function (see
252 Values for \fBl_type\fR used for record locking with \fBfcntl()\fR (the
253 following values are unique):
278 Exclusive or write lock.
283 Values for \fBf_access\fR used for share reservations with \fBfcntl()\fR (the
284 following values are unique):
291 Read-only share reservation.
300 Write-only share reservation.
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):
322 Compatibility mode share reservation.
331 Deny other read access share reservations.
340 Deny other write access share reservations.
349 Deny other read or write access share reservations.
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:
371 Create file if it does not exist.
389 Do not assign controlling tty.
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:
438 \fB\fBO_NONBLOCK\fR\fR
441 Non-blocking mode (POSIX; see \fBstandards\fR(5)).
450 Write I/O operations on the file descriptor complete as defined by synchronized
451 I/O data integrity completion.
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.
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:
487 \fB\fBO_ACCMODE\fR\fR
490 Mask for file access modes.
495 File access modes used for \fBfcntl()\fR, \fBopen()\fR, and \fBopenat()\fR:
502 Open for reading only.
511 Open for reading and writing.
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:
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
541 \fB\fBAT_SYMLINK_NOFOLLOW\fR\fR
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.
553 \fB\fBAT_REMOVEDIR\fR\fR
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
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 */
578 The structure \fBfshare\fR describes a file share reservation. It includes the
583 short f_access; /* Type of reservation */
584 short f_deny; /* Type of reservations to deny */
585 long f_id; /* Process unique identifier */
591 See \fBattributes\fR(5) for descriptions of the following attributes:
599 ATTRIBUTE TYPE ATTRIBUTE VALUE
601 Interface Stability Committed
603 Standard See \fBstandards\fR(5).
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),
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)):
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
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)):
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.