From d6a0ddc8bd2928a28930ea24d344a48027317169 Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Sat, 9 Feb 2013 01:05:45 +0100 Subject: [PATCH] dom0: make block-snapshot more robust about finding the right loop dev Use losetup -j to find already assigned loop device, instead of manually parsing losetup -a output (which have changed between fc13 and fc18). --- misc/block-snapshot | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/misc/block-snapshot b/misc/block-snapshot index c57cad4..1285c46 100755 --- a/misc/block-snapshot +++ b/misc/block-snapshot @@ -28,21 +28,12 @@ get_dev() { if [ -f "$dev" ]; then file=$dev - inode=$(stat -c '%i' "$file") - devnum=$(stat -c '%D' "$file") - if [ -z "$inode" ] || [ -z "$devnum" ] - then - release_lock "block" - fatal "Unable to lookup $file: dev: $devnum inode: $inode" - fi - - dev_list=$(losetup -a | grep ' \[0*'${devnum}'\]:'${inode} | cut -d : -f 1) - for loopdev in $dev_list; do + loopdev=$(losetup -j $file | head -1 | cut -d : -f 1) + if [ -n "$loopdev" ]; then # found existing loop to this file echo $loopdev return - done - + fi # assign new loop device loopdev=$(losetup -f 2>/dev/null || find_free_loopback_dev)