Skip to contentSkip to conversation

proc(5): clarify the root symlink and mount namespaces

PATCH Superseded Mike Frysinger 2 participants 7 messages Oct 6, 2016 – Oct 7, 2016 5 messages not in the archive Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 proc(5): clarify the root symlink and mount namespaces

If the target process is in a different mount namespace, the root symlink actually shows that view of the filesystem. As an example:
/* Terminal 1 */

$ unshare -Urnm
17168

/* Terminal 2 */

---
 man5/proc.5 | 4 ++++
 1 file changed, 4 insertions(+)
man5/proc.5 +4 -0
index 3a5f4407c657..0680902c54a5 100644
@@ -1513,6 +1513,10 @@ root directory, and behaves in the same way as
 and
 .IR fd/* .
 
+Note however that this file is not merely a symlink.
+It provides the same view of the filesystem (including namespaces and the
+set of per-process mounts) as the process itself.
+
 .\" The following was still true as at kernel 2.6.13
 In a multithreaded process, the contents of this symbolic link
 are not available if the main thread has already terminated
Signature · 6 lines
2.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
In reply to a message not in the archive

Hi Mike,

Quoted 7 lines · Mike Frysinger

If the target process is in a different mount namespace, the root symlink actually shows that view of the filesystem. As an example:
/* Terminal 1 */

$ unshare -Urnm
17168

/* Terminal 2 */

Your example appears to have been truncated. It'd be nice to have the complete example for the commit message. Could you send that?

Thanks,

Michael

Quoted 21 lines
---
 man5/proc.5 | 4 ++++
 1 file changed, 4 insertions(+)
man5/proc.5 +4 -0
index 3a5f4407c657..0680902c54a5 100644
@@ -1513,6 +1513,10 @@ root directory, and behaves in the same way as
 and
 .IR fd/* .
 
+Note however that this file is not merely a symlink.
+It provides the same view of the filesystem (including namespaces and the
+set of per-process mounts) as the process itself.
+
 .\" The following was still true as at kernel 2.6.13
 In a multithreaded process, the contents of this symbolic link
 are not available if the main thread has already terminated
Signature · 7 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw

PATCH v2 1/1 proc(5): clarify the root symlink and mount namespaces

In reply to a message not in the archive

If the target process is in a different mount namespace, the root symlink actually shows that view of the filesystem. As an example:
/* Terminal 1 */

 $ unshare -Urnm
 # mount -t tmpfs tmpfs /etc
 # mount --bind /bin /dev
 # echo $$
 17168

/* Terminal 2 */

 # ls /etc                          # Normal view of /etc files.
 # ls /proc/17168/root/etc          # Empty view of the tmpfs.
 # ls /dev                          # Normal view of /dev files.
 # ls /proc/17168/root/dev          # Contents of /bin files.

---
v2
- restore examples

 man5/proc.5 | 4 ++++
 1 file changed, 4 insertions(+)
man5/proc.5 +4 -0
index 3a5f4407c657..0680902c54a5 100644
@@ -1513,6 +1513,10 @@ root directory, and behaves in the same way as
 and
 .IR fd/* .
 
+Note however that this file is not merely a symlink.
+It provides the same view of the filesystem (including namespaces and the
+set of per-process mounts) as the process itself.
+
 .\" The following was still true as at kernel 2.6.13
 In a multithreaded process, the contents of this symbolic link
 are not available if the main thread has already terminated
Signature · 6 lines
2.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw
In reply to a message not in the archive
Quoted 11 lines · Michael Kerrisk (man-pages)
Quoted 7 lines · Mike Frysinger

If the target process is in a different mount namespace, the root symlink actually shows that view of the filesystem. As an example:
/* Terminal 1 */

$ unshare -Urnm
17168

/* Terminal 2 */

Your example appears to have been truncated. It'd be nice to have the complete example for the commit message. Could you send that?

blah, i sometimes forget that git eats lines that start with a #, so trying to use that as your root prompt messes things up. -mike

#7 lore raw
In reply to a message not in the archive

Hi Mike,

Quoted 9 lines · Mike Frysinger

If the target process is in a different mount namespace, the root symlink actually shows that view of the filesystem. As an example:
/* Terminal 1 */

 $ unshare -Urnm
 # mount -t tmpfs tmpfs /etc
 # mount --bind /bin /dev
 # echo $$
 17168
Quoted 5 lines

/* Terminal 2 */

 # ls /etc                          # Normal view of /etc files.
 # ls /proc/17168/root/etc          # Empty view of the tmpfs.
 # ls /dev                          # Normal view of /dev files.
 # ls /proc/17168/root/dev          # Contents of /bin files.

