diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 02:42:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 02:42:50 +0000 |
commit | 8cb83eee5a58b1fad74c34094ce3afb9e430b5a4 (patch) | |
tree | a9b2e7baeca1be40eb734371e3c8b11b02294497 /tests/ts/mount/regfile | |
parent | Initial commit. (diff) | |
download | util-linux-8cb83eee5a58b1fad74c34094ce3afb9e430b5a4.tar.xz util-linux-8cb83eee5a58b1fad74c34094ce3afb9e430b5a4.zip |
Adding upstream version 2.33.1.upstream/2.33.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ts/mount/regfile')
-rwxr-xr-x | tests/ts/mount/regfile | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/ts/mount/regfile b/tests/ts/mount/regfile new file mode 100755 index 0000000..4f5ce30 --- /dev/null +++ b/tests/ts/mount/regfile @@ -0,0 +1,41 @@ +#!/bin/bash + +# Copyright (C) 2011 Karel Zak <kzak@redhat.com> +# This file is part of util-linux. + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="regular file" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_MOUNT" +ts_check_test_command "$TS_CMD_UMOUNT" + +ts_skip_nonroot +ts_check_losetup +ts_check_prog "mkfs.ext3" + +IMAGE=$(ts_image_init) +mkfs.ext3 -F $IMAGE &> /dev/null || ts_die "Cannot make ext3 on $IMAGE" + +[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT + +$TS_CMD_MOUNT $IMAGE $TS_MOUNTPOINT >> $TS_OUTPUT 2>&1 + +DEVICE=$(awk '/regfile/ { print $1 }' /proc/mounts) + +ts_is_mounted "$TS_MOUNTPOINT" || ts_die "Cannot find $TS_MOUNTPOINT in /proc/mounts" + +if [ -f "/sys/block/$(basename $DEVICE)/loop/backing_file" ]; then + $TS_CMD_UMOUNT $IMAGE || ts_die "Cannot umount $IMAGE" +else + $TS_CMD_UMOUNT $TS_MOUNTPOINT &> /dev/null + ts_skip "too old kernel" +fi + +ts_is_mounted "$TS_MOUNTPOINT" && ts_die "$TS_MOUNTPOINT still in /proc/mounts" + +ts_log "Success" +ts_finalize + |