summaryrefslogtreecommitdiffstats
path: root/tests/ts/mount/regfile
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ts/mount/regfile')
-rwxr-xr-xtests/ts/mount/regfile41
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
+