From: Christoph Hellwig <hch@lst.de>
To: Avi Kivity <avi@redhat.com>
Cc: qemu-devel@nongnu.org, Christoph Hellwig <hch@lst.de>
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 [thread overview]
Message-ID: <20090616132916.GB7521@lst.de> (raw)
In-Reply-To: <1245158469-29498-3-git-send-email-avi@redhat.com>
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 <avi@redhat.com>
> ---
> 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.
next prev parent reply other threads:[~2009-06-16 13:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-16 13:21 [Qemu-devel] [PATCH 0/2] Subject: [PATCH 0/2] raw-posix block driver fixes (v2) Avi Kivity
2009-06-16 13:21 ` [Qemu-devel] [PATCH 1/2] raw-posix: open flags use BDRV_ namespace, not posix namespace Avi Kivity
2009-06-16 13:28 ` [Qemu-devel] " Christoph Hellwig
2009-06-16 13:21 ` [Qemu-devel] [PATCH 2/2] raw-posix: Remove O_RDWR when attempting to open a file read-only Avi Kivity
2009-06-16 13:29 ` Christoph Hellwig [this message]
2009-06-16 21:18 ` [Qemu-devel] " Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090616132916.GB7521@lst.de \
--to=hch@lst.de \
--cc=avi@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).