ia64/xen-unstable

changeset 9128:871f768aadc6

Cope when the filename returned by losetup for an existing loop device is not
fully qualified. In this case, the readlink -f call to canonicalise that name
fails.

Closes bug #553.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Fri Mar 03 15:32:42 2006 +0100 (2006-03-03)
parents 1a1e3dcbbf19
children 2274f293af41
files tools/examples/block
line diff
     1.1 --- a/tools/examples/block	Thu Mar 02 21:45:13 2006 +0100
     1.2 +++ b/tools/examples/block	Fri Mar 03 15:32:42 2006 +0100
     1.3 @@ -321,7 +321,28 @@ mount it read-write in a guest domain."
     1.4                fi
     1.5              fi
     1.6  
     1.7 -            f=$(readlink -f "$f")
     1.8 +            # Canonicalise the filename for the comparison.
     1.9 +
    1.10 +            # I have seen this readlink fails because the filename given by
    1.11 +            # losetup is only the basename.  This cannot happen when the loop
    1.12 +            # device is set up through this script, because file is
    1.13 +            # canonicalised above, but it may happen when loop devices are set
    1.14 +            # up some other way.  This readlink may also conceivably fail if
    1.15 +            # the file backing this loop device has been removed.
    1.16 +
    1.17 +            # For maximum safety, in the case that $f does not resolve, we
    1.18 +            # assume that $file and $f are in the same directory.
    1.19 +
    1.20 +            # If you create a loopback filesystem, remove it and continue to
    1.21 +            # run on it, and then create another file with the same name, then
    1.22 +            # this check will block that -- don't do that.
    1.23 +
    1.24 +            # If you create loop devices through some other mechanism, use
    1.25 +            # relative filenames, and then use the same filename through this
    1.26 +            # script, then this check will block that -- don't do that either.
    1.27 +
    1.28 +            f=$(readlink -f "$f" || echo $(dirname "$file")/$(basename "$f"))
    1.29 +
    1.30  
    1.31              if [ "$f" == "$file" ]
    1.32              then