Skip to content
Snippets Groups Projects
Commit 11a1feb6 authored by Avi Kivity's avatar Avi Kivity Committed by Anthony Liguori
Browse files

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: default avatarAvi Kivity <avi@redhat.com>
Signed-off-by: default avatarAnthony Liguori <aliguori@us.ibm.com>
parent 736d0c25
No related branches found
No related tags found
No related merge requests found
......@@ -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 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment