aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2009-06-16 16:21:09 +0300
committerAnthony Liguori <aliguori@us.ibm.com>2009-06-16 15:18:35 -0500
commit11a1feb6552e3a4709e454faea5e3be5ca8d9e6a (patch)
tree52b7ccb48188e499129d28958a5108039c42f1d3 /block
parent736d0c25ed3e13a3af3d24524c05be1bb1ff5158 (diff)
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 <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'block')
-rw-r--r--block/raw-posix.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/block/raw-posix.c b/block/raw-posix.c
index 5790206741..ccb014a4d1 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 {