pivot_root

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



åå
       pivot_root - root ãã¡ã¤ã«ã·ã¹ãã ãå¤æ´ãã

æ¸å¼
       int pivot_root(const char *new_root, const char *put_old);

       注: ãã®ã·ã¹ãã ã³ã¼ã«ã«ã¯ glibc ã®ã©ããã¼é¢æ°ã¯åå¨ããªããã注æãã®ç¯ãåç§ã

説æ
       pivot_root()  ã¯å¼ã³åºãåã®ããã»ã¹ã® root ãã¡ã¤ã«ã·ã¹ãã ã put_old
       ãã£ã¬ã¯ããªã«ç§»åãã new_root ãå¼ã³åºãåã®ããã»ã¹ã®æ°ãã root
       ãã¡ã¤ã«ã·ã¹ãã ã«ããã

       pivot_root()  ã®å¸åçãªå©ç¨æ³ã¯ãã·ã¹ãã ã®èµ·åä¸ã«ã·ã¹ãã ãä¸æç㪠root
       ãã¡ã¤ã«ã·ã¹ãã  (ä¾ãã° initrd) ããã¦ã³ãããããã«ç¶ãã¦æ¬å½ã® root
       ãã¡ã¤ã«ã·ã¹ãã ããã¦ã³ããã å¾èãå¿è¦ãªå¨ã¦ã®ããã»ã¹ã»ã¹ã¬ããã® ã«ã¬ã³ã root
       ã«å¤æ´ãããããªå ´åã§ããã

       å¤ã root ãã£ã¬ã¯ããªã使ã£ã¦ããå¨ã¦ã®ããã»ã¹ãã¹ã¬ããã® ã«ã¬ã³ã root
       ã¨ã«ã¬ã³ãã¯ã¼ãã³ã°ãã£ã¬ã¯ããªãã pivot_root()  ãå¤æ´ãããã©ããã¯ããããªãã
       pivot_root()  ã®å¼ã³ã ãããã»ã¹ã¯ãå¤ã root ãã«ã¬ã³ãã¯ã¼ã‐
       ã³ã°ãã£ã¬ã¯ããªã使ã£ã¦ãã ããã»ã¹ãããããã®å ´åã§ãæ‐
       £ããåä½ãããã¨ãä¿è¨¼ããªããã°ãªããªãã ãããç°¡åã«è¡ãã«ã¯ããããã®ããã»ã¹ã® root ã¨
       ã«ã¬ã³ãã¯ã¼ãã³ã°ãã£ã¬ã¯ããªã pivot_root()  ãå¼ã³åºãåã« new_root
       ã«å¤æ´ãã¦ãããã¨ã§ããã

       ä¸è¨ã®æ®µè½ã¯ãå°æ¥ pivot_root()
       ãå¤æ´ãããããç¥ããªããã¨ãéã¿ã¦ãããã¨ææ§ã«æ¸ãã¦ããã æ¬ãã¼ã¸ãè¨è¿°ãã¦ããæç¹ã§ã¯ã
       pivot_root()  ã¯å¤ã root ãã£ã¬ã¯ããªãç¨ãã¦ããå¨ã¦ã®ããã»ã¹ã»ã¹ã¬ããã® root
       㨠ã«ã¬ã³ãã¯ã¼ãã³ã°ãã£ã¬ã¯ããªã new_root
       ã«å¤æ´ãããããã¯ã«ã¼ãã«ã®ã¹ã¬ãããå¤ã root ãã£ã¬ã¯ããªã busy
       ç¶æã«ããªãããã«å¿è¦ã§ããããããã®ã¹ã¬ããã å¤ããã£ã¬ã¯ããªã root ãã«ã¬ã³ãã¯ã¼ã‐
       ã³ã°ãã£ã¬ã¯ããªã¨ãã¦ããã¨ã ãã¡ã¤ã«ã·ã¹ãã ã«ä¸åã¢ã¯ã»ã¹ããªãå ´åã§ã å¤ã
       root ã busy ã«ãªã£ã¦ãã¾ãããã§ããã
       å°æ¥ã¯ãã«ã¼ãã«ã¹ã¬ããããããããã¡ã¤ã«ã·ã¹ãã ã¸ã®ã¢ã¯ã»ã¹ã
       æ示çã«æ¾æ£ããã¡ã«ããºã ãã§ãããã®ã§ããã°ããªæ©è½ã¯ pivot_root()
       ããåé¤ããããããããªãã

       ããã¯å¼ã³åºãåã®ããã»ã¹ã«ã¤ãã¦ãå½ã¦ã¯ã¾ããã¨ã«æ³¨æã pivot_root()
       ãã«ã¬ã³ãããã»ã¹ã®ã«ã¬ã³ãã¯ã¼ãã³ã°ãã£ã¬ã¯ããªã«å½±é¿ãããã©ããã¯
       åãããªãããããã£ã¦ pivot_root()  ã®ç´å¾ã« chdir("/") ãå¼ã³åºãã¨ããã

       new_root ããã³ put_old ã«ã¯ä»¥ä¸ã®å¶éããã:

       -  ãã£ã¬ã¯ããªã§ãªããã°ãªããªãã

       -  new_root 㨠put_old ã¯ç¾å¨ã® root ã¨åããã¡ã¤ã«ã·ã¹ãã ã«ãã£ã¦ã¯ãªããªãã

       -  put_old 㯠new_root 以ä¸ã«ãªããã°ãªããªããããªãã¡ put_old ãå·®ãæååã« 1
          å以ä¸ã® ../ ãä»ãããã¨ã«ãã£ã¦ new_root
          ã¨åããã£ã¬ã¯ããªãå¾ãããªããã°ãªããªãã

       -  ä»ã®ãã¡ã¤ã«ã·ã¹ãã ã put_old ã«ãã¦ã³ãããã¦ãã¦ã¯ãªããªãã

       å©ç¨ä¾ã«ã¤ãã¦ã¯ pivot_root(8)  ãåç§ã®ãã¨ã

       ç¾å¨ã® root ããã¦ã³ããã¤ã³ãã§ã¯ãªã (chroot(2)  ã pivot_root()
       ã®å¾ãªã©ã以ä¸ãåç§) å ´åã å¤ã root ãã£ã¬ã¯ããªã§ã¯ãªãã
       ãã®ãã¡ã¤ã«ã·ã¹ãã ã®ãã¦ã³ããã¤ã³ãã put_old ã«ãã¦ã³ããããã

       new_root ã¯ãã¦ã³ããã¤ã³ãã§ãªãã¦ãããã ãã®å ´å /proc/mounts ã¯ã new_root ã
       root (/)  ã¨ãããã¡ã¤ã«ã·ã¹ãã ã®ãã¦ã³ããã¤ã³ãã表示ããã

