summaryrefslogtreecommitdiffstats
path: root/tests/ts/mount/regfile
blob: 4f5ce303ac00840afafec08707b833631d54ca9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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