Re: Improving documentation of parent-ID field in /proc/PID/mountinfo

From: Miklos Szeredi
Date: Mon Nov 20 2017 - 04:22:26 EST


On Mon, Nov 20, 2017 at 10:07 AM, Michael Kerrisk (man-pages)
<mtk.manpages@xxxxxxxxx> wrote:

> But, the problem is that the existing description is at best misleading:
>
> (2) parent ID: the ID of the parent mount (or of self for
> the top of the mount tree).
>
> That implies that we'll find one line in the list where field 1 and
> field 2 are the same. But we don't, because the mountns rootfs entry
> is not shown in mountinfo. On top of that, the reader is left
> confused, because when they look at mountinfo, they see one entry
> where the parent-ID doesn't exist in the list. So, something more than
> the current text is required. After digging around in the kernel
> source and noticing that chroot() will also cause this scenario, and
> taking into account your comments, I revised the text to:
>
> (2) parent ID: the ID of the parent mount (or of self for
> the root of this mount namespace's mount tree).
>
> If the parent mount point lies outside the process's
> root directory (see chroot(2)), the ID shown here
> won't have a corresponding record in mountinfo 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 mountinfo). As a speâ
> cial case of this point, the process's root mount
> point may have a parent mount (for the initramfs
> filesystem) that lies outside the process's root
> directory, and an entry for that mount point will not
> appear in mountinfo.
>
> How does that seem?

Perfect.

Thanks,
Miklos