File block-flags.diff of Package xen

Index: xen-3.3.1-testing/tools/examples/block
===================================================================
--- xen-3.3.1-testing.orig/tools/examples/block
+++ xen-3.3.1-testing/tools/examples/block
@@ -225,11 +225,14 @@ case "$command" in
 	;;
 
       file)
+        lo_flags=""
+        [ "${mode/S}" = "$mode" ] || lo_flags="-y"
         # Canonicalise the file, for sharing check comparison, and the mode
         # for ease of use here.
         file=$(readlink -f "$p") || fatal "$p does not exist."
         test -f "$file" || fatal "$file does not exist."
         mode=$(canonicalise_mode "$mode")
+        [ "$mode" = "r" ] && lo_flags="$lo_flags -r"
 
         claim_lock "block"
 
@@ -338,12 +341,12 @@ mount it read-write in a guest domain."
             fatal 'Failed to find an unused loop device'
           fi
 
-          losetup "$loopdev" "$file" && losetup_failure="" && break
+          losetup $lo_flags "$loopdev" "$file" && losetup_failure="" && break
         done
 
         if [ "$losetup_failure" ]
         then
-          fatal 'losetup $loopdev $file'
+          fatal 'losetup $lo_flags $loopdev $file'
         fi
 
         xenstore_write "$XENBUS_PATH/node" "$loopdev"
openSUSE Build Service is sponsored by