Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MGYj5-0005hJ-PS for qemu-devel@nongnu.org; Tue, 16 Jun 2009 09:29:23 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MGYj2-0005gH-2P for qemu-devel@nongnu.org; Tue, 16 Jun 2009 09:29:23 -0400 Received: from [199.232.76.173] (port=37025 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MGYj1-0005gE-O0 for qemu-devel@nongnu.org; Tue, 16 Jun 2009 09:29:19 -0400 Received: from verein.lst.de ([213.95.11.210]:60723) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA1:24) (Exim 4.60) (envelope-from ) id 1MGYj1-0004rH-7E for qemu-devel@nongnu.org; Tue, 16 Jun 2009 09:29:19 -0400 Date: Tue, 16 Jun 2009 15:29:16 +0200 From: Christoph Hellwig Message-ID: <20090616132916.GB7521@lst.de> References: <1245158469-29498-1-git-send-email-avi@redhat.com> <1245158469-29498-3-git-send-email-avi@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1245158469-29498-3-git-send-email-avi@redhat.com> Subject: [Qemu-devel] Re: [PATCH 2/2] raw-posix: Remove O_RDWR when attempting to open a file read-only List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: qemu-devel@nongnu.org, Christoph Hellwig On Tue, Jun 16, 2009 at 04:21:09PM +0300, Avi Kivity wrote: > When we open a file, we first attempt to open it read-write, then fall back > to read-only. Unfortunately we reuse the flags from the previous attempt, > so both attempts try to open the file with write permissions, and fail. > > Fix by clearing the O_RDWR flag from the previous attempt. > > Signed-off-by: Avi Kivity > --- > block/raw-posix.c | 1 + > 1 files changed, 1 insertions(+), 0 deletions(-) > > diff --git a/block/raw-posix.c b/block/raw-posix.c > index 5790206..ccb014a 100644 > --- a/block/raw-posix.c > +++ b/block/raw-posix.c > @@ -133,6 +133,7 @@ static int raw_open_common(BlockDriverState *bs, const char *filename, > s->lseek_err_cnt = 0; > > s->open_flags |= O_BINARY; > + s->open_flags &= ~O_ACCMODE; > if ((flags & BDRV_O_ACCESS) == BDRV_O_RDWR) { > s->open_flags |= O_RDWR; > } else { Also looks good.