debuggers.hg

changeset 20677:7162eff6d085

Fix losetup -f not working on SLES10

Signed-off-by: Gary Grebus <gary.grebus@oracle.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Dec 14 07:56:21 2009 +0000 (2009-12-14)
parents db8a985693f7
children 40a598cb0e91
files tools/hotplug/Linux/block
line diff
     1.1 --- a/tools/hotplug/Linux/block	Mon Dec 14 07:55:35 2009 +0000
     1.2 +++ b/tools/hotplug/Linux/block	Mon Dec 14 07:56:21 2009 +0000
     1.3 @@ -16,6 +16,26 @@ expand_dev() {
     1.4    echo -n $dev
     1.5  }
     1.6  
     1.7 +find_free_loopback_helper() {
     1.8 +  local next_devnum=0
     1.9 +  local busy_devnum
    1.10 +  while read busy_devnum; do
    1.11 +    if [ "$next_devnum" != "$busy_devnum" ]; then
    1.12 +      break
    1.13 +    fi
    1.14 +    let next_devnum=$next_devnum+1
    1.15 +  done
    1.16 +  echo "/dev/loop${next_devnum}"
    1.17 +}
    1.18 +
    1.19 +# Not all distros have "losetup -f"
    1.20 +find_free_loopback_dev() {
    1.21 +  local loopdev
    1.22 +  loopdev=$(losetup -a | sed -e 's+^/dev/loop++' -e 's/:.*//' | find_free_loopback_helper)
    1.23 +  if [ -n "$loopdev" ] && [ -b "$loopdev" ]; then
    1.24 +    echo "$loopdev"
    1.25 +  fi
    1.26 +}
    1.27  
    1.28  ##
    1.29  # check_sharing device mode
    1.30 @@ -270,7 +290,7 @@ mount it read-write in a guest domain."
    1.31            done
    1.32          fi
    1.33  
    1.34 -        loopdev=$(losetup -f)
    1.35 +        loopdev=$(find_free_loopback_dev)
    1.36          if [ "$loopdev" = '' ]
    1.37          then
    1.38            release_lock "block"