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).
This commit is contained in:
parent
58eeda8723
commit
d6a0ddc8bd
@ -28,21 +28,12 @@ get_dev() {
|
|||||||
if [ -f "$dev" ]; then
|
if [ -f "$dev" ]; then
|
||||||
file=$dev
|
file=$dev
|
||||||
|
|
||||||
inode=$(stat -c '%i' "$file")
|
loopdev=$(losetup -j $file | head -1 | cut -d : -f 1)
|
||||||
devnum=$(stat -c '%D' "$file")
|
if [ -n "$loopdev" ]; then
|
||||||
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
|
|
||||||
# found existing loop to this file
|
# found existing loop to this file
|
||||||
echo $loopdev
|
echo $loopdev
|
||||||
return
|
return
|
||||||
done
|
fi
|
||||||
|
|
||||||
|
|
||||||
# assign new loop device
|
# assign new loop device
|
||||||
loopdev=$(losetup -f 2>/dev/null || find_free_loopback_dev)
|
loopdev=$(losetup -f 2>/dev/null || find_free_loopback_dev)
|
||||||
|
Loading…
Reference in New Issue
Block a user