OSDN Git Service

Update README
[linuxjm/LDP_man-pages.git] / draft / man3 / mkstemp.3
index 872410f..427e046 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
 .\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.\"
 .\" Japanese Version Copyright (c) 1997 Kazuyuki Tanisako
 .\"         all rights reserved.
 .\" Translated 1997-05-17, Kazuyuki Tanisako <tanisako@osa.dec-j.co.jp>
 .\" Updated 2001-01-17, Kentaro Shirakata <argrath@ub32.org>
 .\" Updated 2005-02-26, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
 .\" Updated 2008-08-10, Akihiro MOTOKI, LDP v3.05
+.\" Updated 2012-04-27, Akihiro MOTOKI <amotoki@gmail.com>
+.\" Updated 2012-05-01, Akihiro MOTOKI <amotoki@gmail.com>
+.\" Updated 2013-03-26, Akihiro MOTOKI <amotoki@gmail.com>
 .\"
-.\"WORD:       temporary file  °ì»þ¥Õ¥¡¥¤¥ë
-.\"WORD:       read/write      ¥ê¡¼¥É¡¿¥é¥¤¥È
-.\"WORD:       permissions     µö²Ä
-.\"
-.TH MKSTEMP 3  2008-06-19 "GNU" "Linux Programmer's Manual"
-.\"O .SH NAME
-.SH Ì¾Á°
-.\"O mkstemp, mkostemp \- create a unique temporary file
-mkstemp, mkostemp \- Â¾¤È½Å¤Ê¤é¤Ê¤¤Ì¾Á°¤ò»ý¤Ä°ì»þ¥Õ¥¡¥¤¥ë¤òºîÀ®¤¹¤ë
-.\"O .SH SYNOPSIS
-.SH ½ñ¼°
+.TH MKSTEMP 3 2014\-08\-19 GNU "Linux Programmer's Manual"
+.SH 名前
+mkstemp, mkostemp, mkstemps, mkostemps \- 他と重ならない名前を持つ一時ファイルを作成する
+.SH 書式
 .nf
-.B #include <stdlib.h>
+\fB#include <stdlib.h>\fP
 .sp
-.BI "int mkstemp(char *" template );
+\fBint mkstemp(char *\fP\fItemplate\fP\fB);\fP
 .sp
-.BI "int mkostemp (char *" template ", int " flags );
+\fBint mkostemp(char *\fP\fItemplate\fP\fB, int \fP\fIflags\fP\fB);\fP
+.sp
+\fBint mkstemps(char *\fP\fItemplate\fP\fB, int \fP\fIsuffixlen\fP\fB);\fP
+.sp
+\fBint mkostemps(char *\fP\fItemplate\fP\fB, int \fP\fIsuffixlen\fP\fB, int \fP\fIflags\fP\fB);\fP
 .fi
 .sp
 .in -4n
-.\"O Feature Test Macro Requirements for glibc (see
-.\"O .BR feature_test_macros (7)):
-glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
-.RB ( feature_test_macros (7)
-»²¾È):
+glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
 .in
 .sp
-.BR mkstemp ():
-_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 500
+\fBmkstemp\fP():
+.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
+\fBmkostemp\fP(): _GNU_SOURCE
+.br
+\fBmkstemps\fP(): _BSD_SOURCE || _SVID_SOURCE
 .br
