Skip to contentSkip to conversation

2/5: open() can also return EPERM for O_RDWR on a readonly device

PATCH Applied Juergen Lock 2 participants 2 messages Oct 1, 2008 – Oct 13, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2/5: open() can also return EPERM for O_RDWR on a readonly device

..at least on FreeBSD. (I think the case where this happened was a cdrom.)

Index: qemu/block.c
@@ -381,7 +381,7 @@

     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;
     }
#1 lore raw

Applied, thanks.

Quoted 17 lines · Juergen Lock

..at least on FreeBSD. (I think the case where this happened was a cdrom.)

Index: qemu/block.c

(quoted diff) +1 -1
@@ -381,7 +381,7 @@
     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;
     }
Signature · 4 lines
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   [email protected]         | [email protected]
   `-    people.debian.org/~aurel32 | www.aurel32.net