OSDN Git Service

597fdf7a8026abb74928a53d51c81942908d4c65
[linuxjm/LDP_man-pages.git] / draft / man2 / mknod.2
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" This manpage is Copyright (C) 1992 Drew Eckhardt;
4 .\"                               1993 Michael Haardt
5 .\"                               1993,1994 Ian Jackson.
6 .\" You may distribute it under the terms of the GNU General
7 .\" Public License. It comes with NO WARRANTY.
8 .\"
9 .\" Modified 1996-08-18 by urs
10 .\" Modified 2003-04-23 by Michael Kerrisk
11 .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
12 .\"
13 .\"
14 .\" Japanese Version Copyright (c) 1997 SUTO, Mitsuaki
15 .\"         all rights reserved.
16 .\" Translated 1997-06-26, SUTO, Mitsuaki <suto@av.crl.sony.co.jp>
17 .\" Updated & Modified 1999-03-01, NAKANO Takeo <nakano@apm.seikei.ac.jp>
18 .\" Updated & Modified 2001-06-04, Yuichi SATO <ysato@h4.dion.ne.jp>
19 .\" Updated & Modified 2003-07-26, Yuichi SATO <ysato444@yahoo.co.jp>
20 .\" Updated & Modified 2004-12-31, Yuichi SATO
21 .\" Updated 2005-09-06, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
22 .\"
23 .\"WORD:        node            ノード
24 .\"WORD:        permission      許可属性
25 .\"WORD:        resolve         (パス名を) 解決する
26 .\"
27 .TH MKNOD 2 2010-09-20 "Linux" "Linux Programmer's Manual"
28 .\"O .SH NAME
29 .SH 名前
30 .\"O mknod \- create a special or ordinary file
31 mknod \- 特殊ファイルや通常のファイルを作成する
32 .\"O .SH SYNOPSIS
33 .SH 書式
34 .nf
35 .B #include <sys/types.h>
36 .B #include <sys/stat.h>
37 .B #include <fcntl.h>
38 .B #include <unistd.h>
39 .sp
40 .BI "int mknod(const char *" pathname ", mode_t " mode ", dev_t " dev );
41 .fi
42 .sp
43 .in -4n
44 .\"O Feature Test Macro Requirements for glibc (see
45 .\"O .BR feature_test_macros (7)):
46 glibc 向けの機能検査マクロの要件
47 .RB ( feature_test_macros (7)
48 参照):
49 .in
50 .sp
51 .BR mknod ():
52 .ad l
53 .RS 4
54 _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
55 _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
56 .RE
57 .ad
58 .\"O .SH DESCRIPTION
59 .SH 説明
60 .\"O The system call
61 .\"O .BR mknod ()
62 .\"O creates a file system node (file, device special file or
63 .\"O named pipe) named
64 .\"O .IR pathname ,
65 .\"O with attributes specified by
66 .\"O .I mode
67 .\"O and
68 .\"O .IR dev .
69 システムコール
70 .BR mknod ()
71
72 .I pathname
73 という名前のファイルシステム・ノード
74 (ファイル、デバイススペシャルファイル、名前付きパイプ) を、
75 属性
76 .I mode
77
78 .I dev
79 の指定にしたがって作成する。
80
81 .\"O The
82 .\"O .I mode
83 .\"O argument specifies both the permissions to use and the type of node
84 .\"O to be created.
85 .I mode
86 引き数には、作成するノードの許可属性 (permission) とタイプを指定する。
87 .\"O It should be a combination (using bitwise OR) of one of the file types
88 .\"O listed below and the permissions for the new node.
89 .I mode
90 の指定は以下にあげるファイルタイプのうちの 1 つと、
91 許可属性の組合せ (ビットごとの OR を使用) で行う。
92
93 .\"O The permissions are modified by the process's
94 .\"O .I umask
95 .\"O in the usual way: the permissions of the created node are
96 .\"O .IR "(mode & ~umask)" .
97 許可属性は通常通り、プロセスの
98 .I umask
99 によって修正され、作成されたノードの許可属性は
100 .I "(mode & ~umask)"
101 となる。
102
103 .\"O The file type must be one of
104 .\"O .BR S_IFREG ,
105 .\"O .BR S_IFCHR ,
106 .\"O .BR S_IFBLK ,
107 .\"O .B S_IFIFO
108 .\"O or
109 .\"O .B S_IFSOCK
110 .\"O .\" (S_IFSOCK since Linux 1.2.4)
111 .\"O to specify a regular file (which will be created empty), character
112 .\"O special file, block special file, FIFO (named pipe), or UNIX domain socket,
113 .\"O respectively.
114 .\"O (Zero file type is equivalent to type
115 .\"O .BR S_IFREG .)
116 ファイルタイプには
117 .BR S_IFREG ,
118 .BR S_IFCHR ,
119 .BR S_IFBLK ,
120 .BR S_IFIFO ,
121 .B S_IFSOCK
122 .\" (S_IFSOCK は Linux 1.2.4 から存在する)
123 のいずれかを指定しなければならない。
124 それぞれ順に、通常のファイル (空のファイルとして作成される)・
125 キャラクタスペシャルファイル・ブロックスペシャルファイル・
126 FIFO (名前付きパイプ)・UNIX ドメインソケットである
127 (ファイルタイプ 0 は
128 .B S_IFREG
129 と同じである)。
130
131 .\"O If the file type is
132 .\"O .B S_IFCHR
133 .\"O or
134 .\"O .B S_IFBLK
135 .\"O then
136 .\"O .I dev
137 .\"O specifies the major and minor numbers of the newly created device
138 .\"O special file
139 .\"O .RB ( makedev (3)
140 .\"O may be useful to build the value for
141 .\"O .IR dev );
142 .\"O otherwise it is ignored.
143 ファイルタイプが
144 .B S_IFCHR
145 または
146 .B S_IFBLK
147 のとき、
148 .I dev
149 には作成するデバイススペシャルファイルのメジャー番号と
150 マイナー番号を指定する
151 .RB ( makedev (3)
152
153 .I dev
154 のこれらの番号を作成する際に役立つだろう)。
155 それ以外の場合は
156 .I dev
157 は無視される。
158
159 .\"O If
160 .\"O .I pathname
161 .\"O already exists, or is a symbolic link, this call fails with an
162 .\"O .B EEXIST
163 .\"O error.
164 .I pathname
165 が既に存在する場合、またはシンボリックリンクの場合、
166 この呼び出しは
167 .B EEXIST
168 エラーで失敗する。
169
170 .\"O The newly created node will be owned by the effective user ID of the
171 .\"O process.
172 .\"O If the directory containing the node has the set-group-ID
173 .\"O bit set, or if the file system is mounted with BSD group semantics, the
174 .\"O new node will inherit the group ownership from its parent directory;
175 .\"O otherwise it will be owned by the effective group ID of the process.
176 新しく作成されたノードの所有者はプロセスの実効ユーザ ID にセットされる。
177 新たに作られたノードを保持する
178 親ディレクトリの set-group-ID ビットがセットされていたり、
179 ファイルシステムが BSD のグループセマンティクスにしたがって
180 マウントされている場合には、新しいノードのグループ所有権は親ディレクトリの
181 グループ所有権を継承する (親ディレクトリと同じになる)。
182 また、そうでなかった場合の所有グループはプロセスの実効グループ ID となる。
183 .\"O .SH RETURN VALUE
184 .SH 返り値
185 .\"O .BR mknod ()
186 .\"O returns zero on success, or \-1 if an error occurred (in which case,
187 .\"O .I errno
188 .\"O is set appropriately).
189 .BR mknod ()
190 は成功した場合 0 を、失敗した場合 \-1 を返す
191 (失敗した場合
192 .I errno
193 がエラーの内容にしたがってセットされる)。
194 .\"O .SH ERRORS
195 .SH エラー
196 .TP
197 .B EACCES
198 .\"O The parent directory does not allow write permission to the process,
199 .\"O or one of the directories in the path prefix of
200 .\"O .I pathname
201 .\"O did not allow search permission.
202 .\"O (See also
203 .\"O .BR path_resolution (7).)
204 プロセスが親ディレクトリへの書き込み許可を持たない。
205 もしくはパス名
206 .I pathname
207 中のディレクトリ部分のどれかに検索許可属性が無い
208 .RB ( path_resolution (7)
209 も参照すること)。
210 .TP
211 .B EEXIST
212 .\"O .I pathname
213 .\"O already exists.
214 .\"O This includes the case where
215 .\"O .I pathname
216 .\"O is a symbolic link, dangling or not.
217 .I pathname
218 が既に存在する。
219 これには
220 .I pathname
221 がシンボリック・リンクである場合も含まれる
222 (シンボリック・リンクが壊れているか (dangling) どうかは関係ない)。
223 .TP
224 .B EFAULT
225 .\"O .IR pathname " points outside your accessible address space."
226 .I pathname
227 がそのプロセスのアクセス可能なアドレス空間の外を指している。
228 .TP
229 .B EINVAL
230 .\"O .I mode
231 .\"O requested creation of something other than a regular file, device
232 .\"O special file, FIFO or socket.
233 .I mode
234 が通常のファイル・デバイススペシャルファイル・FIFO・ソケット以外を
235 作成するようにセットされている。
236 .TP
237 .B ELOOP
238 .\"O Too many symbolic links were encountered in resolving
239 .\"O .IR pathname .
240 パス名
241 .I pathname
242 を解決するときに、含まれているシンボリックリンクが多すぎた。
243 .TP
244 .B ENAMETOOLONG
245 .\"O .IR pathname " was too long."
246 .I pathname
247 が長過ぎる。
248 .TP
249 .B ENOENT
250 .\"O A directory component in
251 .\"O .I pathname
252 .\"O does not exist or is a dangling symbolic link.
253 .I pathname
254 中で指定されているディレクトリが存在しないか、
255 またはリンク先の無いシンボリックリンクである。
256 .TP
257 .B ENOMEM
258 .\"O Insufficient kernel memory was available.
259 十分なカーネルメモリが無い。
260 .TP
261 .B ENOSPC
262 .\"O The device containing
263 .\"O .I pathname
264 .\"O has no room for the new node.
265 .I pathname
266 のあるデバイスに新たにノードを作成する空きが無い。
267 .TP
268 .B ENOTDIR
269 .\"O A component used as a directory in
270 .\"O .I pathname
271 .\"O is not, in fact, a directory.
272 .I pathname
273 中のディレクトリ要素が、実際にはディレクトリでない。
274 .TP
275 .B EPERM
276 .\"O .I mode
277 .\"O requested creation of something other than a regular file,
278 .\"O FIFO (named pipe), or UNIX domain socket, and the caller
279 .\"O is not privileged (Linux: does not have the
280 .\"O .B CAP_MKNOD
281 .\"O capability);
282 .\"O .\" For UNIX domain sockets and regular files, EPERM is only returned in
283 .\"O .\" Linux 2.2 and earlier; in Linux 2.4 and later, unprivileged can
284 .\"O .\" use mknod() to make these files.
285 .\"O also returned if the file system containing
286 .\"O .I pathname
287 .\"O does not support the type of node requested.
288 .I mode
289 は通常のファイル・FIFO (名前付きパイプ)・UNIX ドメインソケット以外を
290 作成するようにセットされているが、実行者が特権
291 (Linux では
292 .B CAP_MKNOD
293 ケーパビリティ (capability)) を持っていない。
294 .\" UNIX ドメインソケットと通常ファイルに対して mknod() を行うと、
295 .\" Linux 2.2 以前では EPERM を返すだけである。
296 .\" Linux 2.4 以降では特権を持っていなくてもこれらのファイルを
297 .\" 作成するのに mknod() を使用することができる。
298 または
299 .I pathname
300 を保持するファイルシステムが、指定されたノード形式をサポートしていない。
301 .TP
302 .B EROFS
303 .\"O .I pathname
304 .\"O refers to a file on a read-only file system.
305 .I pathname
306 が読み出し専用ファイルシステム上のファイルを指している。
307 .\"O .SH CONFORMING TO
308 .SH 準拠
309 .\"O SVr4, 4.4BSD, POSIX.1-2001 (but see below).
310 .\"O .\" The Linux version differs from the SVr4 version in that it
311 .\"O .\" does not require root permission to create pipes, also in that no
312 .\"O .\" EMULTIHOP, ENOLINK, or EINTR error is documented.
313 SVr4, 4.4BSD, POSIX.1-2001 (下記も参照).
314 .\" Linux の実装は SVr4 の実装と異なり、パイプの作成には root 権限が不要である。
315 .\" また EMULTIHOP と ENOLINK と EINTR のエラーについては記述されていない。
316 .\"O .SH NOTES
317 .SH 注意
318 .\"O POSIX.1-2001 says: "The only portable use of
319 .\"O .BR mknod ()
320 .\"O is to create a FIFO-special file.
321 .\"O If
322 .\"O .I mode
323 .\"O is not
324 .\"O .B S_IFIFO
325 .\"O or
326 .\"O .I dev
327 .\"O is not 0, the behavior of
328 .\"O .BR mknod ()
329 .\"O is unspecified."
330 POSIX.1-2001 では次のように書いている:
331 .RB 「 mknod ()
332 の唯一の移植性のある使用法は、FIFO スペシャルファイルを作成することである。
333 .I mode
334
335 .B S_IFIFO
336 ではない場合、または
337 .I dev
338 が 0 ではない場合、
339 .BR mknod ()
340 の挙動は規定されていない。」
341 .\"O However, nowadays one should never use
342 .\"O .BR mknod ()
343 .\"O for this purpose; one should use
344 .\"O .BR mkfifo (3),
345 .\"O a function especially defined for this purpose.
346 しかしながら、現在ではこの目的のために
347 .BR mknod ()
348 を使用すべきではない。この目的のために特別に定義された関数である
349 .BR mkfifo ()
350 を使用すべきである。
351
352 .\"O Under Linux, this call cannot be used to create directories.
353 Linux では、ディレクトリを作成するために
354 この呼び出しを使用することはできない。
355 .\"O One should make directories with
356 .\"O .BR mkdir (2).
357 ディレクトリは
358 .BR mkdir (2)
359 で作成すべきである。
360 .\"O .\" and one should make UNIX domain sockets with socket(2) and bind(2).
361 .\" UNIX ドメインソケットは socket(2) と bind(2) で作成すべきである。
362
363 .\"O There are many infelicities in the protocol underlying NFS.
364 .\"O Some of these affect
365 .\"O .BR mknod ().
366 NFS を実現しているプロトコルには多くの不備が存在し、
367 それらのいくつかは
368 .BR mknod ()
369 に影響を与える。
370 .\"O .SH SEE ALSO
371 .SH 関連項目
372 .BR chmod (2),
373 .BR chown (2),
374 .BR fcntl (2),
375 .BR mkdir (2),
376 .BR mknodat (2),
377 .BR mount (2),
378 .BR socket (2),
379 .BR stat (2),
380 .BR umask (2),
381 .BR unlink (2),
382 .BR makedev (3),
383 .BR mkfifo (3),
384 .BR path_resolution (7)