mknod

MKNOD(2)                   Linux Programmer's Manual                  MKNOD(2)



åå
       mknod - ç¹æ®ãã¡ã¤ã«ãé常ã®ãã¡ã¤ã«ãä½æãã

æ¸å¼
       #include <sys/types.h>
       #include <sys/stat.h>
       #include <fcntl.h>
       #include <unistd.h>

       int mknod(const char *pathname, mode_t mode, dev_t dev);

   glibc åãã®æ©è½æ¤æ»ãã¯ãã®è¦ä»¶ (feature_test_macros(7)  åç§):

       mknod():
           _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500 ||
           _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED

説æ
       ã·ã¹ãã ã³ã¼ã« mknod()  㯠pathname ã¨ããååã®ãã¡ã¤ã«ã·ã¹ãã ã»ãã¼ã
       (ãã¡ã¤ã«ãããã¤ã¹ã¹ãã·ã£ã«ãã¡ã¤ã«ãååä»ããã¤ã) ãã å±æ§ mode 㨠dev
       ã®æå®ã«ãããã£ã¦ä½æããã

       mode å¼ãæ°ã«ã¯ãä½æãããã¼ãã®è¨±å¯å±æ§ (permission) ã¨ã¿ã¤ããæå®ããã mode
       ã®æå®ã¯ä»¥ä¸ã«ããããã¡ã¤ã«ã¿ã¤ãã®ãã¡ã® 1 ã¤ã¨ã 許å¯å±æ§ã®çµåã (ããããã¨ã®
       OR ã使ç¨) ã§è¡ãã

       許å¯å±æ§ã¯é常éããããã»ã¹ã® umask ã«ãã£ã¦ä¿®æ£ãããä½æããããã¼ãã®è¨±å¯å±æ§ã¯
       (mode & ~umask) ã¨ãªãã

       ãã¡ã¤ã«ã¿ã¤ãã«ã¯ S_IFREG, S_IFCHR, S_IFBLK, S_IFIFO, S_IFSOCK
       ã®ãããããæå®ããªããã°ãªããªãã ããããé ã«ãé常ã®ãã¡ã¤ã«
       (空ã®ãã¡ã¤ã«ã¨ãã¦ä½æããã)ã» ãã£ã©ã¯ã¿ã¹ãã·ã£ã«ãã¡ã¤ã«ã»ãã‐
       ãã¯ã¹ãã·ã£ã«ãã¡ã¤ã«ã» FIFO (ååä»ããã¤ã)ã»UNIX ãã¡ã¤ã³ã½ã±ããã§ãã
       (ãã¡ã¤ã«ã¿ã¤ã 0 㯠S_IFREG ã¨åãã§ãã)ã

       ãã¡ã¤ã«ã¿ã¤ãã S_IFCHR ã¾ã㯠S_IFBLK ã®ã¨ãã dev
       ã«ã¯ä½æããããã¤ã¹ã¹ãã·ã£ã«ãã¡ã¤ã«ã®ã¡ã¸ã£ã¼çªå·ã¨ ãã¤ãã¼çªå·ãæå®ãã
       (makedev(3)  㯠dev ã®ãããã®çªå·ãä½æããéã«å½¹ç«ã¤ã ãã)ã ãã以å¤ã®å ´åã¯
       dev ã¯ç¡è¦ãããã

       pathname ãæ¢ã«åå¨ããå ´åãã¾ãã¯ã·ã³ããªãã¯ãªã³ã¯ã®å ´åã ãã®å¼ã³åºãã¯
       EEXIST ã¨ã©ã¼ã§å¤±æããã

       æ°ããä½æããããã¼ãã®ææèã¯ããã»ã¹ã®å®å¹ã¦ã¼ã¶ ID ã«ã»ãããããã
       æ°ãã«ä½ããããã¼ããä¿æãã 親ãã£ã¬ã¯ããªã® set-group-ID ããããã»ããããã¦ãããã
       ãã¡ã¤ã«ã·ã¹ãã ã BSD ã®ã°ã«ã¼ãã»ãã³ãã£ã¯ã¹ã«ãããã£ã¦
       ãã¦ã³ãããã¦ããå ´åã«ã¯ãæ°ãããã¼ãã®ã°ã«ã¼ãææ権ã¯è¦ªãã£ã¬ã¯ããªã®
       ã°ã«ã¼ãææ権ãç¶æ¿ãã (親ãã£ã¬ã¯ããªã¨åãã«ãªã)ã
       ã¾ããããã§ãªãã£ãå ´åã®ææã°ã«ã¼ãã¯ããã»ã¹ã®å®å¹ã°ã«ã¼ã ID ã¨ãªãã

è¿ãå¤
       mknod()  ã¯æåããå ´å 0 ãã失æããå ´å -1 ãè¿ã (失æããå ´å errno
       ãã¨ã©ã¼ã®å容ã«ãããã£ã¦ã»ããããã)ã

