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-devel

[Xen-devel] tools/examples/block better use of losetup -r

To: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] tools/examples/block better use of losetup -r
From: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
Date: Wed, 19 Dec 2007 11:49:26 +0000
Delivery-date: Wed, 19 Dec 2007 03:52:22 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
The attached change arranges to 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.

Ian.

Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>

Index: xen-unstable.hg/tools/examples/block
===================================================================
--- xen-unstable.hg.orig/tools/examples/block   2007-12-19 10:54:05.000000000 
+0000
+++ xen-unstable.hg/tools/examples/block        2007-12-19 11:47:44.000000000 
+0000
@@ -327,10 +327,13 @@
           fatal 'Failed to find an unused loop device'
         fi
 
-        status=$(losetup "$loopdev" "$file" || echo "failed")
-        if [ -n "$status" ]; then
-          do_or_die losetup -r "$loopdev" "$file"
+        if LANG=C losetup -h 2>&1 | grep read-only >/dev/null
+        then
+          roflag="-$mode"; roflag="${roflag#-w}"
+        else
+          roflag=''
         fi
+        do_or_die losetup $roflag "$loopdev" "$file"
         xenstore_write "$XENBUS_PATH/node" "$loopdev"
         write_dev "$loopdev"
         release_lock "block"
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] tools/examples/block better use of losetup -r, Ian Jackson <=