From: Tomas Racek Date: Tue, 12 Feb 2013 09:21:59 +0000 (+0000) Subject: xfstests: Add new standard loop handling functions X-Git-Tag: v2022.05.01~3542 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=29fe8007e75bf8983fa1267ae2850787262f17c1;p=xfstests-dev.git xfstests: Add new standard loop handling functions Add _create_loop_device and _destroy_loop_device to uniformly handle loopback devices. V1->V2: Fix possible race Signed-off-by: Tomas Racek Reviewed-by: Rich Johnston Signed-off-by: Rich Johnston --- diff --git a/common.rc b/common.rc index 0cccb94b..2f4a9f40 100644 --- a/common.rc +++ b/common.rc @@ -1833,6 +1833,19 @@ _require_dumpe2fs() fi } +_create_loop_device() +{ + file=$1 + dev=`losetup -f --show $file` || _fail "Cannot assign $file to a loop device" + echo $dev +} + +_destroy_loop_device() +{ + dev=$1 + losetup -d $dev || _fail "Cannot destroy loop device $dev" +} + ################################################################################ if [ "$iam" != new -a "$iam" != bench ]