From mboxrd@z Thu Jan 1 00:00:00 1970 From: Zhignag Wang Subject: [PATCH]Enable loopback disk image files on readonly nfs filesystem Date: Tue, 06 Nov 2007 20:08:41 -0800 Message-ID: <47313A49.8040904@oracle.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------010005000005030100020006" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------010005000005030100020006 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi all, This small patch enables you to loopback disk image files on readonly nfs filesystem on some system. When we losetup a file on readonly nfs filesystem, it fails with: # losetup /dev/loop7 /data/vm/xen_el5_i386_para/system.raw /data/vm/xen_el5_i386_para/system.raw: Permission denied New version of losetup has add a "-r" option for readonly loop, which Linux kernel has supported for a long time. Some distribution (EL5 update, Fedora 8, etc.) have shipped it. This patch benefit this option while doesn't break the old versions of losetup. Signed-off-by: Zhigang Wang regards, zhigang --------------010005000005030100020006 Content-Type: text/x-patch; name="losetup-readonly.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="losetup-readonly.patch" --- xen-unstable/tools/examples/block.orig 2007-11-06 20:01:53.000000000 -0800 +++ xen-unstable/tools/examples/block 2007-11-06 20:03:14.000000000 -0800 @@ -326,7 +326,10 @@ fatal 'Failed to find an unused loop device' fi - do_or_die losetup "$loopdev" "$file" + status=$(losetup "$loopdev" "$file" || echo "failed") + if [ -n "$status" ]; then + do_or_die losetup -r "$loopdev" "$file" + fi xenstore_write "$XENBUS_PATH/node" "$loopdev" write_dev "$loopdev" release_lock "block" --------------010005000005030100020006 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------010005000005030100020006--