Thanks for the patch! And thanks for the commit message, which is I think actually useful text for the man page itself, so I added it (in somewhat modified form) to the page itself.

Cheers,

Michael

Quoted 24 lines

---
v2
- restore examples

 man5/proc.5 | 4 ++++
 1 file changed, 4 insertions(+)
man5/proc.5 +4 -0
index 3a5f4407c657..0680902c54a5 100644
@@ -1513,6 +1513,10 @@ root directory, and behaves in the same way as
 and
 .IR fd/* .
 
+Note however that this file is not merely a symlink.
+It provides the same view of the filesystem (including namespaces and the
+set of per-process mounts) as the process itself.
+
 .\" The following was still true as at kernel 2.6.13
 In a multithreaded process, the contents of this symbolic link
 are not available if the main thread has already terminated
Signature · 7 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#9 lore raw
In reply to a message not in the archive
Quoted 16 lines · Michael Kerrisk (man-pages)
Quoted 9 lines · Mike Frysinger

If the target process is in a different mount namespace, the root symlink actually shows that view of the filesystem. As an example:
/* Terminal 1 */

 $ unshare -Urnm
 # mount -t tmpfs tmpfs /etc
 # mount --bind /bin /dev
 # echo $$
 17168
Quoted 5 lines

/* Terminal 2 */

 # ls /etc                          # Normal view of /etc files.
 # ls /proc/17168/root/etc          # Empty view of the tmpfs.
 # ls /dev                          # Normal view of /dev files.
 # ls /proc/17168/root/dev          # Contents of /bin files.
Quoted 3 lines

Thanks for the patch! And thanks for the commit message, which is I think actually useful text for the man page itself, so I added it (in somewhat modified form) to the page itself.

looks like some formatting is off ?
-mike

man5/proc.5 +3 -3
@@ -1525,7 +1525,7 @@ and in that shell we create some new mount points:
 $ \fBPS1='sh1# ' unshare \-Urnm\fP
 sh1# \fBmount \-t tmpfs tmpfs /etc\fP  # Mount empty tmpfs at /etc
 sh1# \fBmount \-\-bind /usr /dev\fP     # Mount /usr at /dev
-sh1# \fBecho $$
+sh1# \fBecho $$\fP
 27123
 .in
 .fi
@@ -1533,10 +1533,10 @@ sh1# \fBecho $$
 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:
-    
+
 .nf
 .in +4n
-$ \fBPS1='sh2# ' sudo sh
+$ \fBPS1='sh2# ' sudo sh\fP
 sh2# \fBls /etc | wc \-l\fP                  # In initial NS
 309
 sh2# \fBls /proc/27123/root/etc | wc \-l\fP  # /etc in other NS
#11 lore raw
In reply to a message not in the archive
Quoted 17 lines · Mike Frysinger
Quoted 16 lines · Michael Kerrisk (man-pages)
Quoted 14 lines · Mike Frysinger

If the target process is in a different mount namespace, the root symlink actually shows that view of the filesystem. As an example:
/* Terminal 1 */

 $ unshare -Urnm
 # mount -t tmpfs tmpfs /etc
 # mount --bind /bin /dev
 # echo $$
 17168

/* Terminal 2 */

 # ls /etc                          # Normal view of /etc files.
 # ls /proc/17168/root/etc          # Empty view of the tmpfs.
 # ls /dev                          # Normal view of /dev files.
 # ls /proc/17168/root/dev          # Contents of /bin files.
Quoted 5 lines
Quoted 3 lines

Thanks for the patch! And thanks for the commit message, which is I think actually useful text for the man page itself, so I added it (in somewhat modified form) to the page itself.

looks like some formatting is off ?

Thanks, Mike. Patch applied.

Cheers,

Michael

Quoted 25 lines
man5/proc.5 +3 -3
@@ -1525,7 +1525,7 @@ and in that shell we create some new mount points:
 $ \fBPS1='sh1# ' unshare \-Urnm\fP
 sh1# \fBmount \-t tmpfs tmpfs /etc\fP  # Mount empty tmpfs at /etc
 sh1# \fBmount \-\-bind /usr /dev\fP     # Mount /usr at /dev
-sh1# \fBecho $$
+sh1# \fBecho $$\fP
 27123
 .in
 .fi
@@ -1533,10 +1533,10 @@ sh1# \fBecho $$
 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:
-    
+
 .nf
 .in +4n
-$ \fBPS1='sh2# ' sudo sh
+$ \fBPS1='sh2# ' sudo sh\fP
 sh2# \fBls /etc | wc \-l\fP                  # In initial NS
 309
 sh2# \fBls /proc/27123/root/etc | wc \-l\fP  # /etc in other NS
Signature · 7 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html