Commit 01def427 authored by Alexandre Julliard's avatar Alexandre Julliard

Pass the cdrom device path in CDROM_InitRegistry so that ntdll doesn't

need to call DRIVE_GetDevice. Get rid of GetDriveType calls.
parent 7f77f0f1
......@@ -83,8 +83,6 @@
#include "ntddstor.h"
#include "ntddcdrm.h"
#include "ntddscsi.h"
#include "drive.h"
#include "file.h"
#include "wine/debug.h"
/* Non-Linux systems do not have linux/cdrom.h and the like, and thus
......@@ -189,6 +187,7 @@ struct cdrom_cache {
char toc_good; /* if false, will reread TOC from disk */
CDROM_TOC toc;
SUB_Q_CURRENT_POSITION CurrentPosition;
const char *device;
};
static struct cdrom_cache cdrom_cache[26];
......@@ -450,7 +449,7 @@ static int CDROM_GetInterfaceInfo(int fd, int* port, int* iface, int* device,int
* NOTE: programs usually read these registry entries after sending the
* IOCTL_SCSI_GET_ADDRESS ioctl to the cdrom
*/
void CDROM_InitRegistry(int fd)
void CDROM_InitRegistry(int fd, int device_id, const char *device )
{
int portnum, busid, targetid, lun;
OBJECT_ATTRIBUTES attr;
......@@ -466,6 +465,8 @@ void CDROM_InitRegistry(int fd)
HKEY targetKey;
DWORD disp;
cdrom_cache[device_id].device = device;
attr.Length = sizeof(attr);
attr.RootDirectory = 0;
attr.ObjectName = &nameW;
......@@ -590,18 +591,14 @@ static NTSTATUS CDROM_Open(HANDLE hDevice, DWORD clientID, int* dev)
if (!cdrom_cache[*dev].count)
{
char root[4];
const char *device;
strcpy(root, "A:\\");
root[0] += *dev;
if (GetDriveTypeA(root) != DRIVE_CDROM) return STATUS_NO_SUCH_DEVICE;
if (!(device = DRIVE_GetDevice(*dev))) return STATUS_NO_SUCH_DEVICE;
if (!(device = cdrom_cache[*dev].device)) return STATUS_NO_SUCH_DEVICE;
cdrom_cache[*dev].fd = open(device, O_RDONLY|O_NONBLOCK);
if (cdrom_cache[*dev].fd == -1)
{
FIXME("Can't open configured CD-ROM drive at %s (device %s): %s\n",
root, DRIVE_GetDevice(*dev), strerror(errno));
FIXME("Can't open configured CD-ROM drive %c: (device %s): %s\n",
'A' + *dev, device, strerror(errno));
return STATUS_NO_SUCH_DEVICE;
}
}
......
......@@ -38,7 +38,6 @@
#include "wine/server.h"
#include "async.h"
#include "ntdll_misc.h"
#include "file.h" /* FIXME */
#include "../files/smb.h"
#include "winternl.h"
......@@ -74,8 +73,6 @@ NTSTATUS WINAPI NtOpenFile(
{
LPWSTR filename;
static const WCHAR szDosDevices[] = {'\\','D','o','s','D','e','v','i','c','e','s','\\',0};
DOS_FULL_NAME full_name;
NTSTATUS r;
FIXME("(%p,0x%08lx,%p,%p,0x%08lx,0x%08lx) partial stub\n",
FileHandle, DesiredAccess, ObjectAttributes,
......@@ -97,28 +94,10 @@ NTSTATUS WINAPI NtOpenFile(
return STATUS_OBJECT_NAME_NOT_FOUND;
/* FIXME: this calls SetLastError() -> bad */
if(!DOSFS_GetFullName(&filename[strlenW(szDosDevices)], TRUE,
&full_name))
return STATUS_OBJECT_NAME_NOT_FOUND;
/* FIXME: modify server protocol so
create file takes an OBJECT_ATTRIBUTES structure */
SERVER_START_REQ( create_file )
{
req->access = DesiredAccess;
req->inherit = 0;
req->sharing = ShareAccess;
req->create = OPEN_EXISTING;
req->attrs = 0;
req->drive_type = GetDriveTypeW( full_name.short_name );
wine_server_add_data( req, full_name.long_name, strlen(full_name.long_name) );
SetLastError(0);
r = wine_server_call( req );
*FileHandle = reply->handle;
}
SERVER_END_REQ;
return r;
*FileHandle = CreateFileW( &filename[strlenW(szDosDevices)], DesiredAccess, ShareAccess,
NULL, OPEN_EXISTING, 0, 0 );
if (*FileHandle == INVALID_HANDLE_VALUE) return STATUS_OBJECT_NAME_NOT_FOUND;
return STATUS_SUCCESS;
}
/**************************************************************************
......@@ -683,7 +662,6 @@ NTSTATUS WINAPI NtDeviceIoControlFile(HANDLE DeviceHandle, HANDLE hEvent,
ULONG OutputBufferSize)
{
DWORD clientID = 0;
char str[3];
TRACE("(%p,%p,%p,%p,%p,0x%08lx,%p,0x%08lx,%p,0x%08lx)\n",
DeviceHandle, hEvent, UserApcRoutine, UserApcContext,
......@@ -699,24 +677,20 @@ NTSTATUS WINAPI NtDeviceIoControlFile(HANDLE DeviceHandle, HANDLE hEvent,
SERVER_END_REQ;
if (!clientID) return STATUS_INVALID_PARAMETER;
strcpy(str, "A:");
str[0] += LOBYTE(clientID);
/* FIXME: should use the NTDLL equivalent */
if (GetDriveTypeA(str) == DRIVE_CDROM)
if (CDROM_DeviceIoControl(clientID, DeviceHandle, hEvent,
UserApcRoutine, UserApcContext,
IoStatusBlock, IoControlCode,
InputBuffer, InputBufferSize,
OutputBuffer, OutputBufferSize) == STATUS_NO_SUCH_DEVICE)
{
return CDROM_DeviceIoControl(clientID, DeviceHandle, hEvent,
UserApcRoutine, UserApcContext,
IoStatusBlock, IoControlCode,
InputBuffer, InputBufferSize,
OutputBuffer, OutputBufferSize);
/* it wasn't a CDROM */
FIXME("Unimplemented dwIoControlCode=%08lx\n", IoControlCode);
IoStatusBlock->u.Status = STATUS_NOT_IMPLEMENTED;
IoStatusBlock->Information = 0;
if (hEvent) NtSetEvent(hEvent, NULL);
}
FIXME("Unimplemented dwIoControlCode=%08lx\n", IoControlCode);
IoStatusBlock->u.Status = STATUS_NOT_IMPLEMENTED;
IoStatusBlock->Information = 0;
if (hEvent) NtSetEvent(hEvent, NULL);
return STATUS_NOT_IMPLEMENTED;
return IoStatusBlock->u.Status;
}
/******************************************************************************
......
......@@ -144,7 +144,7 @@ inline static char *heap_strdup( const char *str )
#define IS_OPTION_TRUE(ch) ((ch) == 'y' || (ch) == 'Y' || (ch) == 't' || (ch) == 'T' || (ch) == '1')
extern void CDROM_InitRegistry(int dev);
extern void CDROM_InitRegistry(int dev, int id, const char *device);
/***********************************************************************
* DRIVE_GetDriveType
......@@ -329,7 +329,7 @@ int DRIVE_Init(void)
if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
{
WCHAR *data = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
len = WideCharToMultiByte(CP_ACP, 0, data, -1, NULL, 0, NULL, NULL);
len = WideCharToMultiByte(drive->codepage, 0, data, -1, NULL, 0, NULL, NULL);
drive->device = HeapAlloc(GetProcessHeap(), 0, len);
WideCharToMultiByte(drive->codepage, 0, data, -1, drive->device, len, NULL, NULL);
......@@ -346,7 +346,7 @@ int DRIVE_Init(void)
int cd_fd;
if ((cd_fd = open(drive->device, O_RDONLY|O_NONBLOCK)) != -1)
{
CDROM_InitRegistry(cd_fd);
CDROM_InitRegistry(cd_fd, i, drive->device);
close(cd_fd);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment