Patchwork [PULL,3/7] block/curl.c: Refuse to open the handle for writes.

login
register
mail settings
Submitter Kevin Wolf
Date June 17, 2013, 4:31 p.m.
Message ID <1371486710-17793-4-git-send-email-kwolf@redhat.com>
Download mbox | patch
Permalink /patch/251921/
State New
Headers show

Comments

Kevin Wolf - June 17, 2013, 4:31 p.m.
From: "Richard W.M. Jones" <rjones@redhat.com>

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/curl.c | 6 ++++++
 1 file changed, 6 insertions(+)

Patch

diff --git a/block/curl.c b/block/curl.c
index 4dc3b4b..0fba451 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -406,6 +406,12 @@  static int curl_open(BlockDriverState *bs, QDict *options, int flags)
 
     static int inited = 0;
 
+    if (flags & BDRV_O_RDWR) {
+        qerror_report(ERROR_CLASS_GENERIC_ERROR,
+                      "curl block device does not support writes");
+        return -EROFS;
+    }
+
     opts = qemu_opts_create_nofail(&runtime_opts);
     qemu_opts_absorb_qdict(opts, options, &local_err);
     if (error_is_set(&local_err)) {