OSDN Git Service

(split) LDP: Update original to LDP v3.50.
[linuxjm/LDP_man-pages.git] / original / man3 / mkstemp.3
index bea792f..40cd7e6 100644 (file)
@@ -1,6 +1,7 @@
 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
 .\" and Copyright (C) 2008, Michael Kerrisk <mtk.manpages@gmail.com>
 .\"
+.\" %%%LICENSE_START(VERBATIM)
 .\" Permission is granted to make and distribute verbatim copies of this
 .\" manual provided the copyright notice and this permission notice are
 .\" preserved on all copies.
@@ -20,6 +21,7 @@
 .\"
 .\" Formatted or processed versions of this manual, if unaccompanied by
 .\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
 .\"
 .\" References consulted:
 .\"     Linux libc source code
 .\" Modified 990328, aeb
 .\" 2008-06-19, mtk, Added mkostemp(); various other changes
 .\"
-.TH MKSTEMP 3  2008-06-19 "GNU" "Linux Programmer's Manual"
+.TH MKSTEMP 3  2012-12-21 "GNU" "Linux Programmer's Manual"
 .SH NAME
-mkstemp, mkostemp \- create a unique temporary file
+mkstemp, mkostemp, mkstemps, mkostemps \- create a unique temporary file
 .SH SYNOPSIS
 .nf
 .B #include <stdlib.h>
 .sp
 .BI "int mkstemp(char *" template );
 .sp
-.BI "int mkostemp (char *" template ", int " flags );
+.BI "int mkostemp(char *" template ", int " flags );
+.sp
+.BI "int mkstemps(char *" template ", int " suffixlen );
+.sp
+.BI "int mkostemps(char *" template ", int " suffixlen ", int " flags );
 .fi
 .sp
 .in -4n
@@ -48,10 +54,25 @@ Feature Test Macro Requirements for glibc (see
 .in
 .sp
 .BR mkstemp ():
-_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 500
+.ad l
+.RS 4
+.PD 0
+_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
+_XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
 .br
+|| /* Since glibc 2.12: */ _POSIX_C_SOURCE\ >=\ 200112L
+.PD
+.RE
+.ad b
+.PP
 .BR mkostemp ():
 _GNU_SOURCE
+.br
+.BR mkstemps ():
+_BSD_SOURCE || _SVID_SOURCE
+.br
+.BR mkostemps ():
+_GNU_SOURCE
 .SH DESCRIPTION
 The
 .BR mkstemp ()
@@ -70,16 +91,15 @@ must not be a string constant, but should be declared as a character array.
 
 The file is created with
 permissions 0600, that is, read plus write for owner only.
-(In glibc versions 2.06 and earlier, the file is created with permissions 0666,
-that is, read and write for all users.)
 The returned file descriptor provides both read and write access to the file.
 The file is opened with the
 .BR open (2)
 .B O_EXCL
 flag, guaranteeing that the caller is the process that creates the file.
 
+The
 .BR mkostemp ()
-is like
+function is like
 .BR mkstemp (),
 with the difference that flags as for
 .BR open (2)
@@ -88,7 +108,32 @@ may be specified in
 (e.g.,
 .BR O_APPEND ,
 .BR O_SYNC ).
-.SH "RETURN VALUE"
+
+The
+.BR mkstemps ()
+function is like
+.BR mkstemp (),
+except that the string in
+.I template
+contains a suffix of
+.I suffixlen
+characters.
+Thus,
+.I template
+is of the form
+.IR "prefixXXXXXXsuffix" ,
+and the string XXXXXX is modified as for
+.BR mkstemp ().
+
+The
+.BR mkostemps ()
+function is to
+.BR mkstemps ()
+as
+.BR mkostemp ()
+is to
+.BR mkstemp ().
+.SH RETURN VALUE
 On success, these functions return the file descriptor
 of the temporary file.
 On error, \-1 is returned, and
@@ -101,23 +146,53 @@ Could not create a unique temporary filename.
 Now the contents of \fItemplate\fP are undefined.
 .TP
 .B EINVAL
-The last six characters of \fItemplate\fP were not XXXXXX.
-Now \fItemplate\fP is unchanged.
+For
+.BR mkstemp ()
+and
+.BR mkostemp ():
+The last six characters of \fItemplate\fP were not XXXXXX;
+now \fItemplate\fP is unchanged.
+.sp
+For
+.BR mkstemps ()
+and
+.BR mkostemps ():
+.I template
+is less than
+.I "(6 + suffixlen)"
+characters long, or the last 6 characters before the suffix in
+.I template
+were not XXXXXX.
 .PP
 These functions may also fail with any of the errors described for
 .BR open (2).
 .SH VERSIONS
 .BR mkostemp ()
 is available since glibc 2.7.
-.SH "CONFORMING TO"
+.BR mkstemps ()
+and
+.BR mkostemps ()
+are available since glibc 2.11.
+.SH CONFORMING TO
 .BR mkstemp ():
 4.3BSD, POSIX.1-2001.
-.BR mkostemp ():
-is a glibc extension.
+
+.BR mkstemps ():
+unstandardized, but appears on several other systems.
+.\" mkstemps() appears to be at least on the BSDs, Mac OS X, Solaris,
+.\" and Tru64.
+
+.BR mkostemp ()
+and
+.BR mkostemps ():
+are glibc extensions.
 .SH NOTES
-The old behavior of creating a file with mode 0666 may be
-a security risk, especially since other Unix flavors use 0600,
+In glibc versions 2.06 and earlier, the file is created with permissions 0666,
+that is, read and write for all users.
+This old behavior may be
+a security risk, especially since other UNIX flavors use 0600,
 and somebody might overlook this detail when porting programs.
+POSIX.1-2008 adds a requirement that the file be created with mode 0600.
 
 More generally, the POSIX specification of
 .BR mkstemp ()
@@ -136,7 +211,7 @@ is in
 .I <unistd.h>
 for libc4, libc5, glibc1; glibc2 follows POSIX.1 and has the prototype in
 .IR <stdlib.h> .
-.SH "SEE ALSO"
+.SH SEE ALSO
 .BR mkdtemp (3),
 .BR mktemp (3),
 .BR tempnam (3),