]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
xfstests: Add new standard loop handling functions
authorTomas Racek <tracek@redhat.com>
Tue, 12 Feb 2013 09:21:59 +0000 (09:21 +0000)
committerRich Johnston <rjohnston@sgi.com>
Tue, 26 Feb 2013 15:22:24 +0000 (09:22 -0600)
Add _create_loop_device and _destroy_loop_device to uniformly handle
loopback devices.

V1->V2: Fix possible race

Signed-off-by: Tomas Racek <tracek@redhat.com>
Reviewed-by: Rich Johnston <rjohnston@sgi.com>
Signed-off-by: Rich Johnston <rjohnston@sgi.com>
common.rc

index 0cccb94bb62f396afd66c762d86d6b8e91800fc4..2f4a9f40b58572bdd27ca2bf5a964d107c9b34d9 100644 (file)
--- 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 ]