OSDN Git Service

(split) LDP: Translation snapshots for ja.po.
[linuxjm/LDP_man-pages.git] / draft / man3 / mkstemp.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\" and Copyright (C) 2008, Michael Kerrisk <mtk.manpages@gmail.com>
3 .\"
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\"
24 .\" References consulted:
25 .\"     Linux libc source code
26 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
27 .\"     386BSD man pages
28 .\" Modified Sat Jul 24 18:48:48 1993 by Rik Faith (faith@cs.unc.edu)
29 .\" Modified 980310, aeb
30 .\" Modified 990328, aeb
31 .\" 2008-06-19, mtk, Added mkostemp(); various other changes
32 .\"
33 .\" Japanese Version Copyright (c) 1997 Kazuyuki Tanisako
34 .\"         all rights reserved.
35 .\" Translated 1997-05-17, Kazuyuki Tanisako <tanisako@osa.dec-j.co.jp>
36 .\" Modified 1997-05-27, Kazuyuki Tanisako <tanisako@osa.dec-j.co.jp>
37 .\" Modified 1998-02-05, Kazuyuki Tanisako <tanisako@osa.dec-j.co.jp>
38 .\" Modified 1998-09-27, Kazuyuki Tanisako <tanisako@osa.dec-j.co.jp>
39 .\" Modified 1999-04-10, Kazuyuki Tanisako <tanisako@osa.dec.com>
40 .\" Updated 2001-01-17, Kentaro Shirakata <argrath@ub32.org>
41 .\" Updated 2005-02-26, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
42 .\" Updated 2008-08-10, Akihiro MOTOKI, LDP v3.05
43 .\"
44 .\"WORD:        temporary file  一時ファイル
45 .\"WORD:        read/write      リード/ライト
46 .\"WORD:        permissions     許可
47 .\"
48 .TH MKSTEMP 3  2008-06-19 "GNU" "Linux Programmer's Manual"
49 .\"O .SH NAME
50 .SH 名前
51 .\"O mkstemp, mkostemp \- create a unique temporary file
52 mkstemp, mkostemp \- 他と重ならない名前を持つ一時ファイルを作成する
53 .\"O .SH SYNOPSIS
54 .SH 書式
55 .nf
56 .B #include <stdlib.h>
57 .sp
58 .BI "int mkstemp(char *" template );
59 .sp
60 .BI "int mkostemp (char *" template ", int " flags );
61 .fi
62 .sp
63 .in -4n
64 .\"O Feature Test Macro Requirements for glibc (see
65 .\"O .BR feature_test_macros (7)):
66 glibc 向けの機能検査マクロの要件
67 .RB ( feature_test_macros (7)
68 参照):
69 .in
70 .sp
71 .BR mkstemp ():
72 _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 500
73 .br
74 .BR mkostemp ():
75 _GNU_SOURCE
76 \"O .SH DESCRIPTION
77 .SH 説明
78 .\"O The
79 .\"O .BR mkstemp ()
80 .\"O function generates a unique temporary filename from
81 .\"O .IR template ,
82 .\"O creates and opens the file,
83 .\"O and returns an open file descriptor for the file.
84 関数
85 .BR mkstemp ()
86 は引数
87 .I template
88 から他と重ならない一時ファイル名を生成し、
89 そのファイルの作成とオープンを行い、
90 そのファイルに対するオープン済みのファイルディスクリプタを返す。
91
92 .\"O The last six characters of
93 .\"O .I template
94 .\"O must be "XXXXXX" and these are replaced with a string that makes the
95 .\"O filename unique.
96 引数
97 .I template
98 で指示する文字列の後ろの 6 文字は XXXXXX である必要がある。
99 この部分がファイル名を他と重ならないようにする文字で置き換えられる。
100 .\"O Since it will be modified,
101 .\"O .I template
102 .\"O must not be a string constant, but should be declared as a character array.
103 .I template
104 は書き換えられるため、文字列定数ではなく文字配列として
105 宣言するようにしなければならない。
106
107 .\"O The file is created with
108 .\"O permissions 0600, that is, read plus write for owner only.
109 .\"O (In glibc versions 2.06 and earlier, the file is created with permissions 0666,
110 .\"O that is, read and write for all users.)
111 .\"O The returned file descriptor provides both read and write access to the file.
112 .\"O The file is opened with the
113 .\"O .BR open (2)
114 .\"O .B O_EXCL
115 .\"O flag, guaranteeing that the caller is the process that creates the file.
116 ファイルは許可モード 0600 で作成され、所有者のみが読み書き可能である
117 (glibc バージョン 2.06 以前では、ファイルは許可モード 0666 で作成され、
118 全てのユーザが読み書き可能であった)。
119 返されるファイルディスクリプタで、このファイルへの読み書き両方のアクセスが
120 可能である。
121 呼び出し者がそのファイルを作成するプロセスであることを保証するために、
122 ファイルは
123 .BR open (2)
124
125 .B O_EXCL
126 フラグ付きでオープンされる。
127
128 .\"O .BR mkostemp ()
129 .\"O is like
130 .\"O .BR mkstemp (),
131 .\"O with the difference that flags as for
132 .\"O .BR open (2)
133 .\"O may be specified in
134 .\"O .IR flags
135 .\"O (e.g.,
136 .\"O .BR O_APPEND ,
137 .\"O .BR O_SYNC ).
138 .BR mkostemp ()
139
140 .BR mkstemp ()
141 と同様だが、
142 .BR open (2)
143 に渡されるフラグ
144 .RB O_APPEND ,
145 .B O_SYNC
146 など) を
147 .I flags
148 で指定できる点が異なる
149 .\"O .SH "RETURN VALUE"
150 .SH 返り値
151 .\"O On success, these functions return the file descriptor
152 .\"O of the temporary file.
153 .\"O On error, \-1 is returned, and
154 .\"O .I errno
155 .\"O is set appropriately.
156 成功すると、これらの関数は一時ファイルのファイルディスクリプタを返す。
157 エラーの場合は、\-1 を返し、
158 .I errno
159 を適切に設定する。
160 .\"O .SH ERRORS
161 .SH エラー
162 .TP
163 .B EEXIST
164 .\"O Could not create a unique temporary filename.
165 .\"O Now the contents of \fItemplate\fP are undefined.
166 すでに同じ名前を持つファイルが存在した。
167 \fItemplate\fP の内容は不定である。
168 .TP
169 .B EINVAL
170 .\"O The last six characters of \fItemplate\fP were not XXXXXX.
171 .\"O Now \fItemplate\fP is unchanged.
172 引数 \fItemplate\fP で指示された文字配列の後ろの 6 文字が XXXXXX でない。
173 \fItemplate\fP の内容は変化しない。
174 .PP
175 .\"O These functions may also fail with any of the errors described for
176 .\"O .BR open (2).
177 これらの関数は
178 .BR open (2)
179 に書かわれているエラーのいずれかで失敗することもある。
180 .\"O .SH VERSIONS
181 .SH バージョン
182 .\"O .BR mkostemp ()
183 .\"O is available since glibc 2.7.
184 .BR mkostemp ()
185 は glibc 2.7 以降で利用可能である。
186 .\"O .SH "CONFORMING TO"
187 .SH 準拠
188 .BR mkstemp ():
189 4.3BSD, POSIX.1-2001.
190 .BR mkostemp ():
191 .\"O is a glibc extension.
192 glibc による拡張。
193 .\"O .SH NOTES
194 .SH 注意
195 .\"O The old behavior of creating a file with mode 0666 may be
196 .\"O a security risk, especially since other Unix flavors use 0600,
197 .\"O and somebody might overlook this detail when porting programs.
198 許可モード 0666 でファイルを作成するという古い動作は、
199 セキュリティ上のリスクになる場合がある。
200 特に他の Unix では許可モードとして 0600 を使うため、
201 プログラムを移植する際、この細かな違いを見落とす可能性が
202 あるからだ。
203
204 .\"O More generally, the POSIX specification of
205 .\"O .BR mkstemp ()
206 .\"O does not say anything
207 .\"O about file modes, so the application should make sure its
208 .\"O file mode creation mask (see
209 .\"O .BR umask (2))
210 .\"O is set appropriately before calling
211 .\"O .BR mkstemp ()
212 .\"O (and
213 .\"O .BR mkostemp ()).
214 より一般的には、
215 .BR mkstemp ()
216 の POSIX 規定ではファイルモードについて何も述べていない。
217 従って、アプリケーションは
218 .BR mkstemp ()
219 (や
220 .BR mkostemp ())
221 を呼び出す前にファイルモード生成マスク
222 .RB ( umask (2)
223 参照) が適切に設定されているか確認するべきである。
224
225 .\"O The prototype for
226 .\"O .BR mktemp ()
227 .\"O is in
228 .\"O .I <unistd.h>
229 .\"O for libc4, libc5, glibc1; glibc2 follows POSIX.1 and has the prototype in
230 .\"O .IR <stdlib.h> .
231 .BR mktemp ()
232 のプロトタイプ宣言は、libc4, libc5, glibc1 では
233 .I <unistd.h>
234 に含まれる; glibc2 では POSIX.1 に準拠し
235 .I <stdlib.h>
236 に含まれている。
237 .\"O .SH "SEE ALSO"
238 .SH 関連項目
239 .BR mkdtemp (3),
240 .BR mktemp (3),
241 .BR tempnam (3),
242 .BR tmpfile (3),
243 .BR tmpnam (3)