-.BR mkostemp ():
-_GNU_SOURCE
-\"O .SH DESCRIPTION
-.SH ÀâÌÀ
-.\"O The
-.\"O .BR mkstemp ()
-.\"O function generates a unique temporary filename from
-.\"O .IR template ,
-.\"O creates and opens the file,
-.\"O and returns an open file descriptor for the file.
-´Ø¿ô
-.BR mkstemp ()
-¤Ï°ú¿ô
-.I template
-¤«¤é¾¤È½Å¤Ê¤é¤Ê¤¤°ì»þ¥Õ¥¡¥¤¥ë̾¤òÀ¸À®¤·¡¢
-¤½¤Î¥Õ¥¡¥¤¥ë¤ÎºîÀ®¤È¥ª¡¼¥×¥ó¤ò¹Ô¤¤¡¢
-¤½¤Î¥Õ¥¡¥¤¥ë¤ËÂФ¹¤ë¥ª¡¼¥×¥óºÑ¤ß¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òÊÖ¤¹¡£
+\fBmkostemps\fP(): _GNU_SOURCE
+.SH 説明
+関数 \fBmkstemp\fP()  は引数 \fItemplate\fP から他と重ならない一時ファイル名を生成し、 そのファイルの作成とオープンを行い、
+そのファイルに対するオープン済みのファイルディスクリプターを返す。
+
+引数 \fItemplate\fP で指示する文字列の後ろの 6 文字は XXXXXX である必要がある。
+この部分がファイル名を他と重ならないようにする文字で置き換えられる。 \fItemplate\fP は書き換えられるため、文字列定数ではなく文字配列として
+宣言するようにしなければならない。
+
+ファイルは許可モード 0600 で作成され、所有者のみが読み書き可能である。返されるファイルディスクリプターで、このファイルへの読み書き両方のアクセスが
+可能である。 呼び出し者がそのファイルを作成するプロセスであることを保証するために、 ファイルは \fBopen\fP(2)  の \fBO_EXCL\fP
+フラグ付きでオープンされる。
 
-.\"O The last six characters of
-.\"O .I template
-.\"O must be "XXXXXX" and these are replaced with a string that makes the
-.\"O filename unique.
-°ú¿ô
-.I template
-¤Ç»Ø¼¨¤¹¤ëʸ»úÎó¤Î¸å¤í¤Î 6 Ê¸»ú¤Ï XXXXXX ¤Ç¤¢¤ëɬÍפ¬¤¢¤ë¡£
-¤³¤ÎÉôʬ¤¬¥Õ¥¡¥¤¥ë̾¤ò¾¤È½Å¤Ê¤é¤Ê¤¤¤è¤¦¤Ë¤¹¤ëʸ»ú¤ÇÃÖ¤­´¹¤¨¤é¤ì¤ë¡£
-.\"O Since it will be modified,
-.\"O .I template
-.\"O must not be a string constant, but should be declared as a character array.
-.I template
-¤Ï½ñ¤­´¹¤¨¤é¤ì¤ë¤¿¤á¡¢Ê¸»úÎóÄê¿ô¤Ç¤Ï¤Ê¤¯Ê¸»úÇÛÎó¤È¤·¤Æ
-Àë¸À¤¹¤ë¤è¤¦¤Ë¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
+.\" Reportedly, FreeBSD
+\fBmkostemp\fP() 関数は \fBmkstemp\fP() と同様だが、 \fIflags\fP に \fBO_APPEND\fP, \fBO_CLOEXEC\fP,
+\fBO_SYNC\fP のビットを指定できる点が異なる (意味は \fBopen\fP(2) と同じである)。ファイルを作成する際、 \fBmkostemp\fP()
+は \fBopen\fP(2) に渡す \fIflags\fP 引き数に \fBO_RDWR\fP, \fBO_CREAT\fP, \fBO_EXCL\fP を含める。そのため、
+\fBmkostemp\fP() に渡す \fIflags\fP 引き数にこれらの値を含める必要はなく、システムによってはエラーが発生する点に注意すること。
 
