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);

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

       mode ã¯ä½æãããã¼ãã®ãã¼ããã·ã§ã³ã¨ã¿ã¤ããæå®ããã

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

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

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

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

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


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

ã¨ã©ã¼
       EPERM  mode ã FIFO (ååä»ããã¤ã) 以å¤ã®ä½æã«ã»ããããã¦ãããå®è¡èãã¹ã¼ãã¼
              ã¦ã¼ã¶ã¼ã§ã¯ãªããã¾ã㯠pathname ä¸‐
              ã«å¾ªç°ã·ã³ããªãã¯ã»ãªã³ã¯ãå«ã¾ãããä¾ãã°ã
              èªåèªèº«ãåç§ããã·ã³ããªãã¯ã»ãªã³ã¯ãªã©ã


       EINVAL mode ãé常ãã¡ã¤ã«ãããã¤ã¹ã¹ãã·ã£ã«ãã¡ã¤ã«ãFIFO 以å¤ã«ã»ããããã¦ã
              ãã

       EEXIST pathname ãæ¢ã«åå¨ããã

       EFAULT pathname ãã¦ã¼ã¶ã¼ã®ã¢ãã¬ã¹ç©ºéå¤ãæãã¦ããã

       EACCES ããã»ã¹ã親ãã£ã¬ã¯ããªã¸ã®æ¸ãè¾¼ã¿è¨±å¯ãæããªããããã㯠pathname ä¸‐
              ã®ãã£ã¬ã¯ããªã®ã©ããã« search (execute) ãã¼ããã·ã§ã³ãç¡ãã

       ENAMETOOLONG
              pathname ãé·éããã

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

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

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

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

       ELOOP  pathname ä¸‐
              ã«å¾ªç°ã·ã³ããªãã¯ãªã³ã¯ãå«ã¾ããã循ç°ã·ã³ããªãã¯ãªã³ã¯ã¨ã¯ãã®ãª
              ã³ã¯åã«èªåèªèº«ãå«ã¾ãã¦ããã·ã³ããªãã¯ãªã³ã¯ã®ãã¨ã§ããã

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

æºæ
       SVr4 (ä½ããã®é¢æ°ã®å¼ã³åºãã«ã¯ç¹æ¨©ãå¿è¦ã¨ãªãããã㯠POSIX ã«ã¯è¦
       å®ããã¦ããªã), 4.4BSDãLinux ã®å®è£ã¯ SVr4 ã®å®è£ã¨ç°ãªãããã¤ãã® ä½æã«ã¯
       root ã®ç¹æ¨©ãå¿è¦ã§ã¯ãªããã¾ã EMULTIHOP 㨠ENOLINK 㨠EINTR
       ã®ã¨ã©ã¼ã«ã¤ãã¦ã¯è¨è¿°ããã¦ããªãã

ãã°
       mknod ã¯ãã£ã¬ã¯ããªãã½ã±ãããã¡ã¤ã«ã®ä½æã«ã¯ä½¿ç¨ã§ããªããã¾ããé常ã®ãã¡
       ã¤ã«ã®ä½æã§ãã¹ã¼ãã¼ã¦ã¼ã¶ã¼ä»¥å¤ã使ç¨ãããã¨ã¯ã§ããªãã

       NFS ã«åºã¥ããããã³ã«ã«ã¯å¤ãã®ä¸é©åãªç©ãåå¨ãã mknod ã«å½±é¿ãä¸ããã

é¢é£é ç®
       read(2), write(2), fcntl(2), close(2), unlink(2), open(2), mkdir(2),
       stat(2), umask(2), mount(2), socket(2), fopen(3).



Linux 1.0                        29 March 1994                        MKNOD(2)