mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 10:35:28 +00:00
[CLASS2]
- Add symlink creation support for CDROM devices [USBSTOR] - Simply forward unsupported SCSI operations Fixes USB CDROM support. CORE-6591 #resolve Patch by Johannes "USB God" Anderwald. svn path=/trunk/; revision=59091
This commit is contained in:
parent
7e7378f7c9
commit
a701847436
3 changed files with 62 additions and 41 deletions
|
@ -137,6 +137,7 @@ DriverEntry(
|
|||
/* The following hack to assign drive letters with a non-PnP storage stack */
|
||||
|
||||
typedef struct _CLASS_DEVICE_INFO {
|
||||
ULONG DeviceType;
|
||||
ULONG Partitions;
|
||||
ULONG DeviceNumber;
|
||||
ULONG DriveNumber;
|
||||
|
@ -205,7 +206,15 @@ ScsiClassAssignDriveLetter(PCLASS_DEVICE_INFO DeviceInfo)
|
|||
do
|
||||
{
|
||||
/* Check that the disk exists */
|
||||
if (DeviceInfo->DeviceType == FILE_DEVICE_DISK)
|
||||
{
|
||||
PartitionU.Length = swprintf(PartitionU.Buffer, L"\\Device\\HardDisk%d\\Partition0", DeviceNumber) * sizeof(WCHAR);
|
||||
}
|
||||
else if (DeviceInfo->DeviceType == FILE_DEVICE_CD_ROM)
|
||||
{
|
||||
PartitionU.Length = swprintf(PartitionU.Buffer, L"\\Device\\CdRom%d", DeviceNumber) * sizeof(WCHAR);
|
||||
}
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&PartitionU,
|
||||
OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
|
||||
|
@ -233,7 +242,14 @@ ScsiClassAssignDriveLetter(PCLASS_DEVICE_INFO DeviceInfo)
|
|||
do
|
||||
{
|
||||
/* Check that the drive exists */
|
||||
if (DeviceInfo->DeviceType == FILE_DEVICE_DISK)
|
||||
{
|
||||
PartitionU.Length = swprintf(PartitionU.Buffer, L"\\??\\PhysicalDrive%d", DriveNumber) * sizeof(WCHAR);
|
||||
}
|
||||
else if (DeviceInfo->DeviceType == FILE_DEVICE_CD_ROM)
|
||||
{
|
||||
PartitionU.Length = swprintf(PartitionU.Buffer, L"\\??\\%C:", ('C' + DriveNumber)) * sizeof(WCHAR);
|
||||
}
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&PartitionU,
|
||||
OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
|
||||
|
@ -252,19 +268,37 @@ ScsiClassAssignDriveLetter(PCLASS_DEVICE_INFO DeviceInfo)
|
|||
}
|
||||
} while (Status == STATUS_SUCCESS);
|
||||
|
||||
/* Create the symbolic link to PhysicalDriveX */
|
||||
if (DeviceInfo->DeviceType == FILE_DEVICE_DISK)
|
||||
{
|
||||
PartitionU.Length = swprintf(PartitionU.Buffer, L"\\Device\\Harddisk%d\\Partition0", DeviceNumber) * sizeof(WCHAR);
|
||||
DriveLetterU.Length = swprintf(DriveLetterU.Buffer, L"\\??\\PhysicalDrive%d", DriveNumber) * sizeof(WCHAR);
|
||||
}
|
||||
else if (DeviceInfo->DeviceType == FILE_DEVICE_CD_ROM)
|
||||
{
|
||||
PartitionU.Length = swprintf(PartitionU.Buffer, L"\\Device\\CdRom%d", DeviceNumber) * sizeof(WCHAR);
|
||||
DriveLetterU.Length = swprintf(DriveLetterU.Buffer, L"\\??\\%C:", ('C' + DriveNumber)) * sizeof(WCHAR);
|
||||
}
|
||||
|
||||
/* Create the symbolic link to PhysicalDriveX */
|
||||
Status = IoCreateSymbolicLink(&DriveLetterU, &PartitionU);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Failed to create symbolic link */
|
||||
DbgPrint("Failed to create symbolic link %wZ -> %wZ with %lx\n", &PartitionU, &DriveLetterU, Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
DbgPrint("HACK: Created symbolic link %wZ -> %wZ\n", &PartitionU, &DriveLetterU);
|
||||
|
||||
DeviceInfo->DeviceNumber = DeviceNumber;
|
||||
DeviceInfo->DriveNumber = DriveNumber;
|
||||
|
||||
if (DeviceInfo->DeviceType == FILE_DEVICE_CD_ROM)
|
||||
{
|
||||
/* done for cdroms */
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
/* Check that the disk exists */
|
||||
|
@ -303,9 +337,6 @@ ScsiClassAssignDriveLetter(PCLASS_DEVICE_INFO DeviceInfo)
|
|||
}
|
||||
}
|
||||
|
||||
DeviceInfo->DeviceNumber = DeviceNumber;
|
||||
DeviceInfo->DriveNumber = DriveNumber;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -361,7 +392,7 @@ ScsiClassAddDevice(
|
|||
Status = IoCreateDevice(DriverObject,
|
||||
sizeof(CLASS_DEVICE_INFO),
|
||||
NULL,
|
||||
FILE_DEVICE_DISK,
|
||||
DriverExtension->InitializationData.DeviceType,
|
||||
0,
|
||||
FALSE,
|
||||
&DeviceObject);
|
||||
|
@ -375,6 +406,7 @@ ScsiClassAddDevice(
|
|||
|
||||
/* Attach it to the PDO */
|
||||
DeviceInfo->LowerDevice = IoAttachDeviceToDeviceStack(DeviceObject, PhysicalDeviceObject);
|
||||
DeviceInfo->DeviceType = DriverExtension->InitializationData.DeviceType;
|
||||
|
||||
/* Check that the kernel has already assigned drive letters */
|
||||
if (KeLoaderBlock == NULL)
|
||||
|
|
|
@ -1258,7 +1258,7 @@ USBSTOR_SendUnknownRequest(
|
|||
PPDO_DEVICE_EXTENSION PDODeviceExtension;
|
||||
PIO_STACK_LOCATION IoStack;
|
||||
PSCSI_REQUEST_BLOCK Request;
|
||||
UFI_TEST_UNIT_CMD Cmd;
|
||||
UFI_UNKNOWN_CMD Cmd;
|
||||
|
||||
//
|
||||
// get current stack location
|
||||
|
@ -1283,7 +1283,7 @@ USBSTOR_SendUnknownRequest(
|
|||
//
|
||||
// sanity check
|
||||
//
|
||||
ASSERT(Request->CdbLength == sizeof(UFI_TEST_UNIT_CMD));
|
||||
ASSERT(Request->CdbLength <= sizeof(UFI_UNKNOWN_CMD));
|
||||
|
||||
//
|
||||
// initialize test unit cmd
|
||||
|
@ -1412,28 +1412,11 @@ USBSTOR_HandleExecuteSCSI(
|
|||
//
|
||||
Status = USBSTOR_SendTestUnit(DeviceObject, Irp, RetryCount);
|
||||
}
|
||||
#if 0
|
||||
else if (pCDB->AsByte[0] == SCSIOP_MECHANISM_STATUS)
|
||||
{
|
||||
DPRINT1("SCSIOP_MECHANISM_STATUS\n");
|
||||
|
||||
//
|
||||
// Just send it the way it is
|
||||
//
|
||||
Status = USBSTOR_SendUnknownRequest(DeviceObject, Irp, RetryCount);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
// unsupported request
|
||||
DPRINT1("UNIMPLEMENTED Operation Code %x\n", pCDB->AsByte[0]);
|
||||
Status = STATUS_NOT_SUPPORTED;
|
||||
|
||||
Request->SrbStatus = SRB_STATUS_ERROR;
|
||||
Irp->IoStatus.Status = Status;
|
||||
Irp->IoStatus.Information = 0;
|
||||
USBSTOR_QueueTerminateRequest(PDODeviceExtension->LowerDeviceObject, Irp);
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
// Unknown request. Simply forward
|
||||
DPRINT1("Forwarding unknown Operation Code %x\n", pCDB->AsByte[0]);
|
||||
Status = USBSTOR_SendUnknownRequest(DeviceObject, Irp, RetryCount);
|
||||
}
|
||||
|
||||
return Status;
|
||||
|
|
|
@ -317,6 +317,12 @@ C_ASSERT(sizeof(UFI_TEST_UNIT_CMD) == 12);
|
|||
|
||||
#define UFI_TEST_UNIT_CMD_LEN (6)
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------
|
||||
typedef struct
|
||||
{
|
||||
UCHAR Bytes[16];
|
||||
}UFI_UNKNOWN_CMD, *PUFI_UNKNOWN_CMD;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
union
|
||||
|
|
Loading…
Reference in a new issue