ia64/xen-unstable

changeset 16642:643ab64d12d5

tools/examples/block better use of losetup -r

Use losetup -r when the vbd is specified to be readonly, but only if
-r is supported (rather than always creating a writeable losetup
mapping if possible).

This was inspired by (but not derived from) a diff from the Fedora 8
patchset which uses -r iff the vbd is specified as readonly. We need
to be cleverer upstream because not all systems have losetup -r.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Dec 19 15:05:15 2007 +0000 (2007-12-19)
parents b0c85bc56f9e
children 35ab2bb25e09
files tools/examples/block
line diff
     1.1 --- a/tools/examples/block	Wed Dec 19 15:02:05 2007 +0000
     1.2 +++ b/tools/examples/block	Wed Dec 19 15:05:15 2007 +0000
     1.3 @@ -327,10 +327,13 @@ mount it read-write in a guest domain."
     1.4            fatal 'Failed to find an unused loop device'
     1.5          fi
     1.6  
     1.7 -        status=$(losetup "$loopdev" "$file" || echo "failed")
     1.8 -        if [ -n "$status" ]; then
     1.9 -          do_or_die losetup -r "$loopdev" "$file"
    1.10 +        if LANG=C losetup -h 2>&1 | grep read-only >/dev/null
    1.11 +        then
    1.12 +          roflag="-$mode"; roflag="${roflag#-w}"
    1.13 +        else
    1.14 +          roflag=''
    1.15          fi
    1.16 +        do_or_die losetup $roflag "$loopdev" "$file"
    1.17          xenstore_write "$XENBUS_PATH/node" "$loopdev"
    1.18          write_dev "$loopdev"
    1.19          release_lock "block"