* open current namespace from /proc/self/ns/mnt
* mkdir /tmp/mount/mount.<pid>
* unshare mount namespace
* create mount node from /tmp/mount/mount.<pid> by mount(MS_BIND)
* mark /tmp/mount/mount.<pid> private by mount(MS_PRIVATE|MS_REC)
* bind mount /tmp/mount/mount.<pid>/subdir to <target>
* umount /tmp/mount/mount.<pid>
* rmdir /tmp/mount/mount.<pid>
* setns() to the original namespace
Note that /tmp/mount/mount.<pid> conversion to mount node and call for
MS_PRIVATE are visible (propagated to the system) if /tmp is a shared
filesystem, the rest (all operations with the desired filesystem) is
atomic for a parental namespace.
Maybe one day it will be possible to reimplement it in more
elegant way with new mount kernel APIs (open_tree(), etc.).
Fixes: https://github.com/karelzak/util-linux/issues/1103 Signed-off-by: Karel Zak <kzak@redhat.com>