]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
tools/run_privatens: check if it is mount point for --make-private
authorNaohiro Aota <naohiro.aota@wdc.com>
Mon, 3 Mar 2025 06:42:09 +0000 (15:42 +0900)
committerZorro Lang <zlang@kernel.org>
Thu, 6 Mar 2025 13:25:54 +0000 (21:25 +0800)
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 <naohiro.aota@wdc.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tools/run_privatens

index df94974ab30c3c2ab97827485735a6732ec02415..dbb28d74417fe55406d2acaf9070499e225fd7ca 100755 (executable)
@@ -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