Author: tfaber Date: Mon May 27 18:39:32 2013 New Revision: 59091
URL: http://svn.reactos.org/svn/reactos?rev=59091&view=rev Log: [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.
Modified: trunk/reactos/drivers/storage/class/class2/class2.c trunk/reactos/drivers/usb/usbstor/scsi.c trunk/reactos/drivers/usb/usbstor/usbstor.h
Modified: trunk/reactos/drivers/storage/class/class2/class2.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/storage/class/class... ============================================================================== --- trunk/reactos/drivers/storage/class/class2/class2.c [iso-8859-1] (original) +++ trunk/reactos/drivers/storage/class/class2/class2.c [iso-8859-1] Mon May 27 18:39:32 2013 @@ -137,6 +137,7 @@ /* 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 @@ do { /* Check that the disk exists */ - PartitionU.Length = swprintf(PartitionU.Buffer, L"\Device\HardDisk%d\Partition0", DeviceNumber) * sizeof(WCHAR); + 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 @@ do { /* Check that the drive exists */ - PartitionU.Length = swprintf(PartitionU.Buffer, L"\??\PhysicalDrive%d", DriveNumber) * sizeof(WCHAR); + 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,18 +268,36 @@ } } while (Status == STATUS_SUCCESS);
+ 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 */ - PartitionU.Length = swprintf(PartitionU.Buffer, L"\Device\Harddisk%d\Partition0", DeviceNumber) * sizeof(WCHAR); - DriveLetterU.Length = swprintf(DriveLetterU.Buffer, L"\??\PhysicalDrive%d", DriveNumber) * sizeof(WCHAR); - 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) { @@ -303,9 +337,6 @@ } }
- DeviceInfo->DeviceNumber = DeviceNumber; - DeviceInfo->DriveNumber = DriveNumber; - return STATUS_SUCCESS; }
@@ -361,7 +392,7 @@ Status = IoCreateDevice(DriverObject, sizeof(CLASS_DEVICE_INFO), NULL, - FILE_DEVICE_DISK, + DriverExtension->InitializationData.DeviceType, 0, FALSE, &DeviceObject); @@ -375,6 +406,7 @@
/* 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)
Modified: trunk/reactos/drivers/usb/usbstor/scsi.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbstor/scsi.c?... ============================================================================== --- trunk/reactos/drivers/usb/usbstor/scsi.c [iso-8859-1] (original) +++ trunk/reactos/drivers/usb/usbstor/scsi.c [iso-8859-1] Mon May 27 18:39:32 2013 @@ -171,7 +171,7 @@ NTAPI USBSTOR_CSWCompletionRoutine( PDEVICE_OBJECT DeviceObject, - PIRP Irp, + PIRP Irp, PVOID Ctx) { PIRP_CONTEXT Context; @@ -430,7 +430,7 @@ NTAPI USBSTOR_DataCompletionRoutine( PDEVICE_OBJECT DeviceObject, - PIRP Irp, + PIRP Irp, PVOID Ctx) { PIRP_CONTEXT Context; @@ -475,7 +475,7 @@ NTAPI USBSTOR_CBWCompletionRoutine( PDEVICE_OBJECT DeviceObject, - PIRP Irp, + PIRP Irp, PVOID Ctx) { PIRP_CONTEXT Context; @@ -509,7 +509,7 @@ { // // write request use bulk out pipe - // + // PipeHandle = Context->FDODeviceExtension->InterfaceInformation->Pipes[Context->FDODeviceExtension->BulkOutPipeIndex].PipeHandle; } else @@ -582,7 +582,7 @@ DPRINT("%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", Block[0] & 0xFF, Block[1] & 0xFF, Block[2] & 0xFF, Block[3] & 0xFF, Block[4] & 0xFF, Block[5] & 0xFF, Block[6] & 0xFF, Block[7] & 0xFF, Block[8] & 0xFF, Block[9] & 0xFF, Block[10] & 0xFF, Block[11] & 0xFF, Block[12] & 0xFF, Block[13] & 0xFF, Block[14] & 0xFF, Block[15] & 0xFF, Block[16] & 0xFF, Block[17] & 0xFF, Block[18] & 0xFF, Block[19] & 0xFF, - Block[20] & 0xFF, Block[21] & 0xFF, Block[22] & 0xFF, Block[23] & 0xFF, Block[24] & 0xFF, Block[25] & 0xFF, Block[26] & 0xFF, Block[27] & 0xFF, Block[28] & 0xFF, Block[29] & 0xFF, + Block[20] & 0xFF, Block[21] & 0xFF, Block[22] & 0xFF, Block[23] & 0xFF, Block[24] & 0xFF, Block[25] & 0xFF, Block[26] & 0xFF, Block[27] & 0xFF, Block[28] & 0xFF, Block[29] & 0xFF, Block[30] & 0xFF);
} @@ -1079,10 +1079,10 @@ // first struct is the header // MODE_PARAMETER_HEADER / _MODE_PARAMETER_HEADER10 // - // followed by + // followed by // MODE_PARAMETER_BLOCK // - // + // UNIMPLEMENTED
// @@ -1258,7 +1258,7 @@ 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 @@ // // sanity check // - ASSERT(Request->CdbLength == sizeof(UFI_TEST_UNIT_CMD)); + ASSERT(Request->CdbLength <= sizeof(UFI_UNKNOWN_CMD));
// // initialize test unit cmd @@ -1412,29 +1412,12 @@ // 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 - // + else + { + // Unknown request. Simply forward + DPRINT1("Forwarding unknown Operation Code %x\n", pCDB->AsByte[0]); 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); - }
return Status; }
Modified: trunk/reactos/drivers/usb/usbstor/usbstor.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/usb/usbstor/usbstor... ============================================================================== --- trunk/reactos/drivers/usb/usbstor/usbstor.h [iso-8859-1] (original) +++ trunk/reactos/drivers/usb/usbstor/usbstor.h [iso-8859-1] Mon May 27 18:39:32 2013 @@ -317,6 +317,12 @@
#define UFI_TEST_UNIT_CMD_LEN (6)
+//------------------------------------------------------------------------------------------------------------------------------------------- +typedef struct +{ + UCHAR Bytes[16]; +}UFI_UNKNOWN_CMD, *PUFI_UNKNOWN_CMD; + typedef struct { union @@ -385,7 +391,7 @@
PVOID AllocateItem( - IN POOL_TYPE PoolType, + IN POOL_TYPE PoolType, IN ULONG ItemSize);
VOID @@ -406,7 +412,7 @@ NTAPI USBSTOR_SyncForwardIrpCompletionRoutine( PDEVICE_OBJECT DeviceObject, - PIRP Irp, + PIRP Irp, PVOID Context);
NTSTATUS @@ -452,7 +458,7 @@ NTAPI USBSTOR_CSWCompletionRoutine( PDEVICE_OBJECT DeviceObject, - PIRP Irp, + PIRP Irp, PVOID Ctx);
NTSTATUS