From 840e93eac9605df0345320b10238e71cc6e20c9b Mon Sep 17 00:00:00 2001 From: Krzysztof Molon Date: Thu, 16 Jul 2026 10:04:13 +0200 Subject: [PATCH] test: fix bind mount test to work without /dev/shm mounted Replace the two /proc/mounts-based bind mount assertions with stat-based device number comparisons. The old tests parsed /proc/mounts entries with sed, which is fragile: /proc/mounts does not distinguish bind mounts from their source mount. The new tests use stat -c %d to compare device numbers: - bind mount: verify /dev/shm and /mnt share the same device - tmpfs mount: verify /dev/shm and /mnt have different devices This works regardless of whether /dev/shm is a separate tmpfs mountpoint or just a subdirectory of /dev. --- test/bst.t | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/test/bst.t b/test/bst.t index 24fa899..d054072 100755 --- a/test/bst.t +++ b/test/bst.t @@ -55,12 +55,9 @@ Testing mount semantics $ bst --mount tmp,/tmp,tmpfs,defaults sh -c 'tail -n 1 /proc/mounts | sed -Ee "s/,uid=[[:digit:]]+,gid=[[:digit:]]+//" -e "s/,seclabel//" -e "s/,inode64//"' tmp /tmp tmpfs rw,relatime 0 0 - $ [ "$(bst --mount /dev/shm,/mnt,none,bind sh -c 'tail -n 1 /proc/mounts | sed -Ee "s/,uid=[[:digit:]]+,gid=[[:digit:]]+//" -e "s|/mnt|/dev/shm|"')" = "$(grep /dev/shm /proc/mounts | sed -Ee "s/,uid=[[:digit:]]+,gid=[[:digit:]]+//")" ] + $ bst --mount /dev/shm,/mnt,none,bind sh -c 'test "$(stat -c %d /dev/shm)" = "$(stat -c %d /mnt)"' - - $ act=$(bst --mount /dev/shm,/mnt,none,bind sh -c 'tail -n 1 /proc/mounts | sed -Ee "s/,uid=[[:digit:]]+,gid=[[:digit:]]+//" -e "s|/mnt|/dev/shm|"') - > exp=$(grep /dev/shm /proc/mounts | sed -Ee "s/,uid=[[:digit:]]+,gid=[[:digit:]]+//") - > [ "$exp" = "$act" ] || echo -e "-$exp\n+$act" + $ bst --mount tmp,/mnt,tmpfs,defaults sh -c 'test "$(stat -c %d /dev/shm)" != "$(stat -c %d /mnt)"' $ bst --mount tmp,/tmp,tmpfs,dirsync,noatime,nodev,nodiratime,noexec,nosuid,relatime,ro,silent,strictatime,sync sh -c 'tail -n 1 /proc/mounts | sed -Ee "s/,uid=[[:digit:]]+,gid=[[:digit:]]+//" -e "s/,seclabel//" -e "s/,inode64//"' tmp /tmp tmpfs ro,sync,dirsync,nosuid,nodev,noexec,nodiratime 0 0