All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/2] raw-posix block driver fixes
@ 2009-06-16 12:22 Avi Kivity
  2009-06-16 12:22 ` [Qemu-devel] [PATCH 1/2] raw-posix: open flags use BDRV_ namespace, not posix namespace Avi Kivity
  2009-06-16 12:22 ` [Qemu-devel] [PATCH 2/2] raw-posix: Remove O_RDWR when attempting to open a file read-only Avi Kivity
  0 siblings, 2 replies; 6+ messages in thread
From: Avi Kivity @ 2009-06-16 12:22 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: qemu-devel, Christoph Hellwig

Fix the recent regression opening read-only files as well as using the
wrong constants for open flags.

Avi Kivity (2):
  raw-posix: open flags use BDRV_ namespace, not posix namespace
  raw-posix: Remove O_RDWR when attempting to open a file read-only

 block/raw-posix.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH 1/2] raw-posix: open flags use BDRV_ namespace, not posix namespace
  2009-06-16 12:22 [Qemu-devel] [PATCH 0/2] raw-posix block driver fixes Avi Kivity
@ 2009-06-16 12:22 ` Avi Kivity
  2009-06-16 12:22 ` [Qemu-devel] [PATCH 2/2] raw-posix: Remove O_RDWR when attempting to open a file read-only Avi Kivity
  1 sibling, 0 replies; 6+ messages in thread
From: Avi Kivity @ 2009-06-16 12:22 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: qemu-devel, Christoph Hellwig

The flags argument to raw_common_open() contain bits defined by the BDRV_O_*
namespace, not the posix O_* namespace.

Adjust to use the correct constants.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 block/raw-posix.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/block/raw-posix.c b/block/raw-posix.c
index 5032348..5790206 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -133,7 +133,7 @@ static int raw_open_common(BlockDriverState *bs, const char *filename,
     s->lseek_err_cnt = 0;
 
     s->open_flags |= O_BINARY;
-    if ((flags & BDRV_O_ACCESS) == O_RDWR) {
+    if ((flags & BDRV_O_ACCESS) == BDRV_O_RDWR) {
         s->open_flags |= O_RDWR;
     } else {
         s->open_flags |= O_RDONLY;
-- 
1.6.0.6

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH 2/2] raw-posix: Remove O_RDWR when attempting to open a file read-only
  2009-06-16 12:22 [Qemu-devel] [PATCH 0/2] raw-posix block driver fixes Avi Kivity
  2009-06-16 12:22 ` [Qemu-devel] [PATCH 1/2] raw-posix: open flags use BDRV_ namespace, not posix namespace Avi Kivity
@ 2009-06-16 12:22 ` Avi Kivity
  2009-06-16 13:12   ` Kevin Wolf
  1 sibling, 1 reply; 6+ messages in thread
From: Avi Kivity @ 2009-06-16 12:22 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: qemu-devel, Christoph Hellwig

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..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;
     }
-- 
1.6.0.6

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH 2/2] raw-posix: Remove O_RDWR when attempting to open a file read-only
  2009-06-16 12:22 ` [Qemu-devel] [PATCH 2/2] raw-posix: Remove O_RDWR when attempting to open a file read-only Avi Kivity
@ 2009-06-16 13:12   ` Kevin Wolf
  2009-06-16 13:16     ` Avi Kivity
  0 siblings, 1 reply; 6+ messages in thread
From: Kevin Wolf @ 2009-06-16 13:12 UTC (permalink / raw)
  To: Avi Kivity; +Cc: qemu-devel, Christoph Hellwig

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 <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..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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH 2/2] raw-posix: Remove O_RDWR when attempting to open a file read-only
  2009-06-16 13:12   ` Kevin Wolf
@ 2009-06-16 13:16     ` Avi Kivity
  0 siblings, 0 replies; 6+ messages in thread
From: Avi Kivity @ 2009-06-16 13:16 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: qemu-devel, Christoph Hellwig

On 06/16/2009 04:12 PM, Kevin Wolf wrote:
>> +        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?
>    

Didn't know about O_ACCMODE.  Will fix and repost.

-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH 1/2] raw-posix: open flags use BDRV_ namespace, not posix namespace
  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 ` Avi Kivity
  0 siblings, 0 replies; 6+ messages in thread
From: Avi Kivity @ 2009-06-16 13:21 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: qemu-devel, Christoph Hellwig

The flags argument to raw_common_open() contain bits defined by the BDRV_O_*
namespace, not the posix O_* namespace.

Adjust to use the correct constants.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 block/raw-posix.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/block/raw-posix.c b/block/raw-posix.c
index 5032348..5790206 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -133,7 +133,7 @@ static int raw_open_common(BlockDriverState *bs, const char *filename,
     s->lseek_err_cnt = 0;
 
     s->open_flags |= O_BINARY;
-    if ((flags & BDRV_O_ACCESS) == O_RDWR) {
+    if ((flags & BDRV_O_ACCESS) == BDRV_O_RDWR) {
         s->open_flags |= O_RDWR;
     } else {
         s->open_flags |= O_RDONLY;
-- 
1.6.0.6

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-06-16 13:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-16 12:22 [Qemu-devel] [PATCH 0/2] raw-posix block driver fixes Avi Kivity
2009-06-16 12:22 ` [Qemu-devel] [PATCH 1/2] raw-posix: open flags use BDRV_ namespace, not posix namespace Avi Kivity
2009-06-16 12:22 ` [Qemu-devel] [PATCH 2/2] raw-posix: Remove O_RDWR when attempting to open a file read-only Avi Kivity
2009-06-16 13:12   ` Kevin Wolf
2009-06-16 13:16     ` Avi Kivity
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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.