OSDN Git Service

(split) DP: release pages (catch up to 3.50).
[linuxjm/LDP_man-pages.git] / release / 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 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .\" References consulted:
27 .\"     Linux libc source code
28 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
29 .\"     386BSD man pages
30 .\" Modified Sat Jul 24 18:48:48 1993 by Rik Faith (faith@cs.unc.edu)
31 .\" Modified 980310, aeb
32 .\" Modified 990328, aeb
33 .\" 2008-06-19, mtk, Added mkostemp(); various other changes
34 .\"
35 .\"*******************************************************************
36 .\"
37 .\" This file was generated with po4a. Translate the source file.
38 .\"
39 .\"*******************************************************************
40 .TH MKSTEMP 3 2012\-12\-21 GNU "Linux Programmer's Manual"
41 .SH 名前
42 mkstemp, mkostemp, mkstemps, mkostemps \- 他と重ならない名前を持つ一時ファイルを作成する
43 .SH 書式
44 .nf
45 \fB#include <stdlib.h>\fP
46 .sp
47 \fBint mkstemp(char *\fP\fItemplate\fP\fB);\fP
48 .sp
49 \fBint mkostemp(char *\fP\fItemplate\fP\fB, int \fP\fIflags\fP\fB);\fP
50 .sp
51 \fBint mkstemps(char *\fP\fItemplate\fP\fB, int \fP\fIsuffixlen\fP\fB);\fP
52 .sp
53 \fBint mkostemps(char *\fP\fItemplate\fP\fB, int \fP\fIsuffixlen\fP\fB, int \fP\fIflags\fP\fB);\fP
54 .fi
55 .sp
56 .in -4n
57 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
58 .in
59 .sp
60 \fBmkstemp\fP():
61 .ad l
62 .RS 4
63 .PD 0
64 _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 500 || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
65 .br
66 || /* Since glibc 2.12: */ _POSIX_C_SOURCE\ >=\ 200112L
67 .PD
68 .RE
69 .ad b
70 .PP
71 \fBmkostemp\fP(): _GNU_SOURCE
72 .br
73 \fBmkstemps\fP(): _BSD_SOURCE || _SVID_SOURCE
74 .br
75 \fBmkostemps\fP(): _GNU_SOURCE
76 .SH 説明
77 関数 \fBmkstemp\fP()  は引数 \fItemplate\fP から他と重ならない一時ファイル名を生成し、 そのファイルの作成とオープンを行い、
78 そのファイルに対するオープン済みのファイルディスクリプタを返す。
79
80 引数 \fItemplate\fP で指示する文字列の後ろの 6 文字は XXXXXX である必要がある。
81 この部分がファイル名を他と重ならないようにする文字で置き換えられる。 \fItemplate\fP は書き換えられるため、文字列定数ではなく文字配列として
82 宣言するようにしなければならない。
83
84 The file is created with permissions 0600, that is, read plus write for
85 owner only.  The returned file descriptor provides both read and write
86 access to the file.  The file is opened with the \fBopen\fP(2)  \fBO_EXCL\fP flag,
87 guaranteeing that the caller is the process that creates the file.
88
89 \fBmkostemp\fP() 関数は \fBmkstemp\fP() と同様だが、\fBopen\fP(2) に渡される
90 フラグ O_APPEND\fB,\fP \fBO_SYNC\fP など) を \fIflags\fP で指定できる点が異なる
91
92 \fBmkstemps\fP() 関数は \fBmkstemp\fP() と同様だが、 \fItemplate\fP 内の文字列に長さ
93 が \fIsuffixlen\fP 文字の接尾辞 (suffix) が含まれる点が異なる。
94 したがって、 \fItemplate\fP は \fIprefixXXXXXXsuffix\fP の形式となる。
95 文字列 XXXXXX の部分は \fBmkstemp\fP() により更新される。
96
97 \fBmkostemps\fP() と \fBmkstemps\fP() の関係は、
98 \fBmkostemp\fP() と \fBmkstemp\fP() の関係と同じである。
99 .SH 返り値
100 成功すると、これらの関数は一時ファイルのファイルディスクリプタを返す。 エラーの場合は、\-1 を返し、 \fIerrno\fP を適切に設定する。
101 .SH エラー
102 .TP 
103 \fBEEXIST\fP
104 すでに同じ名前を持つファイルが存在した。 \fItemplate\fP の内容は不定である。
105 .TP 
106 \fBEINVAL\fP
107 \fBmkstemp\fP() と \fBmkostemp\fP() の場合:
108 \fItemplate\fP の最後の 6 文字が XXXXXX でなかった。
109 この場合、\fItemplate\fP は変更されない。
110 .sp
111 \fBmkstemps\fP() と \fBmkostemps\fP() の場合:
112 \fItemplate\fP の長さが \fI(6 + suffixlen)\fP 文字より短い、または
113 \fItemplate\fP の接尾辞の直前の 6 文字が XXXXXX ではなかった。
114 .PP
115 これらの関数は \fBopen\fP(2) に書かれているエラーのいずれかで失敗することもある。
116 .SH バージョン
117 \fBmkostemp\fP() は glibc 2.7 以降で利用できる。
118 \fBmkstemps\fP() と \fBmkostemps\fP() は glibc 2.11 以降で利用できる。
119 .SH 準拠
120 \fBmkstemp\fP(): 4.3BSD, POSIX.1\-2001.
121
122 .\" mkstemps() appears to be at least on the BSDs, Mac OS X, Solaris,
123 .\" and Tru64.
124 \fBmkstemps\fP(): 標準化されていないが、他のいくつかのシステムにも存在する。
125
126 \fBmkostemp\fP() と \fBmkostemps\fP(): glibc による拡張。
127 .SH 注意
128 In glibc versions 2.06 and earlier, the file is created with permissions
129 0666, that is, read and write for all users.  This old behavior may be a
130 security risk, especially since other UNIX flavors use 0600, and somebody
131 might overlook this detail when porting programs.  POSIX.1\-2008 adds a
132 requirement that the file be created with mode 0600.
133
134 より一般的には、 \fBmkstemp\fP()  の POSIX 規定ではファイルモードについて何も述べていない。 従って、アプリケーションは
135 \fBmkstemp\fP()  (や \fBmkostemp\fP())  を呼び出す前にファイルモード生成マスク (\fBumask\fP(2)  参照)
136 が適切に設定されているか確認するべきである。
137
138 \fBmktemp\fP()  のプロトタイプ宣言は、libc4, libc5, glibc1 では \fI<unistd.h>\fP に含まれる;
139 glibc2 では POSIX.1 に準拠し \fI<stdlib.h>\fP に含まれている。
140 .SH 関連項目
141 \fBmkdtemp\fP(3), \fBmktemp\fP(3), \fBtempnam\fP(3), \fBtmpfile\fP(3), \fBtmpnam\fP(3)
142 .SH この文書について
143 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.50 の一部
144 である。プロジェクトの説明とバグ報告に関する情報は
145 http://www.kernel.org/doc/man\-pages/ に書かれている。