-.\"O The file is created with
-.\"O permissions 0600, that is, read plus write for owner only.
-.\"O (In glibc versions 2.06 and earlier, the file is created with permissions 0666,
-.\"O that is, read and write for all users.)
-.\"O The returned file descriptor provides both read and write access to the file.
-.\"O The file is opened with the
-.\"O .BR open (2)
-.\"O .B O_EXCL
-.\"O flag, guaranteeing that the caller is the process that creates the file.
-¥Õ¥¡¥¤¥ë¤Ïµö²Ä¥â¡¼¥É 0600 ¤ÇºîÀ®¤µ¤ì¡¢½êÍ­¼Ô¤Î¤ß¤¬Æɤ߽ñ¤­²Äǽ¤Ç¤¢¤ë
-(glibc ¥Ð¡¼¥¸¥ç¥ó 2.06 °ÊÁ°¤Ç¤Ï¡¢¥Õ¥¡¥¤¥ë¤Ïµö²Ä¥â¡¼¥É 0666 ¤ÇºîÀ®¤µ¤ì¡¢
-Á´¤Æ¤Î¥æ¡¼¥¶¤¬Æɤ߽ñ¤­²Äǽ¤Ç¤¢¤Ã¤¿)¡£
-ÊÖ¤µ¤ì¤ë¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¡¢¤³¤Î¥Õ¥¡¥¤¥ë¤Ø¤ÎÆɤ߽ñ¤­Î¾Êý¤Î¥¢¥¯¥»¥¹¤¬
-²Äǽ¤Ç¤¢¤ë¡£
-¸Æ¤Ó½Ð¤·¼Ô¤¬¤½¤Î¥Õ¥¡¥¤¥ë¤òºîÀ®¤¹¤ë¥×¥í¥»¥¹¤Ç¤¢¤ë¤³¤È¤òÊݾڤ¹¤ë¤¿¤á¤Ë¡¢
-¥Õ¥¡¥¤¥ë¤Ï
-.BR open (2)
-¤Î
-.B O_EXCL
-¥Õ¥é¥°ÉÕ¤­¤Ç¥ª¡¼¥×¥ó¤µ¤ì¤ë¡£
+\fBmkstemps\fP() 関数は \fBmkstemp\fP() と同様だが、 \fItemplate\fP 内の文字列に長さ
+が \fIsuffixlen\fP 文字の接尾辞 (suffix) が含まれる点が異なる。
+したがって、 \fItemplate\fP は \fIprefixXXXXXXsuffix\fP の形式となる。
+文字列 XXXXXX の部分は \fBmkstemp\fP() により更新される。
 
-.\"O .BR mkostemp ()
-.\"O is like
-.\"O .BR mkstemp (),
-.\"O with the difference that flags as for
-.\"O .BR open (2)
-.\"O may be specified in
-.\"O .IR flags
-.\"O (e.g.,
-.\"O .BR O_APPEND ,
-.\"O .BR O_SYNC ).
-.BR mkostemp ()
-¤Ï
-.BR mkstemp ()
-¤ÈƱÍͤÀ¤¬¡¢
-.BR open (2)
-¤ËÅϤµ¤ì¤ë¥Õ¥é¥°
-.RB O_APPEND ,
-.B O_SYNC
-¤Ê¤É) ¤ò
-.I flags
-¤Ç»ØÄê¤Ç¤­¤ëÅÀ¤¬°Û¤Ê¤ë
-.\"O .SH "RETURN VALUE"
-.SH ÊÖ¤êÃÍ
-.\"O On success, these functions return the file descriptor
-.\"O of the temporary file.
-.\"O On error, \-1 is returned, and
-.\"O .I errno
-.\"O is set appropriately.
-À®¸ù¤¹¤ë¤È¡¢¤³¤ì¤é¤Î´Ø¿ô¤Ï°ì»þ¥Õ¥¡¥¤¥ë¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òÊÖ¤¹¡£
-¥¨¥é¡¼¤Î¾ì¹ç¤Ï¡¢\-1 ¤òÊÖ¤·¡¢
-.I errno
-¤òŬÀÚ¤ËÀßÄꤹ¤ë¡£
-.\"O .SH ERRORS
-.SH ¥¨¥é¡¼
-.TP
-.B EEXIST
-.\"O Could not create a unique temporary filename.
-.\"O Now the contents of \fItemplate\fP are undefined.
-¤¹¤Ç¤ËƱ¤¸Ì¾Á°¤ò»ý¤Ä¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤·¤¿¡£
-\fItemplate\fP ¤ÎÆâÍƤÏÉÔÄê¤Ç¤¢¤ë¡£
-.TP
-.B EINVAL
-.\"O The last six characters of \fItemplate\fP were not XXXXXX.
-.\"O Now \fItemplate\fP is unchanged.
-°ú¿ô \fItemplate\fP ¤Ç»Ø¼¨¤µ¤ì¤¿Ê¸»úÇÛÎó¤Î¸å¤í¤Î 6 Ê¸»ú¤¬ XXXXXX ¤Ç¤Ê¤¤¡£
-\fItemplate\fP ¤ÎÆâÍƤÏÊѲ½¤·¤Ê¤¤¡£
+\fBmkostemps\fP() と \fBmkstemps\fP() の関係は、
+\fBmkostemp\fP() と \fBmkstemp\fP() の関係と同じである。
+.SH 返り値
+成功すると、これらの関数は一時ファイルのファイルディスクリプターを返す。 エラーの場合は、\-1 を返し、 \fIerrno\fP を適切に設定する。
+.SH エラー
+.TP 
+\fBEEXIST\fP
+すでに同じ名前を持つファイルが存在した。 \fItemplate\fP の内容は不定である。
+.TP 
+\fBEINVAL\fP
+\fBmkstemp\fP() と \fBmkostemp\fP() の場合:
+\fItemplate\fP の最後の 6 文字が XXXXXX でなかった。
+この場合、\fItemplate\fP は変更されない。
+.sp
+\fBmkstemps\fP() と \fBmkostemps\fP() の場合:
+\fItemplate\fP の長さが \fI(6 + suffixlen)\fP 文字より短い、または
+\fItemplate\fP の接尾辞の直前の 6 文字が XXXXXX ではなかった。
 .PP
