Skip to contentSkip to conversation

Add new standard loop handling functions

PATCH New Tomas Racek 1 participant 1 message Feb 12, 2013

lore
Share & tools
lore
#0 lore raw

PATCH v2 2/3 Add new standard loop handling functions

Add _create_loop_device and _destroy_loop_device to uniformly handle loopback devices.

V1->V2: Fix possible race

---
 common.rc | 13 +++++++++++++
 1 file changed, 13 insertions(+)
common.rc +13 -0
index 0cccb94..2f4a9f4 100644
@@ -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 ]
Signature · 6 lines
1.7.11.7

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs