[PATCH 2/2] kernel32: Return correct drive type for empty drives (try2)

Alexandre Goujon ale.goujon at gmail.com
Fri Aug 31 09:17:18 CDT 2012


Should fix bug #17037 and skip the ioctl test when there is no disc in the drive.
---
 dlls/kernel32/tests/volume.c |    2 +-
 dlls/kernel32/volume.c       |   10 +++++++++-
 dlls/ntdll/cdrom.c           |    3 ++-
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/dlls/kernel32/tests/volume.c b/dlls/kernel32/tests/volume.c
index 8152ae1..d64965f 100644
--- a/dlls/kernel32/tests/volume.c
+++ b/dlls/kernel32/tests/volume.c
@@ -778,7 +778,7 @@ static void test_dvd_read_structure(HANDLE handle)
     if ((!ret && GetLastError() == ERROR_INVALID_FUNCTION)
      || (!ret && GetLastError() == ERROR_NOT_SUPPORTED))
     {
-        skip("IOCTL_DVD_READ_STRUCTURE not supported\n");
+        skip("IOCTL_DVD_READ_STRUCTURE not supported or no disc in the drive\n");
         return;
     }
 
diff --git a/dlls/kernel32/volume.c b/dlls/kernel32/volume.c
index 238dd9c..7dc975c 100644
--- a/dlls/kernel32/volume.c
+++ b/dlls/kernel32/volume.c
@@ -1546,7 +1546,15 @@ UINT WINAPI GetDriveTypeW(LPCWSTR root) /* [in] String describing drive */
     HANDLE handle;
     UINT ret;
 
-    if (!open_device_root( root, &handle )) return DRIVE_NO_ROOT_DIR;
+    if (!open_device_root( root, &handle ))
+    {
+        /* Getting empty drive handle fails because there's not mount point
+             So in this case, get the drive type from the mountmgr */
+        if (GetLastError() == ERROR_PATH_NOT_FOUND
+        && ((ret = get_mountmgr_drive_type(root)) != DRIVE_UNKNOWN))
+            return ret;
+        return DRIVE_NO_ROOT_DIR;
+    }
 
     status = NtQueryVolumeInformationFile( handle, &io, &info, sizeof(info), FileFsDeviceInformation );
     NtClose( handle );
diff --git a/dlls/ntdll/cdrom.c b/dlls/ntdll/cdrom.c
index 54b9ab6..9bc0baf 100644
--- a/dlls/ntdll/cdrom.c
+++ b/dlls/ntdll/cdrom.c
@@ -2544,7 +2544,8 @@ static NTSTATUS DVD_ReadStructure(int dev, const DVD_READ_STRUCTURE *structure,
     }
 
     if (ioctl(dev, DVD_READ_STRUCT, &s) < 0)
-       return STATUS_INVALID_PARAMETER;
+        /* Will be converted into ERROR_INVALID_FUNCTION */
+        return (errno == ENOMEDIUM) ? STATUS_INVALID_DEVICE_REQUEST : STATUS_INVALID_PARAMETER;
 
     switch (structure->Format)
     {
-- 
1.7.9.5




More information about the wine-patches mailing list