ã¨ã©ã¼
       EACCES ããã»ã¹ã親ãã£ã¬ã¯ããªã¸ã®æ¸ãè¾¼ã¿è¨±å¯ãæããªãã ãããã¯ãã¹å pathname
              ä¸ã®ãã£ã¬ã¯ããªé¨åã®ã©ããã«æ¤ç´¢è¨±å¯å±æ§ãç¡ã (path_resolution(7)
              ãåç§ãããã¨)ã

       EDQUOT The user's quota of disk blocks or inodes on the file system has
              been exhausted.

       EEXIST pathname ããã§ã«åå¨ããã ããã«ã¯ pathname
              ãã·ã³ããªãã¯ãªã³ã¯ã§ããå ´åãå«ã¾ãã (ã·ã³ããªãã¯ãªã³ã¯ããªã³ã¯åãã
              (dangling) ã©ããã¯é¢ä¿ãªã)ã

       EFAULT pathname ããã®ããã»ã¹ã®ã¢ã¯ã»ã¹å¯è½ãªã¢ãã¬ã¹ç©ºéã®å¤ãæãã¦ããã

       EINVAL mode ãé常ã®ãã¡ã¤ã«ã»ããã¤ã¹ã¹ãã·ã£ã«ãã¡ã¤ã«ã»FIFOã»ã½ã±ãã以å¤ã
              ä½æããããã«ã»ããããã¦ããã

       ELOOP  ãã¹å pathname ã解決ããã¨ãã«ãå«ã¾ãã¦ããã·ã³ããªãã¯ãªã³ã¯ãå¤ãããã

       ENAMETOOLONG
              pathname ãé·éããã

       ENOENT pathname ä¸ã®ãã£ã¬ã¯ããªé¨åãåå¨ããªãã
              ãããã¯ãªã³ã¯åã®ç¡ãã·ã³ããªãã¯ãªã³ã¯ã§ããã

       ENOMEM ååãªã«ã¼ãã«ã¡ã¢ãªãç¡ãã

       ENOSPC pathname ã®ããããã¤ã¹ã«æ°ãã«ãã¼ããä½æãã空ããç¡ãã

       ENOTDIR
              pathname ä¸ã®ãã£ã¬ã¯ããªè¦ç´ ããå®éã«ã¯ãã£ã¬ã¯ããªã§ãªãã

       EPERM  mode ã¯é常ã®ãã¡ã¤ã«ã»FIFO (ååä»ããã¤ã)ã»UNIX ãã¡ã¤ã³ã½ã±ãã以å¤ã
              ä½æããããã«ã»ããããã¦ããããå®è¡èãç¹æ¨© (Linux ã§ã¯ CAP_MKNOD
              ã±ã¼ãããªã㣠(capability)) ãæã£ã¦ããªãã ã¾ã㯠pathname
              ãä¿æãããã¡ã¤ã«ã·ã¹ãã ããæå®ããããã¼ãå½¢å¼ããµãã¼ããã¦ããªãã

       EROFS  pathname ãèªã¿åºãå°ç¨ãã¡ã¤ã«ã·ã¹ãã ä¸ã®ãã¡ã¤ã«ãæãã¦ããã

æºæ
       SVr4, 4.4BSD, POSIX.1-2001 (ä¸è¨ãåç§).

注æ
       POSIX.1-2001 ã§ã¯æ¬¡ã®ããã«æ¸ãã¦ããï¼ ãmknod()
       ã®å¯ä¸ã®ç§»æ¤æ§ã®ãã使ç¨æ³ã¯ãFIFO ã¹ãã·ã£ã«ãã¡ã¤ã«ãä½æãããã¨ã§ããã mode ã
       S_IFIFO ã§ã¯ãªãå ´åãã¾ã㯠dev ã 0 ã§ã¯ãªãå ´åã mknod()
       ã®æåã¯è¦å®ããã¦ããªããã ããããªãããç¾å¨ã§ã¯ãã®ç®çã®ããã« mknod()
       ã使ç¨ãã¹ãã§ã¯ãªãããã®ç®çã®ããã«ç¹å¥ã«å®ç¾©ãããé¢æ°ã§ãã mkfifo()
       ã使ç¨ãã¹ãã§ããã

       Linux ã§ã¯ããã£ã¬ã¯ããªãä½æããããã« ãã®å¼ã³åºãã使ç¨ãããã¨ã¯ã§ããªãã
       ãã£ã¬ã¯ããªã¯ mkdir(2)  ã§ä½æãã¹ãã§ããã

       NFS ãå®ç¾ãã¦ãããããã³ã«ã«ã¯å¤ãã®ä¸åãåå¨ãã ãããã®ããã¤ã㯠mknod()
       ã«å½±é¿ãä¸ããã

é¢é£é ç®
       chmod(2), chown(2), fcntl(2), mkdir(2), mknodat(2), mount(2),
       socket(2), stat(2), umask(2), unlink(2), makedev(3), mkfifo(3),
       path_resolution(7)

ãã®ææ¸ã«ã¤ãã¦
       ãã® man ãã¼ã¸ã¯ Linux man-pages ããã¸ã§ã¯ãã®ãªãªã¼ã¹ 3.51 ã®ä¸é¨
       ã§ãããããã¸ã§ã¯ãã®èª¬æã¨ãã°å ±åã«é¢ããæå ±ã¯
       http://www.kernel.org/doc/man-pages/ ã«æ¸ããã¦ããã



Linux                             2013-01-27                          MKNOD(2)