2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2020 Facebook. All Rights Reserved.
5 # common functions for setting up and tearing down a dmdust device
9 local DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
10 DUST_DEV=/dev/mapper/dust-test
11 DUST_TABLE="0 $DEV_SIZE dust $SCRATCH_DEV 0 512"
12 _dmsetup_create dust-test --table "$DUST_TABLE" || \
13 _fatal "failed to create dust device"
18 _scratch_options mount
19 _mount -t $FSTYP `_common_dev_mount_options $*` $SCRATCH_OPTIONS \
20 $DUST_DEV $SCRATCH_MNT
25 $UMOUNT_PROG $SCRATCH_MNT
30 # If dmsetup load fails then we need to make sure to do resume here
31 # otherwise the umount will hang
32 $DMSETUP_PROG resume dust-test > /dev/null 2>&1
33 $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1
34 _dmsetup_remove dust-test