From: Gary Grebus <Gary.Grebus@oracle.com>
To: xen-devel <xen-devel@lists.xensource.com>
Cc: Andre Przywara <andre.przywara@amd.com>
Subject: [PATCH] Fix losetup -f not working on SLES10
Date: Fri, 11 Dec 2009 15:58:50 -0500 [thread overview]
Message-ID: <4B22B28A.3090102@oracle.com> (raw)
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"
reply other threads:[~2009-12-11 20:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B22B28A.3090102@oracle.com \
--to=gary.grebus@oracle.com \
--cc=andre.przywara@amd.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.