ia64/xen-unstable
changeset 8205:5e617fd48504
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>
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>
author | emellor@leeni.uk.xensource.com |
---|---|
date | Sat Dec 03 00:51:36 2005 +0000 (2005-12-03) |
parents | 114946d9937f |
children | 5ff5117291ad b20641d24272 |
files | tools/examples/block |
line diff
1.1 --- a/tools/examples/block Fri Dec 02 22:27:04 2005 +0000 1.2 +++ b/tools/examples/block Sat Dec 03 00:51:36 2005 +0000 1.3 @@ -250,7 +250,7 @@ case "$command" in 1.4 file) 1.5 # Canonicalise the file, for sharing check comparison, and the mode 1.6 # for ease of use here. 1.7 - file=$(readlink -f "$p") 1.8 + file=$(readlink -f "$p") || fatal "$p does not exist." 1.9 mode=$(canonicalise_mode "$mode") 1.10 1.11 claim_lock "block" 1.12 @@ -271,8 +271,7 @@ mount it read-write in a guest domain." 1.13 continue 1.14 fi 1.15 1.16 - f=$(losetup "$dev" 2>/dev/null) || f='()' 1.17 - f=$(echo "$f" | sed -e 's/.*(\(.*\)).*/\1/g') 1.18 + f=$(losetup "$dev" 2>/dev/null) || f='' 1.19 1.20 if [ "$f" ] 1.21 then 1.22 @@ -282,6 +281,38 @@ mount it read-write in a guest domain." 1.23 continue 1.24 fi 1.25 1.26 + f=$(echo "$f" | sed -e 's/.*(\(.*\)).*/\1/g') 1.27 + 1.28 + # $f is the filename, as read from losetup, but the loopback 1.29 + # driver truncates filenames at 64 characters, so we need to go 1.30 + # trawling through the store if it's longer than that. Truncation 1.31 + # is indicated by an asterisk at the end of the filename. 1.32 + if expr index "$f" '*' >/dev/null 1.33 + then 1.34 + found="" 1.35 + for dom in $(xenstore-list "$XENBUS_BASE_PATH") 1.36 + do 1.37 + for domdev in $(xenstore-list "$XENBUS_BASE_PATH/$dom") 1.38 + do 1.39 + d=$(xenstore_read_default \ 1.40 + "$XENBUS_BASE_PATH/$dom/$domdev/node" "") 1.41 + if [ "$d" == "$dev" ] 1.42 + then 1.43 + f=$(xenstore_read "$XENBUS_BASE_PATH/$dom/$domdev/params") 1.44 + found=1 1.45 + break 2 1.46 + fi 1.47 + done 1.48 + done 1.49 + 1.50 + if [ ! "$found" ] 1.51 + then 1.52 + # This loopback device is in use by someone else, so skip it. 1.53 + log debug "Loopback sharing check skips device $dev." 1.54 + continue 1.55 + fi 1.56 + fi 1.57 + 1.58 f=$(readlink -f "$f") 1.59 1.60 if [ "$f" == "$file" ]