summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorRobert Mustacchi <rm@joyent.com>2013-11-01 02:09:06 +0000
committerRobert Mustacchi <rm@joyent.com>2013-11-01 17:52:37 +0000
commit1db0473d2f1d9999290300fb1abb65d3688d7bc1 (patch)
tree9d61f1ce0be3bda610a65470c692e6804644b772 /usr/src
parent7903db5949b2e1baafa5db6a75c1545841ddfc05 (diff)
downloadillumos-joyent-1db0473d2f1d9999290300fb1abb65d3688d7bc1.tar.gz
OS-2606 fopen could support 'x'
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com> Reviewed by: Joshua M. Clulow <jmc@joyent.com>
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/lib/libc/port/stdio/_endopen.c9
-rw-r--r--usr/src/man/man3c/fopen.3c14
2 files changed, 18 insertions, 5 deletions
diff --git a/usr/src/lib/libc/port/stdio/_endopen.c b/usr/src/lib/libc/port/stdio/_endopen.c
index b1f6d12912..a7c4508cbb 100644
--- a/usr/src/lib/libc/port/stdio/_endopen.c
+++ b/usr/src/lib/libc/port/stdio/_endopen.c
@@ -55,7 +55,7 @@
FILE *
_endopen(const char *name, const char *type, FILE *iop, int largefile)
{
- int oflag, fd, fflag, eflag, plusflag;
+ int oflag, fd, fflag, eflag, plusflag, xflag;
const char *echr;
if (iop == NULL)
@@ -80,6 +80,7 @@ _endopen(const char *name, const char *type, FILE *iop, int largefile)
plusflag = 0;
eflag = 0;
+ xflag = 0;
for (echr = type + 1; *echr != '\0'; echr++) {
switch (*echr) {
/* UNIX ignores 'b' and treats text and binary the same */
@@ -91,6 +92,9 @@ _endopen(const char *name, const char *type, FILE *iop, int largefile)
case 'e':
eflag = 1;
break;
+ case 'x':
+ xflag = 1;
+ break;
}
}
if (eflag) {
@@ -101,6 +105,9 @@ _endopen(const char *name, const char *type, FILE *iop, int largefile)
oflag = (oflag & ~(O_RDONLY | O_WRONLY)) | O_RDWR;
fflag = _IORW;
}
+ if (xflag) {
+ oflag |= O_EXCL;
+ }
/* select small or large file open based on flag */
if (largefile) {
diff --git a/usr/src/man/man3c/fopen.3c b/usr/src/man/man3c/fopen.3c
index 648cd185ac..0b1f74afc3 100644
--- a/usr/src/man/man3c/fopen.3c
+++ b/usr/src/man/man3c/fopen.3c
@@ -3,6 +3,7 @@
.\" Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved.
.\" Portions Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
.\" Portions Copyright (c) 2013, OmniTI Computer Consulting, Inc. All Rights Reserved.
+.\" Portions Copyright (c) 2013, Joyent, Inc. All Rights Reserved.
.\" 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
.\" http://www.opengroup.org/bookstore/.
.\" 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.
@@ -86,10 +87,10 @@ Append; open or create file for update, writing at end-of-file.
.sp
.LP
-In addition to the base sequences for the \fImode\fR argument above, two
-additional flags are supported via the \fBb\fR character and the \fBe\fR
-character. Order of these additional flags (including the \fB+\fR) does
-not matter.
+In addition to the base sequences for the \fImode\fR argument above,
+three additional flags are supported via the \fBb\fR character, the
+\fBe\fR character, and the \fBx\fR character. Order of these additional
+flags (including the \fB+\fR) does not matter.
.sp
.LP
The character \fBb\fR has no effect, but is allowed for ISO C standard
@@ -102,6 +103,11 @@ The character \fBe\fR will cause the underlying file descriptor to be
opened with the O_CLOEXEC flag as described in \fBopen\fR(2).
.sp
.LP
+The character \fBx\fR will attempt to open the specified file
+exclusively. This is the same behavior as opening the underlying file
+with the O_EXCL flag as described in \fBopen\fR(2).
+.sp
+.LP
Opening a file with append mode (\fBa\fR as the first character in the
\fImode\fR argument) causes all subsequent writes to the file to be forced to
the then current end-of-file, regardless of intervening calls to