Patchwork block/curl.c: Refuse to open the handle for writes.

login
register
mail settings
Submitter Richard W.M. Jones
Date June 10, 2013, 10:06 a.m.
Message ID <1370858796-16217-2-git-send-email-rjones@redhat.com>
Download mbox | patch
Permalink /patch/250205/
State New
Headers show

Comments

Richard W.M. Jones - June 10, 2013, 10:06 a.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>
---
 block/curl.c | 4 ++++
 1 file changed, 4 insertions(+)
Kevin Wolf - June 10, 2013, 11:24 a.m.
Am 10.06.2013 um 12:06 hat Richard W.M. Jones geschrieben:
> 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>
> ---
>  block/curl.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/block/curl.c b/block/curl.c
> index b8935fd..f1e302b 100644
> --- a/block/curl.c
> +++ b/block/curl.c
> @@ -406,6 +406,10 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags)
>  
>      static int inited = 0;
>  
> +    if (flags & BDRV_O_RDWR) {
> +        return -ENOTSUP;
> +    }
> +

Thanks, I applied this patch to the block branch for now, but I think a
v2 with some better error reporting wouldn't hurt. We can either add a
qerror_report() call or at least change the error code to -EROFS or
something like that.

Kevin

Patch

diff --git a/block/curl.c b/block/curl.c
index b8935fd..f1e302b 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -406,6 +406,10 @@  static int curl_open(BlockDriverState *bs, QDict *options, int flags)
 
     static int inited = 0;
 
+    if (flags & BDRV_O_RDWR) {
+        return -ENOTSUP;
+    }
+
     opts = qemu_opts_create_nofail(&runtime_opts);
     qemu_opts_absorb_qdict(opts, options, &local_err);
     if (error_is_set(&local_err)) {