[ ! -d "$TEST_DEV" ] || export OVL_BASE_TEST_DIR="$TEST_DEV"
[ ! -d "$SCRATCH_DEV" ] || export OVL_BASE_SCRATCH_MNT="$SCRATCH_DEV"
+ # Config file may specify base fs type, but we obay -overlay flag
+ [ "$FSTYP" == overlay ] || export OVL_BASE_FSTYP="$FSTYP"
+ export FSTYP=overlay
+
# 2. SCRATCH/TEST_DEV point to the base fs partitions. In this case,
# the new OVL_BASE_SCRATCH/TEST_DEV/MNT vars are set to the values
# of the configured base fs and SCRATCH/TEST_DEV vars are set to the
# overlayfs base and mount dirs inside base fs mount.
- [ -b "$TEST_DEV" ] || [ -c "$TEST_DEV" ] || return 0
-
- # Config file may specify base fs type, but we obay -overlay flag
- [ "$FSTYP" == overlay ] || export OVL_BASE_FSTYP="$FSTYP"
- export FSTYP=overlay
+ [ -b "$TEST_DEV" ] || [ -c "$TEST_DEV" ] || [ "$OVL_BASE_FSTYP" == tmpfs ] || return 0
# Store original base fs vars
export OVL_BASE_TEST_DEV="$TEST_DEV"
export TEST_DIR="$OVL_BASE_TEST_DIR/$OVL_MNT"
export MOUNT_OPTIONS="$OVERLAY_MOUNT_OPTIONS"
- [ -b "$SCRATCH_DEV" ] || [ -c "$SCRATCH_DEV" ] || return 0
+ [ -b "$SCRATCH_DEV" ] || [ -c "$SCRATCH_DEV" ] || [ "$OVL_BASE_FSTYP" == tmpfs ] || return 0
# Store original base fs vars
export OVL_BASE_SCRATCH_DEV="$SCRATCH_DEV"
_scratch_cycle_mount()
{
local opts="$1"
+ local unmounted
+
+ case "$FSTYP" in
+ tmpfs)
+ _scratch_remount "$opts"
+ return
+ ;;
+ overlay)
+ if [ "$OVL_BASE_FSTYP" = tmpfs ]; then
+ $UMOUNT_PROG $SCRATCH_MNT
+ unmounted=true
+ fi
+ ;;
+ esac
- if [ "$FSTYP" = tmpfs ]; then
- _scratch_remount "$opts"
- return
- fi
if test -n "$opts"; then
opts="-o $opts"
fi
- _scratch_unmount
+ [ "$unmounted" = true ] || _scratch_unmount
_try_scratch_mount "$opts" || _fail "cycle mount failed"
}
_test_cycle_mount()
{
- if [ "$FSTYP" = tmpfs ]; then
- return
- fi
- _test_unmount
+ local unmounted
+
+ case "$FSTYP" in
+ tmpfs)
+ return
+ ;;
+ overlay)
+ if [ "$OVL_BASE_FSTYP" = tmpfs ]; then
+ $UMOUNT_PROG $TEST_DIR
+ unmounted=true
+ fi
+ ;;
+ esac
+
+ [ "$unmounted" = true ] || _test_unmount
_test_mount
}