qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [PATCH 2/2] raw-posix: Remove O_RDWR when attempting to


From: Christoph Hellwig
Subject: [Qemu-devel] Re: [PATCH 2/2] raw-posix: Remove O_RDWR when attempting to open a file read-only
Date: Tue, 16 Jun 2009 15:29:16 +0200
User-agent: Mutt/1.3.28i

On Tue, Jun 16, 2009 at 04:21:09PM +0300, Avi Kivity wrote:
> 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..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 {

Also looks good.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]