From: Naohiro Aota Date: Mon, 3 Mar 2025 06:42:09 +0000 (+0900) Subject: tools/run_privatens: check if it is mount point for --make-private X-Git-Tag: v2025.03.09~75 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6fe33ea3a3247d847c8ee583f0299409061dfa7d;p=xfstests-dev.git tools/run_privatens: check if it is mount point for --make-private While /tmp is mounted with tmpfs in the most setup, it still can be a non-mount point. For example, I'm running the fstests in a container, which does not mount /tmp inside the container. Running any test case on such system results in having the following error printed, which leads to all the test cases fail due to the output difference. mount: /tmp: not mount point or bad option. dmesg(1) may have more information after failed mount system call. These lines are printed by the "mount --make-private" command. So, fix that by using mountpoint command to check if the directory is a mount point or not. Fixes: 247ab01fa227 ("check: run tests in a private pid/mount namespace") Signed-off-by: Naohiro Aota Reviewed-by: Darrick J. Wong Signed-off-by: Zorro Lang --- diff --git a/tools/run_privatens b/tools/run_privatens index df94974a..dbb28d74 100755 --- a/tools/run_privatens +++ b/tools/run_privatens @@ -7,9 +7,15 @@ # and /proc so that child process trees cannot interfere with each other. if [ -n "${FSTESTS_ISOL}" ]; then + # Don't allow changes to these mountpoints to propagate + # outside of our mount namespace... for path in /proc /tmp; do - mount --make-private "$path" + mountpoint "$path" >/dev/null && \ + mount --make-private "$path" done + + # ...because here we create new mounts that are private + # to this mount namespace that we don't want to escape. mount -t proc proc /proc mount -t tmpfs tmpfs /tmp