]> git.ipfire.org Git - thirdparty/util-linux.git/commit
libmount: change propagation of /run for X-mount.subdir
authorKarel Zak <kzak@redhat.com>
Thu, 12 Aug 2021 10:12:39 +0000 (12:12 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 12 Aug 2021 10:12:39 +0000 (12:12 +0200)
commit315e8f634a7936532d08cd5ab056cd875d2a262e
tree7b1db333dd68bfa4f2e246faf1f96582cc90c21f
parent7ae195affb0ea5fb9b777a7a2e89f4d2a69bd578
libmount: change propagation of /run for X-mount.subdir

We do not need to create a new mount node from /run/mount/tmptgt
(where we mount filesystem root), because /run is already mount
node in all mainstream distros, and we can use MS_PRIVATE for
this top-level directory. There is still fallback if /run is
on root filesystem.

This solution reduces number of mount operations, with the patch the
subdir implementation is:

 * open current namespace from /proc/self/ns/mnt
 * mkdir /run/mount/tmptg (if it does not exist)
 * make /run private by mount(MS_PRIVATE)
 * mount filesystem to /run/mount/tmptg
 * bind mount /run/mount/tmptg/<subdir> to <target>
 * umount /run/mount/tmptg
 * setns() to the original namespace

Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/utils.c