1 .\" Copyright (c) 1999 Andries Brouwer (aeb@cwi.nl)
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" Japanese Version Copyright (c) 1997-2000 Kazuyuki Tanisako and NAKANO Takeo
24 .\" all rights reserved.
25 .\" Translated 1997-05-17, Kazuyuki Tanisako <tanisako@osa.dec-j.co.jp>
26 .\" Modified 1997-05-27, Kazuyuki Tanisako <tanisako@osa.dec-j.co.jp>
27 .\" Modified 1998-02-04, Kazuyuki Tanisako <tanisako@osa.dec-j.co.jp>
28 .\" Updated and Modified 2000-10-12, NAKANO Takeo <nakano@apm.seikei.ac.jp>
29 .\" Updated 2006-04-14, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.29
30 .\" Updated 2006-07-26, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.36
32 .\"WORD: temporary file ¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë
33 .\"WORD: filename ¥Õ¥¡¥¤¥ë̾
34 .\"WORD: function ´Ø¿ô
35 .\"WORD: directory ¥Ç¥£¥ì¥¯¥È¥ê
36 .\"WORD: environment variable ´Ä¶ÊÑ¿ô
37 .\"WORD: argument °ú¤¿ô
38 .\"WORD: storage ÊݸÎΰè
39 .\"WORD: pointer ¥Ý¥¤¥ó¥¿¡¼
41 .TH TEMPNAM 3 2008-08-06 "" "Linux Programmer's Manual"
44 .\"O tempnam \- create a name for a temporary file
45 tempnam \- ¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë¤Î̾Á°¤òºîÀ®¤¹¤ë
51 .BI "char *tempnam(const char *" dir ", const char *" pfx );
55 .\"O Feature Test Macro Requirements for glibc (see
56 .\"O .BR feature_test_macros (7)):
57 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
58 .RB ( feature_test_macros (7)
63 _BSD_SOURCE || _SVID_SOURCE
68 .\"O function returns a pointer to a string that is a valid filename,
69 .\"O and such that a file with this name did not exist when
72 .\"O The filename suffix of the pathname generated will start with
76 .\"O is a non-NULL string of at most five bytes.
77 .\"O The directory prefix part of the pathname generated is required to
78 .\"O be "appropriate" (often that at least implies writable).
80 ´Ø¿ô¤Ï¥Õ¥¡¥¤¥ë̾¤È¤·¤ÆÀµ¤·¤¤Ê¸»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿¡¼¤òÊÖ¤¹¡£
81 ¤³¤Î¥Õ¥¡¥¤¥ë̾¤ò»ý¤Ä¥Õ¥¡¥¤¥ë¤Ï¡¢
83 ¤¬¥Á¥§¥Ã¥¯¤·¤¿»þÅÀ¤Ë¤ª¤¤¤Æ¤Ï¸ºß¤·¤Ê¤¤ (¤·¤Ê¤«¤Ã¤¿)¡£
85 ¤¬ NULL ¤Ç¤Ê¤¤ 5 ¥Ð¥¤¥È°ÊÆâ¤Îʸ»úÎó¤Ç¤¢¤ì¤Ð¡¢
86 À¸À®¤µ¤ì¤ë¥Ñ¥¹Ì¾¤Î¤¦¤Á¤Î¥Õ¥¡¥¤¥ë̾¤ÎÉôʬ¤Ï
88 ¤«¤é»Ï¤Þ¤ë¤â¤Î¤Ë¤Ê¤ë¡£
89 À¸À®¤µ¤ì¤ë¥Ç¥£¥ì¥¯¥È¥ê¤ÎÉôʬ¤Ï¡¢¡ÖŬÀڡפǤʤ±¤ì¤Ð¤Ê¤é¤Ê¤¤
90 (ÂçÄñ¤Î¾ì¹ç¡¢¡ÖŬÀڡפǤ¢¤ë¤¿¤á¤Ë¤Ï¤Þ¤º¾¯¤Ê¤¯¤È¤â
91 ½ñ¤¹þ¤ß²Äǽ¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤)¡£
93 .\"O Attempts to find an appropriate directory go through the following
95 ŬÀڤʥǥ£¥ì¥¯¥È¥ê¤Îõº÷¤Ï¡¢°Ê²¼¤Î¼ê½ç¤Ë¤·¤¿¤¬¤Ã¤Æ¹Ô¤ï¤ì¤ë¡£
98 .\"O In case the environment variable
101 .\"O contains the name of an appropriate directory, that is used.
105 ¤½¤ÎÆâÍƤ¬Å¬Àڤʥǥ£¥ì¥¯¥È¥ê¤Î̾Á°¤Ê¤é¡¢¤½¤ì¤òÍѤ¤¤ë¡£
108 .\"O Otherwise, if the
110 .\"O argument is non-NULL and appropriate, it is used.
113 °ú¤¿ô¤¬ NULL ¤Ç¤Ê¤¤Ê¸»úÎó¤Ç¤«¤ÄŬÀڤʤ顢¤½¤ì¤òÍѤ¤¤ë¡£
120 .\"O is used when appropriate.
125 ¤¬Å¬Àڤʤ顢¤½¤ì¤òÍѤ¤¤ë¡£
128 .\"O Finally an implementation-defined directory may be used.
129 ºÇ¸å¤Ë¼ÂÁõ¤ÇÄêµÁ¤µ¤ì¤¿¥Ç¥£¥ì¥¯¥È¥ê¤¬ÍѤ¤¤é¤ì¤ë¤³¤È¤Ë¤Ê¤ë¡£
131 .\"O The string returned by
133 .\"O is allocated using
135 .\"O and hence should be freed by
140 ¤ò»È¤Ã¤Æ³ÎÊݤµ¤ì¤ë¡£¤½¤Î¤¿¤á¡¢
143 .\"O .SH "RETURN VALUE"
147 .\"O function returns a pointer to a unique temporary
148 .\"O filename, or NULL if a unique name cannot be generated.
150 ´Ø¿ô¤Ï¾¤È½Å¤Ê¤é¤Ê¤¤¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë̾¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£
151 ¾¤È½Å¤Ê¤é¤Ê¤¤Ì¾Á°¤¬À¸À®¤Ç¤¤Ê¤±¤ì¤Ð NULL ¤òÊÖ¤¹¡£
156 .\"O Allocation of storage failed.
157 ÊݸÎΰè¤Î³ä¤êÅö¤Æ¤Ë¼ºÇÔ¤·¤¿¡£
158 .\"O .SH "CONFORMING TO"
160 SVr4, 4.3BSD, POSIX.1-2001.
161 .\"O POSIX.1-2008 marks
166 ¤òÇÑ»ßͽÄê¤È¤·¤Æ¤¤¤ë¡£
171 .\"O generates names that are difficult to guess,
172 .\"O it is nevertheless possible that between the time that
174 .\"O returns a pathname, and the time that the program opens it,
175 .\"O another program might create that pathname using
177 .\"O or create it as a symbolic link.
178 .\"O This can lead to security holes.
179 .\"O To avoid such possibilities, use the
182 .\"O flag to open the pathname.
183 .\"O Or better yet, use
186 .\"O .BR tmpfile (3).
188 ¤Ï¿ä¬¤¬Æñ¤·¤¤Ì¾Á°¤òÀ¸À®¤¹¤ë¤¬¡¢¤½¤ì¤Ë¤â¤«¤«¤ï¤é¤º¡¢
190 ¤¬¥Ñ¥¹Ì¾¤òÊÖ¤·¤Æ¤«¤é¡¢¥×¥í¥°¥é¥à¤¬¤½¤Î¥Õ¥¡¥¤¥ë¤ò¥ª¡¼¥×¥ó¤¹¤ë
191 ¤Þ¤Ç¤Î´Ö¤Ë¡¢ÊÌ¤Î¥×¥í¥°¥é¥à¤¬Æ±¤¸¥Ñ¥¹Ì¾¤Ç¡¢¥Õ¥¡¥¤¥ë¤ò
193 ¤ÇºîÀ®¤·¤¿¤ê¡¢¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤òºîÀ®¤·¤¿¤ê¤¹¤ë²ÄǽÀ¤¬¤¢¤ë¡£
194 ¤³¤ì¤Ï¥»¥¥å¥ê¥Æ¥£¥Û¡¼¥ë¤Ë¤Ä¤Ê¤¬¤ë²ÄǽÀ¤¬¤¢¤ë¡£
195 ¤½¤Î¤è¤¦¤Ê²ÄǽÀ¤ò²óÈò¤¹¤ë¤¿¤á¤Ë¤Ï¡¢
199 ¥Õ¥é¥°¤ò»È¤Ã¤Æ¥Ñ¥¹Ì¾¤ò¥ª¡¼¥×¥ó¤¹¤ì¤Ð¤è¤¤¡£
206 .\"O SUSv2 does not mention the use of
208 .\"O glibc will use it only
209 .\"O when the program is not set-user-ID.
210 .\"O On SVr4, the directory used under \fBd)\fP is
212 .\"O (and this is what glibc does).
215 ¤ËÉÕ¤¤¤Æ¸ÀµÚ¤µ¤ì¤Æ¤¤¤Ê¤¤¡£
216 glibc ¤Ï¡¢¥×¥í¥°¥é¥à¤¬ set-user-ID ¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ë¸Â¤Ã¤Æ¤³¤ì¤òÍѤ¤¤ë¡£
217 SVr4 ¤Ç¤Ï \fBd)\fP ¤Ç»ÈÍѤµ¤ì¤ë¥Ç¥£¥ì¥¯¥È¥ê¤ò
219 ¤ÈÄê¤á¤Æ¤¤¤ë (glibc ¤â¤³¤ÎÄ̤ê¤Ç¤¢¤ë)¡£
221 .\"O Because it dynamically allocates memory used to return the pathname,
223 .\"O is reentrant, and thus thread safe, unlike
225 ¥Ñ¥¹Ì¾¤òÊÖ¤¹¤Î¤Ë»ÈÍѤ¹¤ë¥á¥â¥ê¤òưŪ¤Ë³ÎÊݤ¹¤ë¤Î¤Ç¡¢
229 ¤Ï¥ê¥¨¥ó¥È¥é¥ó¥È¤Ç¤¢¤ê¡¢¥¹¥ì¥Ã¥É¥»¡¼¥Õ¤Ç¤¢¤ë¡£
233 .\"O function generates a different string each time it is called,
239 .\"O If it is called more than
242 .\"O the behavior is implementation defined.
246 ²ó¤Þ¤Ç¡¢¸Æ¤Ó½Ð¤µ¤ì¤ëÅ٤˰ۤʤëʸ»úÎó¤òºîÀ®¤¹¤ë
253 ²ó°Ê¾å¸Æ¤Ó½Ð¤µ¤ì¤¿¾ì¹ç¡¢Æ°ºî¤Ï¼ÂÁõ°Í¸¤Ç¤¢¤ë¡£
256 .\"O uses at most the first five bytes from
261 ¤ÎÀèƬ 5 ¥Ð¥¤¥È¤ò»ÈÍѤ¹¤ë¡£
263 .\"O The glibc implementation of
265 .\"O will fail with the error
267 .\"O upon failure to find a unique name.
268 ¾¤È½Å¤Ê¤é¤Ê¤¤Ì¾Á°¤¬¸«¤Ä¤±¤é¤ì¤Ê¤«¤Ã¤¿¾ì¹ç¡¢glibc ¤Î
275 .\"O The precise meaning of "appropriate" is undefined;
276 .\"O it is unspecified how accessibility of a directory is determined.
277 ¡ÖŬÀڡפȤ¤¤¦¸ÀÍÕ¤ÎÀµ³Î¤Ê°ÕÌ£¤ÏÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤¤¡£
278 ¥Ç¥£¥ì¥¯¥È¥ê¤ËÂФ·¤Æ¤É¤ÎÄøÅ٤Υ¢¥¯¥»¥¹¸¢¸Â¤¬É¬ÍפʤΤ«¤Ï»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¡£
280 .\"O Never use this function.
286 ·è¤·¤Æ¤³¤Î´Ø¿ô¤ò»È¤Ã¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£Âå¤ï¤ê¤Ë