proc_pid_root(5) — Linux manual page

NAME | DESCRIPTION | SEE ALSO | COLOPHON

proc_pid_root(5)           File Formats Manual          proc_pid_root(5)

NAME         top

       /proc/pid/root/ - symbolic link to root directory

DESCRIPTION         top

       /proc/pid/root/
              UNIX and Linux support the idea of a per-process root of
              the filesystem, set by the chroot(2) system call.  This
              file is a symbolic link that points to the process's root
              directory, and behaves in the same way as exe, and fd/*.

              Note however that this file is not merely a symbolic link.
              It provides the same view of the filesystem (including
              namespaces and the set of per-process mounts) as the
              process itself.  An example illustrates this point.  In
              one terminal, we start a shell in new user and mount
              namespaces, and in that shell we create some new mounts:

                  $ PS1='sh1# ' unshare -Urnm
                  sh1# mount -t tmpfs tmpfs /etc  # Mount empty tmpfs at /etc
                  sh1# mount --bind /usr /dev     # Mount /usr at /dev
                  sh1# echo $$
                  27123

              In a second terminal window, in the initial mount
              namespace, we look at the contents of the corresponding
              mounts in the initial and new namespaces:

                  $ PS1='sh2# ' sudo sh
                  sh2# ls /etc | wc -l                  # In initial NS
                  309
                  sh2# ls /proc/27123/root/etc | wc -l  # /etc in other NS
                  0                                     # The empty tmpfs dir
                  sh2# ls /dev | wc -l                  # In initial NS
                  205
                  sh2# ls /proc/27123/root/dev | wc -l  # /dev in other NS
                  11                                    # Actually bind
                                                        # mounted to /usr
                  sh2# ls /usr | wc -l                  # /usr in initial NS
                  11

              In a multithreaded process, the contents of the
              /proc/pid/root symbolic link are not available if the main
              thread has already terminated (typically by calling
              pthread_exit(3)).

              Permission to dereference or read (readlink(2)) this
              symbolic link is governed by a ptrace access mode
              PTRACE_MODE_READ_FSCREDS check; see ptrace(2).

SEE ALSO         top

       proc(5)

COLOPHON         top

       This page is part of the man-pages (Linux kernel and C library
       user-space interface documentation) project.  Information about
       the project can be found at 
       ⟨https://www.kernel.org/doc/man-pages/⟩.  If you have a bug report
       for this manual page, see
       ⟨https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/CONTRIBUTING⟩.
       This page was obtained from the tarball man-pages-6.9.1.tar.gz
       fetched from
       ⟨https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/⟩ on
       2024-06-26.  If you discover any rendering problems in this HTML
       version of the page, or you believe there is a better or more up-
       to-date source for the page, or you have corrections or
       improvements to the information in this COLOPHON (which is not
       part of the original manual page), send a mail to
       [email protected]

Linux man-pages 6.9.1          2024-05-02               proc_pid_root(5)