Charles Davis : ntdll: Use the parent device for everything when processing a storage IOCTL request on Mac OS .
Alexandre Julliard
julliard at winehq.org
Thu Oct 15 08:54:38 CDT 2009
Module: wine
Branch: master
Commit: 895be2b0f84dc02098fa623b068cbff34a1c6075
URL: http://source.winehq.org/git/wine.git/?a=commit;h=895be2b0f84dc02098fa623b068cbff34a1c6075
Author: Charles Davis <cdavis at mymail.mines.edu>
Date: Wed Oct 14 10:46:46 2009 -0600
ntdll: Use the parent device for everything when processing a storage IOCTL request on Mac OS.
---
dlls/ntdll/cdrom.c | 46 +++++++++++++++++++++++++---------------------
1 files changed, 25 insertions(+), 21 deletions(-)
diff --git a/dlls/ntdll/cdrom.c b/dlls/ntdll/cdrom.c
index c0389f9..b5f2365 100644
--- a/dlls/ntdll/cdrom.c
+++ b/dlls/ntdll/cdrom.c
@@ -2334,6 +2334,31 @@ NTSTATUS CDROM_DeviceIoControl(HANDLE hDevice,
goto error;
}
+#ifdef __APPLE__
+ {
+ char name[100];
+
+ /* This is ugly as hell, but Mac OS is unable to do anything from the
+ * partition fd, it wants an fd for the whole device, and it sometimes
+ * also requires the device fd to be closed first, so we have to close
+ * the handle that the caller gave us.
+ * Also for some reason it wants the fd to be closed before we even
+ * open the parent if we're trying to eject the disk.
+ */
+ if ((status = get_parent_device( fd, name, sizeof(name) ))) goto error;
+ if (dwIoControlCode == IOCTL_STORAGE_EJECT_MEDIA)
+ NtClose( hDevice );
+ if (needs_close) close( fd );
+ TRACE("opening parent %s\n", name );
+ if ((fd = open( name, O_RDONLY )) == -1)
+ {
+ status = FILE_GetNtStatus();
+ goto error;
+ }
+ needs_close = 1;
+ }
+#endif
+
switch (dwIoControlCode)
{
case IOCTL_STORAGE_CHECK_VERIFY:
@@ -2365,28 +2390,7 @@ NTSTATUS CDROM_DeviceIoControl(HANDLE hDevice,
if (lpInBuffer != NULL || nInBufferSize != 0 || lpOutBuffer != NULL || nOutBufferSize != 0)
status = STATUS_INVALID_PARAMETER;
else
- {
-#ifdef __APPLE__
- char name[100];
-
- /* This is ugly as hell, but Mac OS is unable to eject from the device fd,
- * it wants an fd for the whole device, and it also requires the device fd
- * to be closed first, so we have to close the handle that the caller gave us.
- * Also for some reason it wants the fd to be closed before we even open the parent.
- */
- if ((status = get_parent_device( fd, name, sizeof(name) ))) break;
- NtClose( hDevice );
- if (needs_close) close( fd );
- TRACE("opening parent %s\n", name );
- if ((fd = open( name, O_RDONLY )) == -1)
- {
- status = FILE_GetNtStatus();
- break;
- }
- needs_close = 1;
-#endif
status = CDROM_SetTray(fd, TRUE);
- }
break;
case IOCTL_CDROM_MEDIA_REMOVAL:
More information about the wine-cvs
mailing list