]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man5/proc_pid_root.5
tzfile.5: ffix
[thirdparty/man-pages.git] / man5 / proc_pid_root.5
CommitLineData
ee5ec1d2
AC
1.\" Copyright (C) 1994, 1995, Daniel Quinlan <quinlan@yggdrasil.com>
2.\" Copyright (C) 2002-2008, 2017, Michael Kerrisk <mtk.manpages@gmail.com>
3.\" Copyright (C) 2023, Alejandro Colomar <alx@kernel.org>
4.\"
5.\" SPDX-License-Identifier: GPL-3.0-or-later
6.\"
7.TH proc_pid_root 5 (date) "Linux man-pages (unreleased)"
8.SH NAME
9/proc/pid/root/ \- symbolic link to root directory
10.SH DESCRIPTION
11.TP
12.IR /proc/ pid /root/
13UNIX and Linux support the idea of a per-process root of the
14filesystem, set by the
15.BR chroot (2)
16system call.
17This file is a symbolic link that points to the process's
18root directory, and behaves in the same way as
19.IR exe ,
20and
21.IR fd/* .
22.IP
23Note however that this file is not merely a symbolic link.
24It provides the same view of the filesystem (including namespaces and the
25set of per-process mounts) as the process itself.
26An example illustrates this point.
27In one terminal, we start a shell in new user and mount namespaces,
28and in that shell we create some new mounts:
29.IP
30.in +4n
31.EX
32$ \fBPS1=\[aq]sh1# \[aq] unshare \-Urnm\fP
33sh1# \fBmount \-t tmpfs tmpfs /etc\fP # Mount empty tmpfs at /etc
34sh1# \fBmount \-\-bind /usr /dev\fP # Mount /usr at /dev
35sh1# \fBecho $$\fP
3627123
37.EE
38.in
39.IP
40In a second terminal window, in the initial mount namespace,
41we look at the contents of the corresponding mounts in
42the initial and new namespaces:
43.IP
44.in +4n
45.EX
46$ \fBPS1=\[aq]sh2# \[aq] sudo sh\fP
47sh2# \fBls /etc | wc \-l\fP # In initial NS
48309
49sh2# \fBls /proc/27123/root/etc | wc \-l\fP # /etc in other NS
500 # The empty tmpfs dir
51sh2# \fBls /dev | wc \-l\fP # In initial NS
52205
53sh2# \fBls /proc/27123/root/dev | wc \-l\fP # /dev in other NS
5411 # Actually bind
55 # mounted to /usr
56sh2# \fBls /usr | wc \-l\fP # /usr in initial NS
5711
58.EE
59.in
60.IP
61.\" The following was still true as at kernel 2.6.13
62In a multithreaded process, the contents of the
63.IR /proc/ pid /root
64symbolic link are not available if the main thread has already terminated
65(typically by calling
66.BR pthread_exit (3)).
67.IP
68Permission to dereference or read
69.RB ( readlink (2))
70this symbolic link is governed by a ptrace access mode
71.B PTRACE_MODE_READ_FSCREDS
72check; see
73.BR ptrace (2).
74.SH SEE ALSO
75.BR proc (5)