-.\"O These functions may also fail with any of the errors described for
-.\"O .BR open (2).
-¤³¤ì¤é¤Î´Ø¿ô¤Ï
-.BR open (2)
-¤Ë½ñ¤«¤ï¤ì¤Æ¤¤¤ë¥¨¥é¡¼¤Î¤¤¤º¤ì¤«¤Ç¼ºÇÔ¤¹¤ë¤³¤È¤â¤¢¤ë¡£
-.\"O .SH VERSIONS
-.SH ¥Ð¡¼¥¸¥ç¥ó
-.\"O .BR mkostemp ()
-.\"O is available since glibc 2.7.
-.BR mkostemp ()
-¤Ï glibc 2.7 °Ê¹ß¤ÇÍøÍѲÄǽ¤Ç¤¢¤ë¡£
-.\"O .SH "CONFORMING TO"
-.SH ½àµò
-.BR mkstemp ():
-4.3BSD, POSIX.1-2001.
-.BR mkostemp ():
-.\"O is a glibc extension.
-glibc ¤Ë¤è¤ë³ÈÄ¥¡£
-.\"O .SH NOTES
-.SH Ãí°Õ
-.\"O The old behavior of creating a file with mode 0666 may be
-.\"O a security risk, especially since other Unix flavors use 0600,
-.\"O and somebody might overlook this detail when porting programs.
-µö²Ä¥â¡¼¥É 0666 ¤Ç¥Õ¥¡¥¤¥ë¤òºîÀ®¤¹¤ë¤È¤¤¤¦¸Å¤¤Æ°ºî¤Ï¡¢
-¥»¥­¥å¥ê¥Æ¥£¾å¤Î¥ê¥¹¥¯¤Ë¤Ê¤ë¾ì¹ç¤¬¤¢¤ë¡£
-Æä˾¤Î Unix ¤Ç¤Ïµö²Ä¥â¡¼¥É¤È¤·¤Æ 0600 ¤ò»È¤¦¤¿¤á¡¢
-¥×¥í¥°¥é¥à¤ò°Ü¿¢¤¹¤ëºÝ¡¢¤³¤ÎºÙ¤«¤Ê°ã¤¤¤ò¸«Íî¤È¤¹²ÄǽÀ­¤¬
-¤¢¤ë¤«¤é¤À¡£
+これらの関数は \fBopen\fP(2) に書かれているエラーのいずれかで失敗することもある。
+.SH バージョン
+\fBmkostemp\fP() は glibc 2.7 以降で利用できる。
+\fBmkstemps\fP() と \fBmkostemps\fP() は glibc 2.11 以降で利用できる。
+.SH 属性
+.SS "マルチスレッディング (pthreads(7) 参照)"
+関数 \fBmkstemp\fP(), \fBmkostemp\fP(), \fBmkstemps\fP(), \fBmkostemps\fP() はスレッドセーフである。
+.SH 準拠
+\fBmkstemp\fP(): 4.3BSD, POSIX.1\-2001.
+
+.\" mkstemps() appears to be at least on the BSDs, Mac OS X, Solaris,
+.\" and Tru64.
+\fBmkstemps\fP(): 標準化されていないが、他のいくつかのシステムにも存在する。
 
