mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
overlay: deduplicate code in overlay mount helpers
factor out helpers _overlay_base_mount() and _overlay_base_umount() to reduce code duplication. Signed-off-by: Amir Goldstein <amir73il@gmail.com> Reviewed-by: Eryu Guan <eguan@redhat.com> Signed-off-by: Eryu Guan <eguan@redhat.com>
This commit is contained in:
committed by
Eryu Guan
parent
766e711f84
commit
ca5b89eb90
+29
-37
@@ -53,23 +53,31 @@ _overlay_mount()
|
||||
$* $dir $mnt
|
||||
}
|
||||
|
||||
_overlay_base_test_mount()
|
||||
_overlay_base_mount()
|
||||
{
|
||||
if [ -z "$OVL_BASE_TEST_DEV" -o -z "$OVL_BASE_TEST_DIR" ] || \
|
||||
_check_mounted_on OVL_BASE_TEST_DEV $OVL_BASE_TEST_DEV \
|
||||
OVL_BASE_TEST_DIR $OVL_BASE_TEST_DIR
|
||||
then
|
||||
local devname=$1
|
||||
local mntname=$2
|
||||
local dev=$3
|
||||
local mnt=$4
|
||||
shift 4
|
||||
|
||||
if [ -z "$dev" -o -z "$mnt" ] || \
|
||||
_check_mounted_on $devname $dev $mntname $mnt; then
|
||||
# no base fs or already mounted
|
||||
return 0
|
||||
elif [ $? -ne 1 ]
|
||||
then
|
||||
elif [ $? -ne 1 ]; then
|
||||
# base fs mounted but not on mount point
|
||||
return 1
|
||||
fi
|
||||
|
||||
_mount $TEST_FS_MOUNT_OPTS \
|
||||
$SELINUX_MOUNT_OPTIONS \
|
||||
$OVL_BASE_TEST_DEV $OVL_BASE_TEST_DIR
|
||||
_mount $* $dev $mnt
|
||||
}
|
||||
|
||||
_overlay_base_test_mount()
|
||||
{
|
||||
_overlay_base_mount OVL_BASE_TEST_DEV OVL_BASE_TEST_DIR \
|
||||
"$OVL_BASE_TEST_DEV" "$OVL_BASE_TEST_DIR" \
|
||||
$TEST_FS_MOUNT_OPTS $SELINUX_MOUNT_OPTIONS
|
||||
}
|
||||
|
||||
_overlay_test_mount()
|
||||
@@ -80,28 +88,9 @@ _overlay_test_mount()
|
||||
|
||||
_overlay_base_scratch_mount()
|
||||
{
|
||||
if [ -z "$OVL_BASE_SCRATCH_DEV" -o -z "$OVL_BASE_SCRATCH_MNT" ] || \
|
||||
_check_mounted_on OVL_BASE_SCRATCH_DEV $OVL_BASE_SCRATCH_DEV \
|
||||
OVL_BASE_SCRATCH_MNT $OVL_BASE_SCRATCH_MNT
|
||||
then
|
||||
# no base fs or already mounted
|
||||
return 0
|
||||
elif [ $? -ne 1 ]
|
||||
then
|
||||
# base fs mounted but not on mount point
|
||||
return 1
|
||||
fi
|
||||
|
||||
_mount $OVL_BASE_MOUNT_OPTIONS \
|
||||
$SELINUX_MOUNT_OPTIONS \
|
||||
$OVL_BASE_SCRATCH_DEV $OVL_BASE_SCRATCH_MNT
|
||||
}
|
||||
|
||||
_overlay_base_scratch_unmount()
|
||||
{
|
||||
[ -n "$OVL_BASE_SCRATCH_DEV" -a -n "$OVL_BASE_SCRATCH_MNT" ] || return 0
|
||||
|
||||
$UMOUNT_PROG $OVL_BASE_SCRATCH_MNT
|
||||
_overlay_base_mount OVL_BASE_SCRATCH_DEV OVL_BASE_SCRATCH_MNT \
|
||||
"$OVL_BASE_SCRATCH_DEV" "$OVL_BASE_SCRATCH_MNT" \
|
||||
$OVL_BASE_MOUNT_OPTIONS $SELINUX_MOUNT_OPTIONS
|
||||
}
|
||||
|
||||
_overlay_scratch_mount()
|
||||
@@ -110,23 +99,26 @@ _overlay_scratch_mount()
|
||||
_overlay_mount $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT $*
|
||||
}
|
||||
|
||||
_overlay_base_test_unmount()
|
||||
_overlay_base_unmount()
|
||||
{
|
||||
[ -n "$OVL_BASE_TEST_DEV" -a -n "$OVL_BASE_TEST_DIR" ] || return 0
|
||||
local dev=$1
|
||||
local mnt=$2
|
||||
|
||||
$UMOUNT_PROG $OVL_BASE_TEST_DIR
|
||||
[ -n "$dev" -a -n "$mnt" ] || return 0
|
||||
|
||||
$UMOUNT_PROG $mnt
|
||||
}
|
||||
|
||||
_overlay_test_unmount()
|
||||
{
|
||||
$UMOUNT_PROG $TEST_DIR
|
||||
_overlay_base_test_unmount
|
||||
_overlay_base_unmount "$OVL_BASE_TEST_DEV" "$OVL_BASE_TEST_DIR"
|
||||
}
|
||||
|
||||
_overlay_scratch_unmount()
|
||||
{
|
||||
$UMOUNT_PROG $SCRATCH_MNT
|
||||
_overlay_base_scratch_unmount
|
||||
_overlay_base_unmount "$OVL_BASE_SCRATCH_DEV" "$OVL_BASE_SCRATCH_MNT"
|
||||
}
|
||||
|
||||
# Require a specific overlayfs feature
|
||||
|
||||
Reference in New Issue
Block a user