From 2927055043ce0710d55357f448b4f80268a2fafe Mon Sep 17 00:00:00 2001 From: Michael Kerrisk Date: Mon, 20 Nov 2017 09:59:43 +0100 Subject: [PATCH] proc.5: Rework the description of /proc/PID/mountinfo parent-ID field After comments from Miklos, and further digging in the kernel source that showed that chroot() can also result in "hidden" parent-IDs in mountinfo, I've revised the description of mountinfo. In fs/proc_namespace.cs::how_mountinfo() there is: /* mountpoints outside of chroot jail will give SEQ_SKIP on this */ err = seq_path_root(m, &mnt_path, &p->root, " \t\n\\"); if (err) goto out; I instrumented the 'if (err)' code path with printk() to show that there is indeed a record corresponding to the parent-ID for the process root that is being skipped. Reported-by: Miklos Szeredi Reviewed-by: Miklos Szeredi Signed-off-by: Michael Kerrisk --- man5/proc.5 | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/man5/proc.5 b/man5/proc.5 index 92c49f93f..f9241b51f 100644 --- a/man5/proc.5 +++ b/man5/proc.5 @@ -1243,16 +1243,25 @@ mount ID: a unique ID for the mount (may be reused after .BR umount (2)). .TP (2) -parent ID: the ID of the parent mount. -For the root mount point, -the ID shown here is a hidden mount ID associated with the mount namespace. -That ID is distinct from any of the IDs shown in -field (1) of the records shown in the +parent ID: the ID of the parent mount +(or of self for the root of this mount namespace's mount tree). +.IP +If the parent mount point lies outside the process's root directory (see +.BR chroot (2)), +the ID shown here won't have a corresponding record in .I mountinfo -file, and does not appear in field (1) in the -.I mountinfo -file in any other mount namespace. -(In the initial mount namespace, this hidden ID has the value 0.) +whose mount ID (field 1) matches this parent mount ID +(because mount points that lie outside the process's root directory +are not shown in +.IR mountinfo ). +As a special case of this point, +the process's root mount point may have a parent mount +(for the initramfs filesystem) that lies +.\" Miklos Szeredi, Nov 2017: The hidden one is the initramfs, I believe +.\" mtk: In the initial mount namespace, this hidden ID has the value 0 +outside the process's root directory, +and an entry for that mount point will not appear in +.IR mountinfo . .TP (3) major:minor: the value of