diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 19:10:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 19:10:49 +0000 |
commit | cfe5e3905201349e9cf3f95d52ff4bd100bde37d (patch) | |
tree | d0baf160cbee3195249d095f85e52d20c21acf02 /tests/ts/mount/shared-subtree | |
parent | Initial commit. (diff) | |
download | util-linux-cfe5e3905201349e9cf3f95d52ff4bd100bde37d.tar.xz util-linux-cfe5e3905201349e9cf3f95d52ff4bd100bde37d.zip |
Adding upstream version 2.39.3.upstream/2.39.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ts/mount/shared-subtree')
-rwxr-xr-x | tests/ts/mount/shared-subtree | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/tests/ts/mount/shared-subtree b/tests/ts/mount/shared-subtree new file mode 100755 index 0000000..aaaaf64 --- /dev/null +++ b/tests/ts/mount/shared-subtree @@ -0,0 +1,87 @@ +#!/bin/bash + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="shared-subtree" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" +ts_check_test_command "$TS_CMD_FINDMNT" + +ts_skip_nonroot +ts_check_losetup +ts_check_prog "mkfs.ext2" + +[ -d $TS_MOUNTPOINT ] || mkdir -p $TS_MOUNTPOINT + +# bind +$TS_CMD_MOUNT --bind $TS_MOUNTPOINT $TS_MOUNTPOINT &> /dev/null +[ "$?" = "0" ] || ts_die "error: mount --bind" + +# check the bind +$TS_CMD_FINDMNT --kernel --mountpoint $TS_MOUNTPOINT &> /dev/null +[ "$?" == "0" ] || ts_die "Cannot find binded $TS_MOUNTPOINT in /proc/self/mountinfo" + +# use the same mounpoint for all sub-tests +MOUNTPOINT="$TS_MOUNTPOINT" + + +ts_init_subtest "make-shared" +$TS_CMD_MOUNT --make-shared $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_FINDMNT -nr --mountpoint $MOUNTPOINT -o PROPAGATION >> $TS_OUTPUT +ts_finalize_subtest + +ts_init_subtest "make-private" +$TS_CMD_MOUNT --make-private $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_FINDMNT -nr --mountpoint $MOUNTPOINT -o PROPAGATION >> $TS_OUTPUT +ts_finalize_subtest + + +ts_init_subtest "make-unbindable" +$TS_CMD_MOUNT --make-unbindable $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_FINDMNT -nr --mountpoint $MOUNTPOINT -o PROPAGATION >> $TS_OUTPUT +ts_finalize_subtest + +# clean up +$TS_CMD_UMOUNT $MOUNTPOINT + + +ts_init_subtest "bind-shared" +$TS_CMD_MOUNT --make-shared \ + --bind $MOUNTPOINT $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_FINDMNT -nr --mountpoint $MOUNTPOINT -o PROPAGATION >> $TS_OUTPUT +$TS_CMD_UMOUNT $MOUNTPOINT +ts_finalize_subtest + + +# +# block dev based mounts +# +ts_device_init +DEVICE=$TS_LODEV + +mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE" +ts_device_has "TYPE" "ext2" $DEVICE || ts_die "Cannot find ext2 on $DEVICE" + + +ts_init_subtest "mount-private" +$TS_CMD_MOUNT --make-private --make-unbindable \ + $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_FINDMNT -nr --mountpoint $MOUNTPOINT -o PROPAGATION >> $TS_OUTPUT +$TS_CMD_UMOUNT $MOUNTPOINT +ts_finalize_subtest + +ts_init_subtest "mount-private-ro" +$TS_CMD_MOUNT $DEVICE $MOUNTPOINT -o ro,private >> $TS_OUTPUT 2>> $TS_ERRLOG +$TS_CMD_FINDMNT -nr --mountpoint $MOUNTPOINT -o PROPAGATION >> $TS_OUTPUT +$TS_CMD_FINDMNT -nr --mountpoint $MOUNTPOINT -o VFS-OPTIONS >> $TS_OUTPUT +$TS_CMD_UMOUNT $MOUNTPOINT +ts_finalize_subtest + +rmdir $MOUNTPOINT + +ts_log "Success" +ts_finalize + |