qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Ryota Ozaki <ozaki.ryota@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/3] qemu-nbd: Extend read-only option to nbd	device file
Date: Mon, 29 Mar 2010 12:54:56 +0200	[thread overview]
Message-ID: <4BB08700.90806@redhat.com> (raw)
In-Reply-To: <1269796032-9166-2-git-send-email-ozaki.ryota@gmail.com>

Am 28.03.2010 19:07, schrieb Ryota Ozaki:
> This patch allows to operate on nbd device file
> without write permission for the file if read-only
> option is specified.
> 
> Signed-off-by: Ryota Ozaki <ozaki.ryota@gmail.com>

The help for -r should be changed, too. Currently it says:

-r, --read-only      export read-only

> ---
>  qemu-nbd.c |   10 +++++-----
>  1 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/qemu-nbd.c b/qemu-nbd.c
> index 00b8896..7ef409f 100644
> --- a/qemu-nbd.c
> +++ b/qemu-nbd.c
> @@ -162,7 +162,7 @@ static int find_partition(BlockDriverState *bs, int partition,
>      return -1;
>  }
>  
> -static void show_parts(const char *device)
> +static void show_parts(const char *device, bool readonly)
>  {
>      if (fork() == 0) {
>          int nbd;
> @@ -172,7 +172,7 @@ static void show_parts(const char *device)
>           * but remember to load the module with max_part != 0 :
>           *     modprobe nbd max_part=63
>           */
> -        nbd = open(device, O_RDWR);
> +        nbd = open(device, readonly ? O_RDONLY : O_RDWR);
>          if (nbd != -1) {
>                close(nbd);
>          }

Can't we always use O_RDONLY here? Assuming that this is enough to
trigger a partition table update, I haven't tested it. But if it's not
enough, wouldn't be enough for readonly either.

Kevin

  reply	other threads:[~2010-03-29 10:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-28 17:07 [Qemu-devel] [PATCH 1/3] qemu-nbd: Fix coding style Ryota Ozaki
2010-03-28 17:07 ` [Qemu-devel] [PATCH 2/3] qemu-nbd: Extend read-only option to nbd device file Ryota Ozaki
2010-03-29 10:54   ` Kevin Wolf [this message]
2010-05-02 21:51     ` Ryota Ozaki
2010-03-28 17:07 ` [Qemu-devel] [PATCH 3/3] qemu-nbd: Improve error reporting Ryota Ozaki
2010-03-29 11:03   ` Kevin Wolf
2010-05-02 21:52     ` Ryota Ozaki
2010-05-03 17:01     ` Anthony Liguori
2010-05-04  7:29       ` Kevin Wolf
2010-03-29 10:44 ` [Qemu-devel] [PATCH 1/3] qemu-nbd: Fix coding style Kevin Wolf
2010-05-02 21:50   ` Ryota Ozaki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4BB08700.90806@redhat.com \
    --to=kwolf@redhat.com \
    --cc=ozaki.ryota@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).