From 59b088f10d43de187f5f1ae4c5b8f29fff5ad3ad Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Tue, 16 Jun 2009 16:21:09 +0300 Subject: [PATCH] raw-posix: Remove O_RDWR when attempting to open a file read-only 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 Signed-off-by: Anthony Liguori --- block/raw-posix.c | 1 + 1 file changed, 1 insertion(+) 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 { -- 2.7.4