open() can also return EPERM for O_RDWR on a readonly device
authoraurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162>
Mon, 13 Oct 2008 21:08:34 +0000 (21:08 +0000)
committeraurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162>
Mon, 13 Oct 2008 21:08:34 +0000 (21:08 +0000)
Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5482 c046a42c-6fe2-441c-8c8c-71466251a162

block.c

diff --git a/block.c b/block.c
index 3eb45261643bc1f23069961efa783a0f4bcde60b..5d708baadaac3ffffc5e1d23bfb42570ac917c86 100644 (file)
--- a/block.c
+++ b/block.c
@@ -399,7 +399,7 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
     else
         open_flags = flags & ~(BDRV_O_FILE | BDRV_O_SNAPSHOT);
     ret = drv->bdrv_open(bs, filename, open_flags);
-    if (ret == -EACCES && !(flags & BDRV_O_FILE)) {
+    if ((ret == -EACCES || ret == -EPERM) && !(flags & BDRV_O_FILE)) {
         ret = drv->bdrv_open(bs, filename, BDRV_O_RDONLY);
         bs->read_only = 1;
     }