è¿ãå¤
       æåããå ´å㯠0 ãè¿ããããã¨ã©ã¼ã®å ´å㯠-1 ãè¿ããã errno ãé©åã«è¨å®ãããã

ã¨ã©ã¼
       pivot_root()  㯠stat(2)  ã®è¿ãããããã¨ã©ã¼ã (errno ã«)
       è¿ãå¯è½æ§ããããããã«ä»¥ä¸ãè¿ããã¨ããã:

       EBUSY  new_root ã¾ã㯠put_old ããç¾å¨ã® root ãã¡ã¤ã«ã·ã¹ãã ä¸ã«ããããæ¢ã«
              put_old ã«ãªãããã®ãã¡ã¤ã«ã·ã¹ãã ããã¦ã³ãããã¦ããã

       EINVAL put_old ã new_root ã®ä¸å±¤ã«ãªãã

       ENOTDIR
              new_root ã¾ã㯠put_old ããã£ã¬ã¯ããªã§ãªãã

       EPERM  å¼ã³åºãåã®ããã»ã¹ã CAP_SYS_ADMIN ã±ã¼ãããªãã£ãæã£ã¦ããªãã

ãã¼ã¸ã§ã³
       pivot_root()  㯠Linux 2.3.41 ã§å°å¥ãããã

æºæ
       pivot_root()  㯠Linux ã«åºæã®ãã®ãªã®ã§ã移æ¤æ§ã¯ãªãã

注æ
       glibc ã¯ãã®ã·ã¹ãã ã³ã¼ã«ã«å¯¾ããã©ããã¼é¢æ°ãæä¾ãã¦ããªãã syscall(2)
       ã使ã£ã¦å¼ã³åºããã¨ã

ãã°
       pivot_root()  ã¯ã·ã¹ãã ã®ä»ã®ããã»ã¹å¨ã¦ã® root 㨠ã«ã¬ã³ãã¯ã¼ã‐
       ã³ã°ãã£ã¬ã¯ããªã¨ãå¤æ´ããªãã¦ãããã¯ãã§ããã

       pivot_root()  ã®ä½¿ãæ¹ãããã¡ãã£ã¨ææ§ã«ãªãã¨ã
       ãã£ã¨ããéã«ããã®ããããªãç¶æã«ãªã£ã¦ãã¾ãã ãã

é¢é£é ç®
       chdir(2), chroot(2), stat(2), initrd(4), pivot_root(8)

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



Linux                             2012-07-13                     PIVOT_ROOT(2)