WARNING - OLD ARCHIVES

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/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Read from the store if the filename reported by losetup

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Read from the store if the filename reported by losetup has been truncated (the
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Sat, 03 Dec 2005 12:04:16 +0000
Delivery-date: Sat, 03 Dec 2005 12:05:42 +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 5e617fd4850427ac4ac235969b36d78935103f19
# Parent  114946d9937f15620cac11fc531781db56779829
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@xxxxxxxxxxxxx>

diff -r 114946d9937f -r 5e617fd48504 tools/examples/block
--- a/tools/examples/block      Fri Dec  2 22:27:04 2005
+++ b/tools/examples/block      Sat Dec  3 00:51:36 2005
@@ -250,7 +250,7 @@
       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 @@
             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
@@ -280,6 +279,38 @@
             if [ "$mode" == '!' ]
             then
               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")

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Read from the store if the filename reported by losetup has been truncated (the, Xen patchbot -unstable <=