Fix CDROM permission check, by Kazu <kazoo@r3.dion.ne.jp>.
authorths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>
Thu, 18 Jan 2007 00:22:11 +0000 (00:22 +0000)
committerths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>
Thu, 18 Jan 2007 00:22:11 +0000 (00:22 +0000)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2331 c046a42c-6fe2-441c-8c8c-71466251a162

block-raw.c

index 2b6f441bad85f907ee76c16a9738205129902865..29882e1f70da3f5a32a207cf97a884864f1598f2 100644 (file)
@@ -914,8 +914,13 @@ static int raw_open(BlockDriverState *bs, const char *filename, int flags)
     s->hfile = CreateFile(filename, access_flags, 
                           FILE_SHARE_READ, NULL,
                           create_flags, overlapped, NULL);
-    if (s->hfile == INVALID_HANDLE_VALUE) 
+    if (s->hfile == INVALID_HANDLE_VALUE) {
+        int err = GetLastError();
+
+        if (err == ERROR_ACCESS_DENIED)
+            return -EACCES;
         return -1;
+    }
     return 0;
 }
 
@@ -1278,8 +1283,13 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags)
     s->hfile = CreateFile(filename, access_flags, 
                           FILE_SHARE_READ, NULL,
                           create_flags, overlapped, NULL);
-    if (s->hfile == INVALID_HANDLE_VALUE) 
+    if (s->hfile == INVALID_HANDLE_VALUE) {
+        int err = GetLastError();
+
+        if (err == ERROR_ACCESS_DENIED)
+            return -EACCES;
         return -1;
+    }
     return 0;
 }