Print this page
4330 open(2) manual describes O_SYNC twice
   1 '\" te
   2 .\" Copyright (c) 2008, Sun Microsystems, Inc.  All Rights Reserved.
   3 .\" Copyright 1989 AT&T
   4 .\" Portions Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
   5 .\" Portions Copyright (c) 2013, OmniTI Computer Consulting, Inc.  All Rights Reserved.
   6 .\" 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
   7 .\" http://www.opengroup.org/bookstore/.
   8 .\" 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.
   9 .\"  This notice shall appear on any product containing this material.
  10 .\" 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.
  11 .\" 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.
  12 .\" 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]
  13 .TH OPEN 2 "Jun 16, 2008"
  14 .SH NAME
  15 open, openat \- open a file
  16 .SH SYNOPSIS
  17 .LP
  18 .nf
  19 #include <sys/types.h>
  20 #include <sys/stat.h>
  21 #include <fcntl.h>
  22 
  23 \fBint\fR \fBopen\fR(\fBconst char *\fR\fIpath\fR, \fBint\fR \fIoflag\fR, \fB/* mode_t\fR \fImode\fR */);
  24 .fi
  25 
  26 .LP
  27 .nf
  28 \fBint\fR \fBopenat\fR(\fBint\fR \fIfildes\fR, \fBconst char *\fR\fIpath\fR, \fBint\fR \fIoflag\fR,
  29      \fB/* mode_t\fR \fImode\fR */);
  30 .fi
  31 
  32 .SH DESCRIPTION
  33 .sp


 115 .ad
 116 .sp .6
 117 .RS 4n
 118 Create the file if it does not exist. This flag requires that the \fImode\fR
 119 argument be specified.
 120 .sp
 121 If the file exists, this flag has no effect except as noted under \fBO_EXCL\fR
 122 below.  Otherwise, the file is created with the user \fBID\fR of the file set
 123 to the effective user \fBID\fR of the process. The group \fBID\fR of the file
 124 is set to the effective group \fBIDs\fR of the process, or if the \fBS_ISGID\fR
 125 bit is set in the directory in which the file is being created, the file's
 126 group \fBID\fR is set to the group \fBID\fR of its parent directory.  If the
 127 group \fBID\fR of the new file does not match the effective group \fBID\fR or
 128 one of the supplementary groups IDs, the \fBS_ISGID\fR bit is cleared. The
 129 access permission bits (see \fB<sys/stat.h>\fR) of the file mode are set to the
 130 value of \fImode\fR, modified as follows (see \fBcreat\fR(2)): a bitwise-AND is
 131 performed on the file-mode bits and the corresponding bits in the complement of
 132 the process's file mode creation mask. Thus, all bits set in the process's file
 133 mode creation mask (see \fBumask\fR(2)) are correspondingly cleared in the
 134 file's permission mask. The "save text image after execution bit" of the mode
 135 is cleared (see \fBchmod\fR(2)). \fBO_SYNC\fR Write I/O operations on the file
 136 descriptor complete as defined by synchronized I/O file integrity completion
 137 (see \fBfcntl.h\fR(3HEAD) definition of \fBO_SYNC\fR.) When bits other than the
 138 file permission bits are set, the effect is unspecified. The \fImode\fR
 139 argument does not affect whether the file is open for reading, writing or for
 140 both.
 141 .RE
 142 
 143 .sp
 144 .ne 2
 145 .na
 146 \fB\fBO_DSYNC\fR\fR
 147 .ad
 148 .sp .6
 149 .RS 4n
 150 Write I/O operations on the file descriptor complete as defined by synchronized
 151 I/O data integrity completion.
 152 .RE
 153 
 154 .sp
 155 .ne 2
 156 .na
 157 \fB\fBO_EXCL\fR\fR
 158 .ad
 159 .sp .6
 160 .RS 4n


 287 .ad
 288 .sp .6
 289 .RS 4n
 290 Read I/O operations on the file descriptor complete at the same level of
 291 integrity as specified by the \fBO_DSYNC\fR and \fBO_SYNC\fR flags. If both
 292 \fBO_DSYNC\fR and \fBO_RSYNC\fR are set in \fIoflag\fR, all I/O operations on
 293 the file descriptor complete as defined by synchronized I/O data integrity
 294 completion.  If both \fBO_SYNC\fR and \fBO_RSYNC\fR are set in \fIoflag\fR, all
 295 I/O operations on the file descriptor complete as defined by synchronized I/O
 296 file integrity completion.
 297 .RE
 298 
 299 .sp
 300 .ne 2
 301 .na
 302 \fB\fBO_SYNC\fR\fR
 303 .ad
 304 .sp .6
 305 .RS 4n
 306 Write I/O operations on the file descriptor complete as defined by synchronized
 307 I/O file integrity completion.

 308 .RE
 309 
 310 .sp
 311 .ne 2
 312 .na
 313 \fB\fBO_TRUNC\fR\fR
 314 .ad
 315 .sp .6
 316 .RS 4n
 317 If the file exists and is a regular file, and the file is successfully opened
 318 \fBO_RDWR\fR or \fBO_WRONLY\fR, its length is truncated to 0 and the mode and
 319 owner are unchanged. It has no effect on \fBFIFO\fR special files or terminal
 320 device files. Its effect on other file types is implementation-dependent. The
 321 result of using \fBO_TRUNC\fR with \fBO_RDONLY\fR is undefined.
 322 .RE
 323 
 324 .sp
 325 .ne 2
 326 .na
 327 \fB\fBO_XATTR\fR\fR


   1 '\" te
   2 .\" Copyright (c) 2008, Sun Microsystems, Inc.  All Rights Reserved.
   3 .\" Copyright 1989 AT&T
   4 .\" Portions Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
   5 .\" Portions Copyright (c) 2013, OmniTI Computer Consulting, Inc.  All Rights Reserved.
   6 .\" 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
   7 .\" http://www.opengroup.org/bookstore/.
   8 .\" 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.
   9 .\"  This notice shall appear on any product containing this material.
  10 .\" 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.
  11 .\" 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.
  12 .\" 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]
  13 .TH OPEN 2 "Nov 16, 2013"
  14 .SH NAME
  15 open, openat \- open a file
  16 .SH SYNOPSIS
  17 .LP
  18 .nf
  19 #include <sys/types.h>
  20 #include <sys/stat.h>
  21 #include <fcntl.h>
  22 
  23 \fBint\fR \fBopen\fR(\fBconst char *\fR\fIpath\fR, \fBint\fR \fIoflag\fR, \fB/* mode_t\fR \fImode\fR */);
  24 .fi
  25 
  26 .LP
  27 .nf
  28 \fBint\fR \fBopenat\fR(\fBint\fR \fIfildes\fR, \fBconst char *\fR\fIpath\fR, \fBint\fR \fIoflag\fR,
  29      \fB/* mode_t\fR \fImode\fR */);
  30 .fi
  31 
  32 .SH DESCRIPTION
  33 .sp


 115 .ad
 116 .sp .6
 117 .RS 4n
 118 Create the file if it does not exist. This flag requires that the \fImode\fR
 119 argument be specified.
 120 .sp
 121 If the file exists, this flag has no effect except as noted under \fBO_EXCL\fR
 122 below.  Otherwise, the file is created with the user \fBID\fR of the file set
 123 to the effective user \fBID\fR of the process. The group \fBID\fR of the file
 124 is set to the effective group \fBIDs\fR of the process, or if the \fBS_ISGID\fR
 125 bit is set in the directory in which the file is being created, the file's
 126 group \fBID\fR is set to the group \fBID\fR of its parent directory.  If the
 127 group \fBID\fR of the new file does not match the effective group \fBID\fR or
 128 one of the supplementary groups IDs, the \fBS_ISGID\fR bit is cleared. The
 129 access permission bits (see \fB<sys/stat.h>\fR) of the file mode are set to the
 130 value of \fImode\fR, modified as follows (see \fBcreat\fR(2)): a bitwise-AND is
 131 performed on the file-mode bits and the corresponding bits in the complement of
 132 the process's file mode creation mask. Thus, all bits set in the process's file
 133 mode creation mask (see \fBumask\fR(2)) are correspondingly cleared in the
 134 file's permission mask. The "save text image after execution bit" of the mode
 135 is cleared (see \fBchmod\fR(2)). When bits other than the file permission bits
 136 are set, the effect is unspecified. The \fImode\fR argument does not affect
 137 whether the file is open for reading, writing or for both.



 138 .RE
 139 
 140 .sp
 141 .ne 2
 142 .na
 143 \fB\fBO_DSYNC\fR\fR
 144 .ad
 145 .sp .6
 146 .RS 4n
 147 Write I/O operations on the file descriptor complete as defined by synchronized
 148 I/O data integrity completion.
 149 .RE
 150 
 151 .sp
 152 .ne 2
 153 .na
 154 \fB\fBO_EXCL\fR\fR
 155 .ad
 156 .sp .6
 157 .RS 4n


 284 .ad
 285 .sp .6
 286 .RS 4n
 287 Read I/O operations on the file descriptor complete at the same level of
 288 integrity as specified by the \fBO_DSYNC\fR and \fBO_SYNC\fR flags. If both
 289 \fBO_DSYNC\fR and \fBO_RSYNC\fR are set in \fIoflag\fR, all I/O operations on
 290 the file descriptor complete as defined by synchronized I/O data integrity
 291 completion.  If both \fBO_SYNC\fR and \fBO_RSYNC\fR are set in \fIoflag\fR, all
 292 I/O operations on the file descriptor complete as defined by synchronized I/O
 293 file integrity completion.
 294 .RE
 295 
 296 .sp
 297 .ne 2
 298 .na
 299 \fB\fBO_SYNC\fR\fR
 300 .ad
 301 .sp .6
 302 .RS 4n
 303 Write I/O operations on the file descriptor complete as defined by synchronized
 304 I/O file integrity completion (see \fBfcntl.h\fR(3HEAD) definition of
 305 \fBO_SYNC\fR.)
 306 .RE
 307 
 308 .sp
 309 .ne 2
 310 .na
 311 \fB\fBO_TRUNC\fR\fR
 312 .ad
 313 .sp .6
 314 .RS 4n
 315 If the file exists and is a regular file, and the file is successfully opened
 316 \fBO_RDWR\fR or \fBO_WRONLY\fR, its length is truncated to 0 and the mode and
 317 owner are unchanged. It has no effect on \fBFIFO\fR special files or terminal
 318 device files. Its effect on other file types is implementation-dependent. The
 319 result of using \fBO_TRUNC\fR with \fBO_RDONLY\fR is undefined.
 320 .RE
 321 
 322 .sp
 323 .ne 2
 324 .na
 325 \fB\fBO_XATTR\fR\fR