X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=draft%2Fman3%2Ftempnam.3;h=8b2421676dd764ba711635fc6bc375121eb1e0bc;hb=1d98b26905be2ad5ba08a94d65f57d872bae4f85;hp=b1423f56f620c91b30a2eea3da98dcd91e25bc63;hpb=633a2252e0be3c867dce264a180a89ce8181d36f;p=linuxjm%2FLDP_man-pages.git diff --git a/draft/man3/tempnam.3 b/draft/man3/tempnam.3 index b1423f56..8b242167 100644 --- a/draft/man3/tempnam.3 +++ b/draft/man3/tempnam.3 @@ -20,277 +20,78 @@ .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" -.\" Japanese Version Copyright (c) 1997-2000 Kazuyuki Tanisako and NAKANO Takeo -.\" all rights reserved. -.\" Translated 1997-05-17, Kazuyuki Tanisako -.\" Modified 1997-05-27, Kazuyuki Tanisako -.\" Modified 1998-02-04, Kazuyuki Tanisako -.\" Updated and Modified 2000-10-12, NAKANO Takeo -.\" Updated 2006-04-14, Akihiro MOTOKI , LDP v2.29 -.\" Updated 2006-07-26, Akihiro MOTOKI , LDP v2.36 +.\"******************************************************************* .\" -.\"WORD: temporary file ¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë -.\"WORD: filename ¥Õ¥¡¥¤¥ë̾ -.\"WORD: function ´Ø¿ô -.\"WORD: directory ¥Ç¥£¥ì¥¯¥È¥ê -.\"WORD: environment variable ´Ä¶­ÊÑ¿ô -.\"WORD: argument °ú¤­¿ô -.\"WORD: storage ÊݸÎΰè -.\"WORD: pointer ¥Ý¥¤¥ó¥¿¡¼ +.\" This file was generated with po4a. Translate the source file. .\" -.TH TEMPNAM 3 2008-08-06 "" "Linux Programmer's Manual" -.\"O .SH NAME -.SH ̾Á° -.\"O tempnam \- create a name for a temporary file -tempnam \- ¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë¤Î̾Á°¤òºîÀ®¤¹¤ë -.\"O .SH SYNOPSIS -.SH ½ñ¼° +.\"******************************************************************* +.TH TEMPNAM 3 2008\-08\-06 "" "Linux Programmer's Manual" +.SH 名前 +tempnam \- テンポラリファイルの名前を作成する +.SH 書式 .nf -.B #include +\fB#include \fP .sp -.BI "char *tempnam(const char *" dir ", const char *" pfx ); +\fBchar *tempnam(const char *\fP\fIdir\fP\fB, const char *\fP\fIpfx\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 tempnam (): -_BSD_SOURCE || _SVID_SOURCE -.\"O .SH DESCRIPTION -.SH ÀâÌÀ -.\"O The -.\"O .BR tempnam () -.\"O function returns a pointer to a string that is a valid filename, -.\"O and such that a file with this name did not exist when -.\"O .BR tempnam () -.\"O checked. -.\"O The filename suffix of the pathname generated will start with -.\"O .I pfx -.\"O in case -.\"O .I pfx -.\"O is a non-NULL string of at most five bytes. -.\"O The directory prefix part of the pathname generated is required to -.\"O be "appropriate" (often that at least implies writable). -.BR tempnam () -´Ø¿ô¤Ï¥Õ¥¡¥¤¥ë̾¤È¤·¤ÆÀµ¤·¤¤Ê¸»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿¡¼¤òÊÖ¤¹¡£ -¤³¤Î¥Õ¥¡¥¤¥ë̾¤ò»ý¤Ä¥Õ¥¡¥¤¥ë¤Ï¡¢ -.BR tempnam () -¤¬¥Á¥§¥Ã¥¯¤·¤¿»þÅÀ¤Ë¤ª¤¤¤Æ¤Ï¸ºß¤·¤Ê¤¤ (¤·¤Ê¤«¤Ã¤¿)¡£ -.I pfx -¤¬ NULL ¤Ç¤Ê¤¤ 5 ¥Ð¥¤¥È°ÊÆâ¤Îʸ»úÎó¤Ç¤¢¤ì¤Ð¡¢ -À¸À®¤µ¤ì¤ë¥Ñ¥¹Ì¾¤Î¤¦¤Á¤Î¥Õ¥¡¥¤¥ë̾¤ÎÉôʬ¤Ï -.I pfx -¤«¤é»Ï¤Þ¤ë¤â¤Î¤Ë¤Ê¤ë¡£ -À¸À®¤µ¤ì¤ë¥Ç¥£¥ì¥¯¥È¥ê¤ÎÉôʬ¤Ï¡¢¡ÖŬÀڡפǤʤ±¤ì¤Ð¤Ê¤é¤Ê¤¤ -(ÂçÄñ¤Î¾ì¹ç¡¢¡ÖŬÀڡפǤ¢¤ë¤¿¤á¤Ë¤Ï¤Þ¤º¾¯¤Ê¤¯¤È¤â -½ñ¤­¹þ¤ß²Äǽ¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤)¡£ +\fBtempnam\fP(): _BSD_SOURCE || _SVID_SOURCE +.SH 説明 +\fBtempnam\fP() 関数はファイル名として正しい文字列へのポインターを返す。 このファイル名を持つファイルは、 \fBtempnam\fP() +がチェックした時点においては存在しない (しなかった)。 \fIpfx\fP が NULL でない 5 バイト以内の文字列であれば、 +生成されるパス名のうちのファイル名の部分は \fIpfx\fP から始まるものになる。 生成されるディレクトリの部分は、「適切」でなければならない +(大抵の場合、「適切」であるためにはまず少なくとも 書き込み可能でなければならない)。 -.\"O Attempts to find an appropriate directory go through the following -.\"O steps: -ŬÀڤʥǥ£¥ì¥¯¥È¥ê¤Îõº÷¤Ï¡¢°Ê²¼¤Î¼ê½ç¤Ë¤·¤¿¤¬¤Ã¤Æ¹Ô¤ï¤ì¤ë¡£ -.TP 3 +適切なディレクトリの探索は、以下の手順にしたがって行われる。 +.TP 3 a) -.\"O In case the environment variable -.\"O .B TMPDIR -.\"O exists and -.\"O contains the name of an appropriate directory, that is used. -´Ä¶­ÊÑ¿ô -.B TMPDIR -¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Æ¡¢ -¤½¤ÎÆâÍƤ¬Å¬Àڤʥǥ£¥ì¥¯¥È¥ê¤Î̾Á°¤Ê¤é¡¢¤½¤ì¤òÍѤ¤¤ë¡£ -.TP +環境変数 \fBTMPDIR\fP が設定されていて、 その内容が適切なディレクトリの名前なら、それを用いる。 +.TP b) -.\"O Otherwise, if the -.\"O .I dir -.\"O argument is non-NULL and appropriate, it is used. -¤½¤ì°Ê³°¤Î¾ì¹ç¡¢ -.I dir -°ú¤­¿ô¤¬ NULL ¤Ç¤Ê¤¤Ê¸»úÎó¤Ç¤«¤ÄŬÀڤʤ顢¤½¤ì¤òÍѤ¤¤ë¡£ -.TP +それ以外の場合、 \fIdir\fP 引き数が NULL でない文字列でかつ適切なら、それを用いる。 +.TP c) -.\"O Otherwise, -.\"O .I P_tmpdir -.\"O (as defined in -.\"O .IR ) -.\"O is used when appropriate. -¤½¤ì°Ê³°¤Î¾ì¹ç¡¢ -.RI ( -¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤ë) -.I P_tmpdir -¤¬Å¬Àڤʤ顢¤½¤ì¤òÍѤ¤¤ë¡£ -.TP +それ以外の場合、 (\fI\fP で定義されている) \fIP_tmpdir\fP が適切なら、それを用いる。 +.TP d) -.\"O Finally an implementation-defined directory may be used. -ºÇ¸å¤Ë¼ÂÁõ¤ÇÄêµÁ¤µ¤ì¤¿¥Ç¥£¥ì¥¯¥È¥ê¤¬ÍѤ¤¤é¤ì¤ë¤³¤È¤Ë¤Ê¤ë¡£ +最後に実装で定義されたディレクトリが用いられることになる。 .PP -.\"O The string returned by -.\"O .BR tempnam () -.\"O is allocated using -.\"O .BR malloc (3) -.\"O and hence should be freed by -.\"O .BR free (3). -.BR tempnam () -¤¬ÊÖ¤¹Ê¸»úÎó¤Ï -.BR malloc (3) -¤ò»È¤Ã¤Æ³ÎÊݤµ¤ì¤ë¡£¤½¤Î¤¿¤á¡¢ -.BR free (3) -¤Ç²òÊü¤¹¤Ù¤­¤Ç¤¢¤ë¡£ -.\"O .SH "RETURN VALUE" -.SH ÊÖ¤êÃÍ -.\"O The -.\"O .BR tempnam () -.\"O function returns a pointer to a unique temporary -.\"O filename, or NULL if a unique name cannot be generated. -.BR tempnam () -´Ø¿ô¤Ï¾¤È½Å¤Ê¤é¤Ê¤¤¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë̾¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£ -¾¤È½Å¤Ê¤é¤Ê¤¤Ì¾Á°¤¬À¸À®¤Ç¤­¤Ê¤±¤ì¤Ð NULL ¤òÊÖ¤¹¡£ -.\"O .SH ERRORS -.SH ¥¨¥é¡¼ -.TP -.B ENOMEM -.\"O Allocation of storage failed. -ÊݸÎΰè¤Î³ä¤êÅö¤Æ¤Ë¼ºÇÔ¤·¤¿¡£ -.\"O .SH "CONFORMING TO" -.SH ½àµò -SVr4, 4.3BSD, POSIX.1-2001. -.\"O POSIX.1-2008 marks -.\"O .BR tempnam () -.\"O as obsolete. -POSIX.1-2008 ¤Ï -.BR tempnam () -¤òÇÑ»ßͽÄê¤È¤·¤Æ¤¤¤ë¡£ -.\"O .SH NOTES -.SH Ãí°Õ -.\"O Although -.\"O .BR tempnam () -.\"O generates names that are difficult to guess, -.\"O it is nevertheless possible that between the time that -.\"O .BR tempnam () -.\"O returns a pathname, and the time that the program opens it, -.\"O another program might create that pathname using -.\"O .BR open (2), -.\"O or create it as a symbolic link. -.\"O This can lead to security holes. -.\"O To avoid such possibilities, use the -.\"O .BR open (2) -.\"O .B O_EXCL -.\"O flag to open the pathname. -.\"O Or better yet, use -.\"O .BR mkstemp (3) -.\"O or -.\"O .BR tmpfile (3). -.BR tempnam () -¤Ï¿ä¬¤¬Æñ¤·¤¤Ì¾Á°¤òÀ¸À®¤¹¤ë¤¬¡¢¤½¤ì¤Ë¤â¤«¤«¤ï¤é¤º¡¢ -.BR tempnam () -¤¬¥Ñ¥¹Ì¾¤òÊÖ¤·¤Æ¤«¤é¡¢¥×¥í¥°¥é¥à¤¬¤½¤Î¥Õ¥¡¥¤¥ë¤ò¥ª¡¼¥×¥ó¤¹¤ë -¤Þ¤Ç¤Î´Ö¤Ë¡¢ÊÌ¤Î¥×¥í¥°¥é¥à¤¬Æ±¤¸¥Ñ¥¹Ì¾¤Ç¡¢¥Õ¥¡¥¤¥ë¤ò -.BR open (2) -¤ÇºîÀ®¤·¤¿¤ê¡¢¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤òºîÀ®¤·¤¿¤ê¤¹¤ë²ÄǽÀ­¤¬¤¢¤ë¡£ -¤³¤ì¤Ï¥»¥­¥å¥ê¥Æ¥£¥Û¡¼¥ë¤Ë¤Ä¤Ê¤¬¤ë²ÄǽÀ­¤¬¤¢¤ë¡£ -¤½¤Î¤è¤¦¤Ê²ÄǽÀ­¤ò²óÈò¤¹¤ë¤¿¤á¤Ë¤Ï¡¢ -.BR open (2) -¤Î -.B O_EXCL -¥Õ¥é¥°¤ò»È¤Ã¤Æ¥Ñ¥¹Ì¾¤ò¥ª¡¼¥×¥ó¤¹¤ì¤Ð¤è¤¤¡£ -¤â¤Ã¤È¤¤¤¤¤Î¤Ï¡¢ -.BR mkstemp (3) -¤ä -.BR tmpfile (3) -¤ò»È¤¦¤³¤È¤Ç¤¢¤ë¡£ +\fBtempnam\fP() が返す文字列は \fBmalloc\fP(3) を使って確保される。そのため、 \fBfree\fP(3) で解放すべきである。 +.SH 返り値 +\fBtempnam\fP() 関数は他と重ならないテンポラリファイル名へのポインタを返す。 他と重ならない名前が生成できなければ NULL を返す。 +.SH エラー +.TP +\fBENOMEM\fP +保存領域の割り当てに失敗した。 +.SH 準拠 +SVr4, 4.3BSD, POSIX.1\-2001. POSIX.1\-2008 は \fBtempnam\fP() を廃止予定としている。 +.SH 注意 +\fBtempnam\fP() は推測が難しい名前を生成するが、それにもかかわらず、 \fBtempnam\fP() +がパス名を返してから、プログラムがそのファイルをオープンする までの間に、別のプログラムが同じパス名で、ファイルを \fBopen\fP(2) +で作成したり、シンボリックリンクを作成したりする可能性がある。 これはセキュリティホールにつながる可能性がある。 そのような可能性を回避するためには、 +\fBopen\fP(2) の \fBO_EXCL\fP フラグを使ってパス名をオープンすればよい。 もっといいのは、 \fBmkstemp\fP(3) や +\fBtmpfile\fP(3) を使うことである。 -.\"O SUSv2 does not mention the use of -.\"O .BR TMPDIR ; -.\"O glibc will use it only -.\"O when the program is not set-user-ID. -.\"O On SVr4, the directory used under \fBd)\fP is -.\"O .I /tmp -.\"O (and this is what glibc does). -SUSv2 ¤Ç¤Ï -.B TMPDIR -¤ËÉÕ¤¤¤Æ¸ÀµÚ¤µ¤ì¤Æ¤¤¤Ê¤¤¡£ -glibc ¤Ï¡¢¥×¥í¥°¥é¥à¤¬ set-user-ID ¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ë¸Â¤Ã¤Æ¤³¤ì¤òÍѤ¤¤ë¡£ -SVr4 ¤Ç¤Ï \fBd)\fP ¤Ç»ÈÍѤµ¤ì¤ë¥Ç¥£¥ì¥¯¥È¥ê¤ò -.I /tmp -¤ÈÄê¤á¤Æ¤¤¤ë (glibc ¤â¤³¤ÎÄ̤ê¤Ç¤¢¤ë)¡£ +SUSv2 では \fBTMPDIR\fP に付いて言及されていない。 glibc は、プログラムが set\-user\-ID +されていない場合に限ってこれを用いる。 SVr4 では \fBd)\fP で使用されるディレクトリを \fI/tmp\fP と定めている (glibc +もこの通りである)。 .LP -.\"O Because it dynamically allocates memory used to return the pathname, -.\"O .BR tempnam () -.\"O is reentrant, and thus thread safe, unlike -.\"O .BR tmpnam (3). -¥Ñ¥¹Ì¾¤òÊÖ¤¹¤Î¤Ë»ÈÍѤ¹¤ë¥á¥â¥ê¤òưŪ¤Ë³ÎÊݤ¹¤ë¤Î¤Ç¡¢ -.BR tmpnam (3) -¤È°ã¤¤¡¢ -.BR tempnam () -¤Ï¥ê¥¨¥ó¥È¥é¥ó¥È¤Ç¤¢¤ê¡¢¥¹¥ì¥Ã¥É¥»¡¼¥Õ¤Ç¤¢¤ë¡£ +パス名を返すのに使用するメモリを動的に確保するので、 \fBtmpnam\fP(3) と違い、 \fBtempnam\fP() +はリエントラントであり、スレッドセーフである。 .LP -.\"O The -.\"O .BR tempnam () -.\"O function generates a different string each time it is called, -.\"O up to -.\"O .B TMP_MAX -.\"O (defined in -.\"O .IR ) -.\"O times. -.\"O If it is called more than -.\"O .B TMP_MAX -.\"O times, -.\"O the behavior is implementation defined. -.BR tempnam () -´Ø¿ô¤ÏºÇÂç -.B TMP_MAX -²ó¤Þ¤Ç¡¢¸Æ¤Ó½Ð¤µ¤ì¤ëÅ٤˰ۤʤëʸ»úÎó¤òºîÀ®¤¹¤ë -.RB ( TMP_MAX -¤Ï -.I -¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤ë)¡£ -¤â¤· -.B TMP_MAX -²ó°Ê¾å¸Æ¤Ó½Ð¤µ¤ì¤¿¾ì¹ç¡¢Æ°ºî¤Ï¼ÂÁõ°Í¸¤Ç¤¢¤ë¡£ +\fBtempnam\fP() 関数は最大 \fBTMP_MAX\fP 回まで、呼び出される度に異なる文字列を作成する (\fBTMP_MAX\fP は +\fI\fP で定義されている)。 もし \fBTMP_MAX\fP 回以上呼び出された場合、動作は実装依存である。 .LP -.\"O .BR tempnam () -.\"O uses at most the first five bytes from -.\"O .IR pfx . -.BR tempnam () -¤ÏºÇÂç¤Ç -.I pfx -¤ÎÀèƬ 5 ¥Ð¥¤¥È¤ò»ÈÍѤ¹¤ë¡£ +\fBtempnam\fP() は最大で \fIpfx\fP の先頭 5 バイトを使用する。 -.\"O The glibc implementation of -.\"O .BR tempnam () -.\"O will fail with the error -.\"O .B EEXIST -.\"O upon failure to find a unique name. -¾¤È½Å¤Ê¤é¤Ê¤¤Ì¾Á°¤¬¸«¤Ä¤±¤é¤ì¤Ê¤«¤Ã¤¿¾ì¹ç¡¢glibc ¤Î -.BR tempnam () -¤Î¼ÂÁõ¤Ï¥¨¥é¡¼ -.B EEXIST -¤Ç¼ºÇÔ¤¹¤ë¡£ -.\"O .SH BUGS -.SH ¥Ð¥° -.\"O The precise meaning of "appropriate" is undefined; -.\"O it is unspecified how accessibility of a directory is determined. -¡ÖŬÀڡפȤ¤¤¦¸ÀÍÕ¤ÎÀµ³Î¤Ê°ÕÌ£¤ÏÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤¤¡£ -¥Ç¥£¥ì¥¯¥È¥ê¤ËÂФ·¤Æ¤É¤ÎÄøÅ٤Υ¢¥¯¥»¥¹¸¢¸Â¤¬É¬ÍפʤΤ«¤Ï»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¡£ +他と重ならない名前が見つけられなかった場合、glibc の \fBtempnam\fP() の実装はエラー \fBEEXIST\fP で失敗する。 +.SH バグ +「適切」という言葉の正確な意味は定義されていない。 ディレクトリに対してどの程度のアクセス権限が必要なのかは指定されていない。 -.\"O Never use this function. -.\"O Use -.\"O .BR mkstemp (3) -.\"O or -.\"O .BR tmpfile (3) -.\"O instead. -·è¤·¤Æ¤³¤Î´Ø¿ô¤ò»È¤Ã¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£Âå¤ï¤ê¤Ë -.BR mkstemp (3) -¤« -.BR tmpfile (3) -¤ò»È¤¦¤³¤È¡£ -.\"O .SH "SEE ALSO" -.SH ´ØÏ¢¹àÌÜ -.BR mkstemp (3), -.BR mktemp (3), -.BR tmpfile (3), -.BR tmpnam (3) +決してこの関数を使ってはならない。代わりに \fBmkstemp\fP(3) か \fBtmpfile\fP(3) を使うこと。 +.SH 関連項目 +\fBmkstemp\fP(3), \fBmktemp\fP(3), \fBtmpfile\fP(3), \fBtmpnam\fP(3)