-.\"O More generally, the POSIX specification of
-.\"O .BR mkstemp ()
-.\"O does not say anything
-.\"O about file modes, so the application should make sure its
-.\"O file mode creation mask (see
-.\"O .BR umask (2))
-.\"O is set appropriately before calling
-.\"O .BR mkstemp ()
-.\"O (and
-.\"O .BR mkostemp ()).
-¤è¤ê°ìÈÌŪ¤Ë¤Ï¡¢
-.BR mkstemp ()
-¤Î POSIX µ¬Äê¤Ç¤Ï¥Õ¥¡¥¤¥ë¥â¡¼¥É¤Ë¤Ä¤¤¤Æ²¿¤â½Ò¤Ù¤Æ¤¤¤Ê¤¤¡£
-½¾¤Ã¤Æ¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï
-.BR mkstemp ()
-(¤ä
-.BR mkostemp ())
-¤ò¸Æ¤Ó½Ð¤¹Á°¤Ë¥Õ¥¡¥¤¥ë¥â¡¼¥ÉÀ¸À®¥Þ¥¹¥¯
-.RB ( umask (2)
-»²¾È) ¤¬Å¬ÀÚ¤ËÀßÄꤵ¤ì¤Æ¤¤¤ë¤«³Îǧ¤¹¤ë¤Ù¤­¤Ç¤¢¤ë¡£
+\fBmkostemp\fP() と \fBmkostemps\fP(): glibc による拡張。
+.SH 注意
+glibc バージョン 2.06 以前では、ファイルは許可モード 0666 で作成され、全てのユーザーが読み書き可能であった。この古い動作は、
+セキュリティ上のリスクになり得る。特に、他の UNIX では許可モードとして 0600
+を使うため、プログラムを移植する際、この細かな違いを見落とす可能性があるからだ。 POSIX.1\-2008 では、ファイルを許可モード 0600
+で作成することが必須要件として追加された。
 
-.\"O The prototype for
-.\"O .BR mktemp ()
-.\"O is in
-.\"O .I <unistd.h>
-.\"O for libc4, libc5, glibc1; glibc2 follows POSIX.1 and has the prototype in
-.\"O .IR <stdlib.h> .
-.BR mktemp ()
-¤Î¥×¥í¥È¥¿¥¤¥×Àë¸À¤Ï¡¢libc4, libc5, glibc1 ¤Ç¤Ï
-.I <unistd.h>
-¤Ë´Þ¤Þ¤ì¤ë; glibc2 ¤Ç¤Ï POSIX.1 ¤Ë½àµò¤·
-.I <stdlib.h>
-¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë¡£
-.\"O .SH "SEE ALSO"
-.SH ´ØÏ¢¹àÌÜ
-.BR mkdtemp (3),
-.BR mktemp (3),
-.BR tempnam (3),
-.BR tmpfile (3),
-.BR tmpnam (3)
+.\"
+.\" The prototype for
+.\" .BR mktemp ()
+.\" is in
+.\" .I <unistd.h>
+.\" for libc4, libc5, glibc1; glibc2 follows POSIX.1 and has the prototype in
+.\" .IR <stdlib.h> .
+より一般的には、 \fBmkstemp\fP()  の POSIX 規定ではファイルモードについて何も述べていない。 従って、アプリケーションは
+\fBmkstemp\fP()  (や \fBmkostemp\fP())  を呼び出す前にファイルモード生成マスク (\fBumask\fP(2)  参照)
+が適切に設定されているか確認するべきである。
+.SH 関連項目
+\fBmkdtemp\fP(3), \fBmktemp\fP(3), \fBtempnam\fP(3), \fBtmpfile\fP(3), \fBtmpnam\fP(3)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。