[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 2/2] raw-posix: Remove O_RDWR when attempting to
From: |
Kevin Wolf |
Subject: |
Re: [Qemu-devel] [PATCH 2/2] raw-posix: Remove O_RDWR when attempting to open a file read-only |
Date: |
Tue, 16 Jun 2009 15:12:23 +0200 |
User-agent: |
Thunderbird 2.0.0.21 (X11/20090320) |
Avi Kivity schrieb:
> 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 <address@hidden>
> ---
> 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;
> }
Does the standard say anything about the values of the constants?
Wouldn't it be cleaner to have a s->open_flags &= ~O_ACCMODE before the
if instead, so that O_RDONLY is reset in the other case?
Kevin