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 2008-12-01 "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)):
46 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
47 .RB ( feature_test_macros (7)
52 _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 500
57 .\"O creates a file system node (file, device special file or
58 .\"O named pipe) named
60 .\"O with attributes specified by
68 ¤È¤¤¤¦Ì¾Á°¤Î¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¡¦¥Î¡¼¥É
69 (¥Õ¥¡¥¤¥ë¡¢¥Ç¥Ð¥¤¥¹¥¹¥Ú¥·¥ã¥ë¥Õ¥¡¥¤¥ë¡¢Ì¾Á°ÉÕ¤¥Ñ¥¤¥×) ¤ò¡¢
74 ¤Î»ØÄê¤Ë¤·¤¿¤¬¤Ã¤ÆºîÀ®¤¹¤ë¡£
78 .\"O argument specifies both the permissions to use and the type of node
81 °ú¤¿ô¤Ë¤Ï¡¢ºîÀ®¤¹¤ë¥Î¡¼¥É¤Îµö²Ä°À (permission) ¤È¥¿¥¤¥×¤ò»ØÄꤹ¤ë¡£
82 .\"O It should be a combination (using bitwise OR) of one of the file types
83 .\"O listed below and the permissions for the new node.
85 ¤Î»ØÄê¤Ï°Ê²¼¤Ë¤¢¤²¤ë¥Õ¥¡¥¤¥ë¥¿¥¤¥×¤Î¤¦¤Á¤Î 1 ¤Ä¤È¡¢
86 µö²Ä°À¤ÎÁȹ礻 (¥Ó¥Ã¥È¤´¤È¤Î OR ¤ò»ÈÍÑ) ¤Ç¹Ô¤¦¡£
88 .\"O The permissions are modified by the process's
90 .\"O in the usual way: the permissions of the created node are
91 .\"O .IR "(mode & ~umask)" .
92 µö²Ä°À¤ÏÄ̾ïÄ̤ꡢ¥×¥í¥»¥¹¤Î
94 ¤Ë¤è¤Ã¤Æ½¤Àµ¤µ¤ì¡¢ºîÀ®¤µ¤ì¤¿¥Î¡¼¥É¤Îµö²Ä°À¤Ï
98 .\"O The file type must be one of
105 .\"O .\" (S_IFSOCK since Linux 1.2.4)
106 .\"O to specify a regular file (which will be created empty), character
107 .\"O special file, block special file, FIFO (named pipe), or Unix domain socket,
109 .\"O (Zero file type is equivalent to type
117 .\" (S_IFSOCK ¤Ï Linux 1.2.4 ¤«¤é¸ºß¤¹¤ë)
118 ¤Î¤¤¤º¤ì¤«¤ò»ØÄꤷ¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
119 ¤½¤ì¤¾¤ì½ç¤Ë¡¢Ä̾ï¤Î¥Õ¥¡¥¤¥ë (¶õ¤Î¥Õ¥¡¥¤¥ë¤È¤·¤ÆºîÀ®¤µ¤ì¤ë)¡¦
120 ¥¥ã¥é¥¯¥¿¥¹¥Ú¥·¥ã¥ë¥Õ¥¡¥¤¥ë¡¦¥Ö¥í¥Ã¥¯¥¹¥Ú¥·¥ã¥ë¥Õ¥¡¥¤¥ë¡¦
121 FIFO (̾Á°ÉÕ¤¥Ñ¥¤¥×)¡¦Unix ¥É¥á¥¤¥ó¥½¥±¥Ã¥È¤Ç¤¢¤ë
126 .\"O If the file type is
132 .\"O specifies the major and minor numbers of the newly created device
134 .\"O .RB ( makedev (3)
135 .\"O may be useful to build the value for
137 .\"O otherwise it is ignored.
144 ¤Ë¤ÏºîÀ®¤¹¤ë¥Ç¥Ð¥¤¥¹¥¹¥Ú¥·¥ã¥ë¥Õ¥¡¥¤¥ë¤Î¥á¥¸¥ã¡¼ÈÖ¹æ¤È
145 ¥Þ¥¤¥Ê¡¼ÈÖ¹æ¤ò»ØÄꤹ¤ë
149 ¤Î¤³¤ì¤é¤ÎÈÖ¹æ¤òºîÀ®¤¹¤ëºÝ¤ËÌòΩ¤Ä¤À¤í¤¦)¡£
156 .\"O already exists, or is a symbolic link, this call fails with an
160 ¤¬´û¤Ë¸ºß¤¹¤ë¾ì¹ç¡¢¤Þ¤¿¤Ï¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤Î¾ì¹ç¡¢
165 .\"O The newly created node will be owned by the effective user ID of the
167 .\"O If the directory containing the node has the set-group-ID
168 .\"O bit set, or if the file system is mounted with BSD group semantics, the
169 .\"O new node will inherit the group ownership from its parent directory;
170 .\"O otherwise it will be owned by the effective group ID of the process.
171 ¿·¤·¤¯ºîÀ®¤µ¤ì¤¿¥Î¡¼¥É¤Î½êÍ¼Ô¤Ï¥×¥í¥»¥¹¤Î¼Â¸ú¥æ¡¼¥¶ ID ¤Ë¥»¥Ã¥È¤µ¤ì¤ë¡£
172 ¿·¤¿¤Ëºî¤é¤ì¤¿¥Î¡¼¥É¤òÊÝ»ý¤¹¤ë
173 ¿Æ¥Ç¥£¥ì¥¯¥È¥ê¤Î set-group-ID ¥Ó¥Ã¥È¤¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤¿¤ê¡¢
174 ¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤¬ BSD ¤Î¥°¥ë¡¼¥×¥»¥Þ¥ó¥Æ¥£¥¯¥¹¤Ë¤·¤¿¤¬¤Ã¤Æ
175 ¥Þ¥¦¥ó¥È¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï¡¢¿·¤·¤¤¥Î¡¼¥É¤Î¥°¥ë¡¼¥×½ê͸¢¤Ï¿Æ¥Ç¥£¥ì¥¯¥È¥ê¤Î
176 ¥°¥ë¡¼¥×½ê͸¢¤ò·Ñ¾µ¤¹¤ë (¿Æ¥Ç¥£¥ì¥¯¥È¥ê¤ÈƱ¤¸¤Ë¤Ê¤ë)¡£
177 ¤Þ¤¿¡¢¤½¤¦¤Ç¤Ê¤«¤Ã¤¿¾ì¹ç¤Î½êÍ¥°¥ë¡¼¥×¤Ï¥×¥í¥»¥¹¤Î¼Â¸ú¥°¥ë¡¼¥× ID ¤È¤Ê¤ë¡£
178 .\"O .SH RETURN VALUE
181 .\"O returns zero on success, or \-1 if an error occurred (in which case,
183 .\"O is set appropriately).
185 ¤ÏÀ®¸ù¤·¤¿¾ì¹ç 0 ¤ò¡¢¼ºÇÔ¤·¤¿¾ì¹ç \-1 ¤òÊÖ¤¹
188 ¤¬¥¨¥é¡¼¤ÎÆâÍƤˤ·¤¿¤¬¤Ã¤Æ¥»¥Ã¥È¤µ¤ì¤ë)¡£
193 .\"O The parent directory does not allow write permission to the process,
194 .\"O or one of the directories in the path prefix of
196 .\"O did not allow search permission.
198 .\"O .BR path_resolution (7).)
199 ¥×¥í¥»¥¹¤¬¿Æ¥Ç¥£¥ì¥¯¥È¥ê¤Ø¤Î½ñ¤¹þ¤ßµö²Ä¤ò»ý¤¿¤Ê¤¤¡£
202 Ãæ¤Î¥Ç¥£¥ì¥¯¥È¥êÉôʬ¤Î¤É¤ì¤«¤Ë¸¡º÷µö²Ä°À¤¬Ìµ¤¤
203 .RB ( path_resolution (7)
209 .\"O This includes the case where
211 .\"O is a symbolic link, dangling or not.
216 ¤¬¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯¤Ç¤¢¤ë¾ì¹ç¤â´Þ¤Þ¤ì¤ë
217 (¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯¤¬²õ¤ì¤Æ¤¤¤ë¤« (dangling) ¤É¤¦¤«¤Ï´Ø·¸¤Ê¤¤)¡£
220 .\"O .IR pathname " points outside your accessible address space."
222 ¤¬¤½¤Î¥×¥í¥»¥¹¤Î¥¢¥¯¥»¥¹²Äǽ¤Ê¥¢¥É¥ì¥¹¶õ´Ö¤Î³°¤ò»Ø¤·¤Æ¤¤¤ë¡£
226 .\"O requested creation of something other than a regular file, device
227 .\"O special file, FIFO or socket.
229 ¤¬Ä̾ï¤Î¥Õ¥¡¥¤¥ë¡¦¥Ç¥Ð¥¤¥¹¥¹¥Ú¥·¥ã¥ë¥Õ¥¡¥¤¥ë¡¦FIFO¡¦¥½¥±¥Ã¥È°Ê³°¤ò
230 ºîÀ®¤¹¤ë¤è¤¦¤Ë¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤ë¡£
233 .\"O Too many symbolic links were encountered in resolving
237 ¤ò²ò·è¤¹¤ë¤È¤¤Ë¡¢´Þ¤Þ¤ì¤Æ¤¤¤ë¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤¬Â¿¤¹¤®¤¿¡£
240 .\"O .IR pathname " was too long."
245 .\"O A directory component in
247 .\"O does not exist or is a dangling symbolic link.
249 Ãæ¤Ç»ØÄꤵ¤ì¤Æ¤¤¤ë¥Ç¥£¥ì¥¯¥È¥ê¤¬Â¸ºß¤·¤Ê¤¤¤«¡¢
250 ¤Þ¤¿¤Ï¥ê¥ó¥¯Àè¤Î̵¤¤¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤Ç¤¢¤ë¡£
253 .\"O Insufficient kernel memory was available.
254 ½½Ê¬¤Ê¥«¡¼¥Í¥ë¥á¥â¥ê¤¬Ìµ¤¤¡£
257 .\"O The device containing
259 .\"O has no room for the new node.
261 ¤Î¤¢¤ë¥Ç¥Ð¥¤¥¹¤Ë¿·¤¿¤Ë¥Î¡¼¥É¤òºîÀ®¤¹¤ë¶õ¤¤¬Ìµ¤¤¡£
264 .\"O A component used as a directory in
266 .\"O is not, in fact, a directory.
268 Ãæ¤Î¥Ç¥£¥ì¥¯¥È¥êÍ×ÁǤ¬¡¢¼ÂºÝ¤Ë¤Ï¥Ç¥£¥ì¥¯¥È¥ê¤Ç¤Ê¤¤¡£
272 .\"O requested creation of something other than a regular file,
273 .\"O FIFO (named pipe), or Unix domain socket, and the caller
274 .\"O is not privileged (Linux: does not have the
277 .\"O .\" For Unix domain sockets and regular files, EPERM is only returned in
278 .\"O .\" Linux 2.2 and earlier; in Linux 2.4 and later, unprivileged can
279 .\"O .\" use mknod() to make these files.
280 .\"O also returned if the file system containing
282 .\"O does not support the type of node requested.
284 ¤ÏÄ̾ï¤Î¥Õ¥¡¥¤¥ë¡¦FIFO (̾Á°ÉÕ¤¥Ñ¥¤¥×)¡¦Unix ¥É¥á¥¤¥ó¥½¥±¥Ã¥È°Ê³°¤ò
285 ºîÀ®¤¹¤ë¤è¤¦¤Ë¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤ë¤¬¡¢¼Â¹Ô¼Ô¤¬Æø¢
288 ¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£ (capability)) ¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£
289 .\" Unix ¥É¥á¥¤¥ó¥½¥±¥Ã¥È¤ÈÄ̾ï¥Õ¥¡¥¤¥ë¤ËÂФ·¤Æ mknod() ¤ò¹Ô¤¦¤È¡¢
290 .\" Linux 2.2 °ÊÁ°¤Ç¤Ï EPERM ¤òÊÖ¤¹¤À¤±¤Ç¤¢¤ë¡£
291 .\" Linux 2.4 °Ê¹ß¤Ç¤ÏÆø¢¤ò»ý¤Ã¤Æ¤¤¤Ê¤¯¤Æ¤â¤³¤ì¤é¤Î¥Õ¥¡¥¤¥ë¤ò
292 .\" ºîÀ®¤¹¤ë¤Î¤Ë mknod() ¤ò»ÈÍѤ¹¤ë¤³¤È¤¬¤Ç¤¤ë¡£
295 ¤òÊÝ»ý¤¹¤ë¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤¬¡¢»ØÄꤵ¤ì¤¿¥Î¡¼¥É·Á¼°¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤¤¡£
299 .\"O refers to a file on a read-only file system.
301 ¤¬Æɤ߽Ф·ÀìÍÑ¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¾å¤Î¥Õ¥¡¥¤¥ë¤ò»Ø¤·¤Æ¤¤¤ë¡£
302 .\"O .SH CONFORMING TO
304 .\"O SVr4, 4.4BSD, POSIX.1-2001 (but see below).
305 .\"O .\" The Linux version differs from the SVr4 version in that it
306 .\"O .\" does not require root permission to create pipes, also in that no
307 .\"O .\" EMULTIHOP, ENOLINK, or EINTR error is documented.
308 SVr4, 4.4BSD, POSIX.1-2001 (²¼µ¤â»²¾È).
309 .\" Linux ¤Î¼ÂÁõ¤Ï SVr4 ¤Î¼ÂÁõ¤È°Û¤Ê¤ê¡¢¥Ñ¥¤¥×¤ÎºîÀ®¤Ë¤Ï root ¸¢¸Â¤¬ÉÔÍפǤ¢¤ë¡£
310 .\" ¤Þ¤¿ EMULTIHOP ¤È ENOLINK ¤È EINTR ¤Î¥¨¥é¡¼¤Ë¤Ä¤¤¤Æ¤Ïµ½Ò¤µ¤ì¤Æ¤¤¤Ê¤¤¡£
313 .\"O POSIX.1-2001 says: "The only portable use of
315 .\"O is to create a FIFO-special file.
322 .\"O is not 0, the behavior of
324 .\"O is unspecified."
325 POSIX.1-2001 ¤Ç¤Ï¼¡¤Î¤è¤¦¤Ë½ñ¤¤¤Æ¤¤¤ë¡§
327 ¤ÎÍ£°ì¤Î°Ü¿¢À¤Î¤¢¤ë»ÈÍÑË¡¤Ï¡¢FIFO ¥¹¥Ú¥·¥ã¥ë¥Õ¥¡¥¤¥ë¤òºîÀ®¤¹¤ë¤³¤È¤Ç¤¢¤ë¡£
335 ¤ÎµóÆ°¤Ïµ¬Äꤵ¤ì¤Æ¤¤¤Ê¤¤¡£¡×
336 .\"O However, nowadays one should never use
338 .\"O for this purpose; one should use
340 .\"O a function especially defined for this purpose.
341 ¤·¤«¤·¤Ê¤¬¤é¡¢¸½ºß¤Ç¤Ï¤³¤ÎÌÜŪ¤Î¤¿¤á¤Ë
343 ¤ò»ÈÍѤ¹¤Ù¤¤Ç¤Ï¤Ê¤¤¡£¤³¤ÎÌÜŪ¤Î¤¿¤á¤ËÆÃÊ̤ËÄêµÁ¤µ¤ì¤¿´Ø¿ô¤Ç¤¢¤ë
347 .\"O Under Linux, this call cannot be used to create directories.
348 Linux ¤Ç¤Ï¡¢¥Ç¥£¥ì¥¯¥È¥ê¤òºîÀ®¤¹¤ë¤¿¤á¤Ë
349 ¤³¤Î¸Æ¤Ó½Ð¤·¤ò»ÈÍѤ¹¤ë¤³¤È¤Ï¤Ç¤¤Ê¤¤¡£
350 .\"O One should make directories with
355 .\"O .\" and one should make Unix domain sockets with socket(2) and bind(2).
356 .\" Unix ¥É¥á¥¤¥ó¥½¥±¥Ã¥È¤Ï socket(2) ¤È bind(2) ¤ÇºîÀ®¤¹¤Ù¤¤Ç¤¢¤ë¡£
358 .\"O There are many infelicities in the protocol underlying NFS.
359 .\"O Some of these affect
361 NFS ¤ò¼Â¸½¤·¤Æ¤¤¤ë¥×¥í¥È¥³¥ë¤Ë¤Ï¿¤¯¤ÎÉÔÈ÷¤¬Â¸ºß¤·¡¢
379 .BR path_resolution (7)