Document the O_SYNC flag, and where its semantics are defined (XPG4.2).

Be more clear about how file access modes are specified, and do a bit
of general cleanup.
This commit is contained in:
thorpej 1998-01-15 02:30:18 +00:00
parent d6e5187749
commit 1e4cac0c75
1 changed files with 42 additions and 24 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: open.2,v 1.11 1997/11/01 06:37:48 mycroft Exp $
.\" $NetBSD: open.2,v 1.12 1998/01/15 02:30:18 thorpej Exp $
.\"
.\" Copyright (c) 1980, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@ -53,32 +53,50 @@ argument
and the file descriptor returned to the calling process.
The
.Fa flags
argument may indicate the file is to be
created if it does not exist (by specifying the
.Dv O_CREAT
flag), in which case the file is created with mode
.Fa mode
are specified by
.Em or Ns 'ing
the following values. Applications must specify exactly one
of the first three values (file access modes):
.Bl -tag -offset indent -width O_NONBLOCK
.It Dv O_RDONLY
Open for reading only.
.It Dv O_WRONLY
Open for writing only.
.It Dv O_RDWR
Open for reading and writing.
.El
.Pp
Any combination of the following may be used:
.Bl -tag -offset indent -width O_NONBLOCK
.It Dv O_NONBLOCK
Do not block on open or for data to become available.
.It Dv O_APPEND
Append to the file on each write.
.It Dv O_CREAT
Create the file if it does not exist, in which case the file is
created with mode
.Ar mode
as described in
.Xr chmod 2
and modified by the process' umask value (see
.Xr umask 2 ) .
.Pp
The flags specified are formed by
.Em or Ns 'ing
the following values
.Pp
.Bd -literal -offset indent -compact
O_RDONLY open for reading only
O_WRONLY open for writing only
O_RDWR open for reading and writing
O_NONBLOCK do not block on open or for data to become available
O_APPEND append on each write
O_CREAT create file if it does not exist
O_TRUNC truncate size to 0
O_EXCL error if create and file exists
O_SHLOCK atomically obtain a shared lock
O_EXLOCK atomically obtain an exclusive lock
.Ed
.It Dv O_TRUNC
Truncate size to 0.
.It Dv O_EXCL
Error if
.Dv O_CREAT
and the file already exists.
.It Dv O_SHLOCK
Atomically obtain a shared lock.
.It Dv O_EXLOCK
Atomically obtain an exclusive lock.
.It Dv O_SYNC
If set, each write will wait for both the file data and file status
to be committed to stable storage. This is an extension to
.Fn open
defined in
.St -xpg4.2 .
.El
.Pp
Opening a file with
.Dv O_APPEND
@ -259,7 +277,7 @@ An attempt was made to open a socket (not currently implemented).
.Sh STANDARDS
The
.Fn open
functions conforms to
function conforms to
.St -p1003.1-88 .
.Sh HISTORY
An