From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MGXgw-0006XB-4y for qemu-devel@nongnu.org; Tue, 16 Jun 2009 08:23:06 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MGXgp-0006Ug-Kd for qemu-devel@nongnu.org; Tue, 16 Jun 2009 08:23:04 -0400 Received: from [199.232.76.173] (port=33455 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MGXgp-0006UT-D0 for qemu-devel@nongnu.org; Tue, 16 Jun 2009 08:22:59 -0400 Received: from mx2.redhat.com ([66.187.237.31]:37207) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MGXgo-0008Le-UJ for qemu-devel@nongnu.org; Tue, 16 Jun 2009 08:22:59 -0400 From: Avi Kivity Date: Tue, 16 Jun 2009 15:22:52 +0300 Message-Id: <1245154972-21581-3-git-send-email-avi@redhat.com> In-Reply-To: <1245154972-21581-1-git-send-email-avi@redhat.com> References: <1245154972-21581-1-git-send-email-avi@redhat.com> Subject: [Qemu-devel] [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: Anthony Liguori Cc: qemu-devel@nongnu.org, Christoph Hellwig 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..7536a72 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -136,6 +136,7 @@ static int raw_open_common(BlockDriverState *bs, const char *filename, if ((flags & BDRV_O_ACCESS) == BDRV_O_RDWR) { s->open_flags |= O_RDWR; } else { + s->open_flags &= ~O_RDWR; s->open_flags |= O_RDONLY; bs->read_only = 1; } -- 1.6.0.6