This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
Home Products Support Community News


[Xen-changelog] Cope when the filename returned by losetup for an existi

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Cope when the filename returned by losetup for an existing loop device is not
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 03 Mar 2006 20:42:08 +0000
Delivery-date: Fri, 03 Mar 2006 20:42:48 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User emellor@xxxxxxxxxxxxxxxxxxxxxx
# Node ID 871f768aadc621cf5e44e090c30293074aa27033
# Parent  1a1e3dcbbf19401bb13ff5f304bd2ab65f0af720
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

Closes bug #553.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>

diff -r 1a1e3dcbbf19 -r 871f768aadc6 tools/examples/block
--- a/tools/examples/block      Thu Mar  2 20:45:13 2006
+++ b/tools/examples/block      Fri Mar  3 14:32:42 2006
@@ -321,7 +321,28 @@
-            f=$(readlink -f "$f")
+            # Canonicalise the filename for the comparison.
+            # I have seen this readlink fails because the filename given by
+            # losetup is only the basename.  This cannot happen when the loop
+            # device is set up through this script, because file is
+            # canonicalised above, but it may happen when loop devices are set
+            # up some other way.  This readlink may also conceivably fail if
+            # the file backing this loop device has been removed.
+            # For maximum safety, in the case that $f does not resolve, we
+            # assume that $file and $f are in the same directory.
+            # If you create a loopback filesystem, remove it and continue to
+            # run on it, and then create another file with the same name, then
+            # this check will block that -- don't do that.
+            # If you create loop devices through some other mechanism, use
+            # relative filenames, and then use the same filename through this
+            # script, then this check will block that -- don't do that either.
+            f=$(readlink -f "$f" || echo $(dirname "$file")/$(basename "$f"))
             if [ "$f" == "$file" ]

Xen-changelog mailing list

<Prev in Thread] Current Thread [Next in Thread>