[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] Fix losetup -f not working on SLES10



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1260777381 0
# Node ID 7162eff6d0854112d9b73528937bfb8a9af62c11
# Parent  db8a985693f7ce37d3daee0023266ce8758ddae7
Fix losetup -f not working on SLES10

Signed-off-by: Gary Grebus <gary.grebus@xxxxxxxxxx>
---
 tools/hotplug/Linux/block |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletion(-)

diff -r db8a985693f7 -r 7162eff6d085 tools/hotplug/Linux/block
--- a/tools/hotplug/Linux/block Mon Dec 14 07:55:35 2009 +0000
+++ b/tools/hotplug/Linux/block Mon Dec 14 07:56:21 2009 +0000
@@ -16,6 +16,26 @@ expand_dev() {
   echo -n $dev
 }
 
+find_free_loopback_helper() {
+  local next_devnum=0
+  local busy_devnum
+  while read busy_devnum; do
+    if [ "$next_devnum" != "$busy_devnum" ]; then
+      break
+    fi
+    let next_devnum=$next_devnum+1
+  done
+  echo "/dev/loop${next_devnum}"
+}
+
+# Not all distros have "losetup -f"
+find_free_loopback_dev() {
+  local loopdev
+  loopdev=$(losetup -a | sed -e 's+^/dev/loop++' -e 's/:.*//' | 
find_free_loopback_helper)
+  if [ -n "$loopdev" ] && [ -b "$loopdev" ]; then
+    echo "$loopdev"
+  fi
+}
 
 ##
 # check_sharing device mode
@@ -270,7 +290,7 @@ mount it read-write in a guest domain."
           done
         fi
 
-        loopdev=$(losetup -f)
+        loopdev=$(find_free_loopback_dev)
         if [ "$loopdev" = '' ]
         then
           release_lock "block"

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.