diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 13:14:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 13:14:44 +0000 |
commit | 30ff6afe596eddafacf22b1a5b2d1a3d6254ea15 (patch) | |
tree | 9b788335f92174baf7ee18f03ca8330b8c19ce2b /tests/ts/mount/shared-subtree | |
parent | Initial commit. (diff) | |
download | util-linux-upstream.tar.xz util-linux-upstream.zip |
Adding upstream version 2.36.1.upstream/2.36.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-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..fe6e27d --- /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.ext3" + +[ -d $TS_MOUNTPOINT ] || mkdir -p $TS_MOUNTPOINT + +# bind +$TS_CMD_MOUNT --bind $TS_MOUNTPOINT $TS_MOUNTPOINT +[ "$?" = "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.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" +ts_device_has "TYPE" "ext3" $DEVICE || ts_die "Cannot find ext3 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 + |