All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix losetup -f not working on SLES10
@ 2009-12-11 20:58 Gary Grebus
  0 siblings, 0 replies; only message in thread
From: Gary Grebus @ 2009-12-11 20:58 UTC (permalink / raw)
  To: xen-devel; +Cc: Andre Przywara

Andre,

Does this fix the problem for you?

	/gary


Signed-off-by: Gary Grebus <gary.grebus@oracle.com>

diff -r b928797213ac tools/hotplug/Linux/block
--- a/tools/hotplug/Linux/block	Fri Dec 11 09:17:09 2009 +0000
+++ b/tools/hotplug/Linux/block	Fri Dec 11 15:44:43 2009 -0500
@@ -16,6 +16,26 @@
   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 @@
           done
         fi

-        loopdev=$(losetup -f)
+        loopdev=$(find_free_loopback_dev)
         if [ "$loopdev" = '' ]
         then
           release_lock "block"

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-12-11 20:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-11 20:58 [PATCH] Fix losetup -f not working on SLES10 Gary Grebus

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.