open() can also return EPERM for O_RDWR on a readonly device

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
This commit is contained in:
aurel32 2008-10-13 21:08:34 +00:00
parent 60759371f0
commit a0a83536e0

View File

@ -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;
}