aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>2005-12-03 00:51:36 +0000
committeremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>2005-12-03 00:51:36 +0000
commitffa06621c6b2b9a1c186a919154eb8d3ec3d453d (patch)
tree406dc025d831fa530570b02659dce6151a82222b
parent638a6fa6a06445602f82140f795869f91759d30b (diff)
downloadxen-ffa06621c6b2b9a1c186a919154eb8d3ec3d453d.tar.gz
xen-ffa06621c6b2b9a1c186a919154eb8d3ec3d453d.tar.bz2
xen-ffa06621c6b2b9a1c186a919154eb8d3ec3d453d.zip
Read from the store if the filename reported by losetup has been truncated (the
loop driver stores only the first 64 chars of the filename). In this case, we need to read through the store until we find the domain using the device, and read the configured filename from there instead. Signed-off-by: Ewan Mellor <ewan@xensource.com>
-rw-r--r--tools/examples/block37
1 files changed, 34 insertions, 3 deletions
diff --git a/tools/examples/block b/tools/examples/block
index e84d1fb415..b37f8fdbd4 100644
--- a/tools/examples/block
+++ b/tools/examples/block
@@ -250,7 +250,7 @@ case "$command" in
file)
# Canonicalise the file, for sharing check comparison, and the mode
# for ease of use here.
- file=$(readlink -f "$p")
+ file=$(readlink -f "$p") || fatal "$p does not exist."
mode=$(canonicalise_mode "$mode")
claim_lock "block"
@@ -271,8 +271,7 @@ mount it read-write in a guest domain."
continue
fi
- f=$(losetup "$dev" 2>/dev/null) || f='()'
- f=$(echo "$f" | sed -e 's/.*(\(.*\)).*/\1/g')
+ f=$(losetup "$dev" 2>/dev/null) || f=''
if [ "$f" ]
then
@@ -282,6 +281,38 @@ mount it read-write in a guest domain."
continue
fi
+ f=$(echo "$f" | sed -e 's/.*(\(.*\)).*/\1/g')
+
+ # $f is the filename, as read from losetup, but the loopback
+ # driver truncates filenames at 64 characters, so we need to go
+ # trawling through the store if it's longer than that. Truncation
+ # is indicated by an asterisk at the end of the filename.
+ if expr index "$f" '*' >/dev/null
+ then
+ found=""
+ for dom in $(xenstore-list "$XENBUS_BASE_PATH")
+ do
+ for domdev in $(xenstore-list "$XENBUS_BASE_PATH/$dom")
+ do
+ d=$(xenstore_read_default \
+ "$XENBUS_BASE_PATH/$dom/$domdev/node" "")
+ if [ "$d" == "$dev" ]
+ then
+ f=$(xenstore_read "$XENBUS_BASE_PATH/$dom/$domdev/params")
+ found=1
+ break 2
+ fi
+ done
+ done
+
+ if [ ! "$found" ]
+ then
+ # This loopback device is in use by someone else, so skip it.
+ log debug "Loopback sharing check skips device $dev."
+ continue
+ fi
+ fi
+
f=$(readlink -f "$f")
if [ "$f" == "$file" ]