From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NwCd9-00021n-Da for qemu-devel@nongnu.org; Mon, 29 Mar 2010 06:55:39 -0400 Received: from [140.186.70.92] (port=48039 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NwCd5-0001zx-LI for qemu-devel@nongnu.org; Mon, 29 Mar 2010 06:55:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NwCd4-0004oJ-4a for qemu-devel@nongnu.org; Mon, 29 Mar 2010 06:55:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:24895) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NwCd3-0004o7-OI for qemu-devel@nongnu.org; Mon, 29 Mar 2010 06:55:34 -0400 Message-ID: <4BB08700.90806@redhat.com> Date: Mon, 29 Mar 2010 12:54:56 +0200 From: Kevin Wolf MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 2/3] qemu-nbd: Extend read-only option to nbd device file References: <1269796032-9166-1-git-send-email-ozaki.ryota@gmail.com> <1269796032-9166-2-git-send-email-ozaki.ryota@gmail.com> In-Reply-To: <1269796032-9166-2-git-send-email-ozaki.ryota@gmail.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ryota Ozaki Cc: qemu-devel@nongnu.org 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 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