WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] Fix losetup -f not working on SLES10

To: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] Fix losetup -f not working on SLES10
From: Gary Grebus <Gary.Grebus@xxxxxxxxxx>
Date: Fri, 11 Dec 2009 15:58:50 -0500
Cc: Andre Przywara <andre.przywara@xxxxxxx>
Delivery-date: Fri, 11 Dec 2009 13:00:39 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.23 (X11/20090825)
Andre,

Does this fix the problem for you?

        /gary


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

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"

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] Fix losetup -f not working on SLES10, Gary Grebus <=