.\" Copyright (c) 1999 Andries Brouwer (aeb@cwi.nl) .\" .\" %%%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. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\" 2003-11-15, aeb, added tmpnam_r .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright 1997 Tenkou N. Hattori .\" Japanese Version Copyright (c) 1997 Tenkou N. Hattori .\" all rights reserved. .\" Translated 1997-01-18, Tenkou N. Hattori .\" Updated 2000-03-15, Kentaro Shirakata .\" Updated 2005-03-15, Akihiro MOTOKI .\" Updated 2006-07-26, Akihiro MOTOKI , LDP v2.36 .\" .TH TMPNAM 3 2017\-09\-15 "" "Linux Programmer's Manual" .SH 名前 tmpnam, tmpnam_r \- 一時ファイルの名前を作成する .SH 書式 .nf \fB#include \fP .PP \fBchar *tmpnam(char *\fP\fIs\fP\fB);\fP \fBchar *tmpnam_r(char *\fP\fIs\fP\fB);\fP .fi .PP .RS -4 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .RE .PP \fBtmpnam_r\fP() .PD 0 .ad l .RS 4 .TP 4 glibc 2.19 以降: _DEFAULT_SOURCE .TP Up to and including glibc 2.19: _BSD_SOURCE || _SVID_SOURCE .RE .ad .PD .SH 説明 \fB注意:\fP これらの関数の使用は避けること。代わりに \fBmkstemp\fP(3) か \fBtmpfile\fP(3) を使うこと。 .PP \fBtmpnam\fP() 関数は、ファイル名に使える文字列へのポインターを返す。 ある時点では同じ名前を持つファイルが存在しないファイル名が返されるので、 幼稚なプログラマはこの文字列が一時ファイルのファイル名として 適していると考えるかもしれない。 引数 \fIs\fP が NULL なら、この名前は内部の静的バッファーに作成され、 次に \fBtmpnam\fP() 関数が呼び出された時に上書きされる。 \fIs\fP が NULL でなければ、ファイル名は \fIs\fP が指す (少なくとも \fIL_tmpnam\fP の長さを持つ) 文字配列にコピーされ、 成功した場合は \fIs\fP が返される。 .PP 作成されるパス名は、ディレクトリの部分に \fIP_tmpdir\fP が使われる。 (\fIL_tmpnam\fP と \fIP_tmpdir\fP は、以下で説明する \fBTMP_MAX\fP 同様 \fI\fP で定義されている。) .PP The \fBtmpnam_r\fP() function performs the same task as \fBtmpnam\fP(), but returns NULL (to indicate an error) if \fIs\fP is NULL. .SH 返り値 これらの関数は一意な一時ファイル名へのポインターを返す。 一意なファイル名が作成できなかった場合は NULL を返す。 .SH エラー エラーは定義されていない。 .SH 属性 この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。 .TS allbox; lb lb lb l l l. インターフェース 属性 値 T{ \fBtmpnam\fP() T} Thread safety MT\-Unsafe race:tmpnam/!s T{ \fBtmpnam_r\fP() T} Thread safety MT\-Safe .TE .SH 準拠 \fBtmpnam\fP(): SVr4, 4.3BSD, C89, C99, POSIX.1\-2001. POSIX.1\-2008 は \fBtmpnam\fP() を廃止予定としている。 .PP .\" Appears to be on Solaris \fBtmpnam_r\fP() is a nonstandard extension that is also available on a few other systems. .SH 注意 \fBtmpnam\fP() 関数は最大 \fBTMP_MAX\fP 回まで、呼び出される度に異なる文字列を作成する。 \fBTMP_MAX\fP 回以上呼び出された場合、その動作は実装依存である。 .PP これらの関数は推測が難しい名前を生成するが、それにもかかわらず、パス名が返されてから、プログラムがそのファイルをオープンするまでの間に、別のプログラムが同じパス名で、ファイルを \fBopen\fP(2) で作成したり、シンボリックリンクを作成したりする可能性がある。 これはセキュリティホールにつながる可能性がある。 そのような可能性を回避するためには、 \fBopen\fP(2) の \fBO_EXCL\fP フラグを使ってパス名をオープンすればよい。 もっといいのは、 \fBmkstemp\fP(3) や \fBtmpfile\fP(3) を使うことである。 .PP 移植性が必要な、スレッドを使ったアプリケーションでは、 \fB_POSIX_THREADS\fP か \fB_POSIX_THREAD_SAFE_FUNCTIONS\fP が定義されている場合に、 \fBtmpnam\fP() 関数を NULL 引数で呼び出してはならない。 .SH バグ 決してこれらの関数を使用しないこと。代わりに \fBmkstemp\fP(3) か \fBtmpfile\fP(3) を使うこと。 .SH 関連項目 \fBmkstemp\fP(3), \fBmktemp\fP(3), \fBtempnam\fP(3), \fBtmpfile\fP(3) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は \%https://www.kernel.org/doc/man\-pages/ に書かれている。