xfs/194: actually check if we got the desired block size before proceeding
[xfstests-dev.git] / common / dmdust
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2020 Facebook.  All Rights Reserved.
4 #
5 # common functions for setting up and tearing down a dmdust device
6
7 _init_dust()
8 {
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"
14 }
15
16 _mount_dust()
17 {
18         _scratch_options mount
19         _mount -t $FSTYP `_common_dev_mount_options $*` $SCRATCH_OPTIONS \
20                 $DUST_DEV $SCRATCH_MNT
21 }
22
23 _unmount_dust()
24 {
25         $UMOUNT_PROG $SCRATCH_MNT
26 }
27
28 _cleanup_dust()
29 {
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
35 }