1 .\" Hey Emacs! This file is -*- nroff -*- source.
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.
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>
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>
24 .\"WORD: permission 許可属性
25 .\"WORD: resolve (パス名を) 解決する
27 .TH MKNOD 2 2010-09-20 "Linux" "Linux Programmer's Manual"
30 .\"O mknod \- create a special or ordinary file
31 mknod \- 特殊ファイルや通常のファイルを作成する
35 .B #include <sys/types.h>
36 .B #include <sys/stat.h>
38 .B #include <unistd.h>
40 .BI "int mknod(const char *" pathname ", mode_t " mode ", dev_t " dev );
44 .\"O Feature Test Macro Requirements for glibc (see
45 .\"O .BR feature_test_macros (7)):
47 .RB ( feature_test_macros (7)
54 _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
55 _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
62 .\"O creates a file system node (file, device special file or
63 .\"O named pipe) named
65 .\"O with attributes specified by
74 (ファイル、デバイススペシャルファイル、名前付きパイプ) を、
83 .\"O argument specifies both the permissions to use and the type of node
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.
90 の指定は以下にあげるファイルタイプのうちの 1 つと、
91 許可属性の組合せ (ビットごとの OR を使用) で行う。
93 .\"O The permissions are modified by the process's
95 .\"O in the usual way: the permissions of the created node are
96 .\"O .IR "(mode & ~umask)" .
99 によって修正され、作成されたノードの許可属性は
103 .\"O The file type must be one of
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,
114 .\"O (Zero file type is equivalent to type
122 .\" (S_IFSOCK は Linux 1.2.4 から存在する)
124 それぞれ順に、通常のファイル (空のファイルとして作成される)・
125 キャラクタスペシャルファイル・ブロックスペシャルファイル・
126 FIFO (名前付きパイプ)・UNIX ドメインソケットである
131 .\"O If the file type is
137 .\"O specifies the major and minor numbers of the newly created device
139 .\"O .RB ( makedev (3)
140 .\"O may be useful to build the value for
142 .\"O otherwise it is ignored.
149 には作成するデバイススペシャルファイルのメジャー番号と
154 のこれらの番号を作成する際に役立つだろう)。
161 .\"O already exists, or is a symbolic link, this call fails with an
165 が既に存在する場合、またはシンボリックリンクの場合、
170 .\"O The newly created node will be owned by the effective user ID of the
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 にセットされる。
178 親ディレクトリの set-group-ID ビットがセットされていたり、
179 ファイルシステムが BSD のグループセマンティクスにしたがって
180 マウントされている場合には、新しいノードのグループ所有権は親ディレクトリの
181 グループ所有権を継承する (親ディレクトリと同じになる)。
182 また、そうでなかった場合の所有グループはプロセスの実効グループ ID となる。
183 .\"O .SH RETURN VALUE
186 .\"O returns zero on success, or \-1 if an error occurred (in which case,
188 .\"O is set appropriately).
190 は成功した場合 0 を、失敗した場合 \-1 を返す
193 がエラーの内容にしたがってセットされる)。
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
201 .\"O did not allow search permission.
203 .\"O .BR path_resolution (7).)
204 プロセスが親ディレクトリへの書き込み許可を持たない。
207 中のディレクトリ部分のどれかに検索許可属性が無い
208 .RB ( path_resolution (7)
214 .\"O This includes the case where
216 .\"O is a symbolic link, dangling or not.
221 がシンボリック・リンクである場合も含まれる
222 (シンボリック・リンクが壊れているか (dangling) どうかは関係ない)。
225 .\"O .IR pathname " points outside your accessible address space."
227 がそのプロセスのアクセス可能なアドレス空間の外を指している。
231 .\"O requested creation of something other than a regular file, device
232 .\"O special file, FIFO or socket.
234 が通常のファイル・デバイススペシャルファイル・FIFO・ソケット以外を
238 .\"O Too many symbolic links were encountered in resolving
242 を解決するときに、含まれているシンボリックリンクが多すぎた。
245 .\"O .IR pathname " was too long."
250 .\"O A directory component in
252 .\"O does not exist or is a dangling symbolic link.
254 中で指定されているディレクトリが存在しないか、
255 またはリンク先の無いシンボリックリンクである。
258 .\"O Insufficient kernel memory was available.
262 .\"O The device containing
264 .\"O has no room for the new node.
266 のあるデバイスに新たにノードを作成する空きが無い。
269 .\"O A component used as a directory in
271 .\"O is not, in fact, a directory.
273 中のディレクトリ要素が、実際にはディレクトリでない。
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
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
287 .\"O does not support the type of node requested.
289 は通常のファイル・FIFO (名前付きパイプ)・UNIX ドメインソケット以外を
290 作成するようにセットされているが、実行者が特権
293 ケーパビリティ (capability)) を持っていない。
294 .\" UNIX ドメインソケットと通常ファイルに対して mknod() を行うと、
295 .\" Linux 2.2 以前では EPERM を返すだけである。
296 .\" Linux 2.4 以降では特権を持っていなくてもこれらのファイルを
297 .\" 作成するのに mknod() を使用することができる。
300 を保持するファイルシステムが、指定されたノード形式をサポートしていない。
304 .\"O refers to a file on a read-only file system.
306 が読み出し専用ファイルシステム上のファイルを指している。
307 .\"O .SH CONFORMING TO
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 のエラーについては記述されていない。
318 .\"O POSIX.1-2001 says: "The only portable use of
320 .\"O is to create a FIFO-special file.
327 .\"O is not 0, the behavior of
329 .\"O is unspecified."
330 POSIX.1-2001 では次のように書いている:
332 の唯一の移植性のある使用法は、FIFO スペシャルファイルを作成することである。
341 .\"O However, nowadays one should never use
343 .\"O for this purpose; one should use
345 .\"O a function especially defined for this purpose.
348 を使用すべきではない。この目的のために特別に定義された関数である
352 .\"O Under Linux, this call cannot be used to create directories.
353 Linux では、ディレクトリを作成するために
355 .\"O One should make directories with
360 .\"O .\" and one should make UNIX domain sockets with socket(2) and bind(2).
361 .\" UNIX ドメインソケットは socket(2) と bind(2) で作成すべきである。
363 .\"O There are many infelicities in the protocol underlying NFS.
364 .\"O Some of these affect
366 NFS を実現しているプロトコルには多くの不備が存在し、
384 .BR path_resolution (7)