mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +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 */
|
||||
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 @@ ScsiClassAssignDriveLetter(PCLASS_DEVICE_INFO DeviceInfo)
|
|||
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,19 +268,37 @@ ScsiClassAssignDriveLetter(PCLASS_DEVICE_INFO DeviceInfo)
|
|||
}
|
||||
} while (Status == STATUS_SUCCESS);
|
||||
|
||||
/* 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);
|
||||
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)
|
||||
|
|
|
@ -171,7 +171,7 @@ NTSTATUS
|
|||
NTAPI
|
||||
USBSTOR_CSWCompletionRoutine(
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp,
|
||||
PIRP Irp,
|
||||
PVOID Ctx)
|
||||
{
|
||||
PIRP_CONTEXT Context;
|
||||
|
@ -430,7 +430,7 @@ NTSTATUS
|
|||
NTAPI
|
||||
USBSTOR_DataCompletionRoutine(
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp,
|
||||
PIRP Irp,
|
||||
PVOID Ctx)
|
||||
{
|
||||
PIRP_CONTEXT Context;
|
||||
|
@ -475,7 +475,7 @@ NTSTATUS
|
|||
NTAPI
|
||||
USBSTOR_CBWCompletionRoutine(
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp,
|
||||
PIRP Irp,
|
||||
PVOID Ctx)
|
||||
{
|
||||
PIRP_CONTEXT Context;
|
||||
|
@ -509,7 +509,7 @@ USBSTOR_CBWCompletionRoutine(
|
|||
{
|
||||
//
|
||||
// write request use bulk out pipe
|
||||
//
|
||||
//
|
||||
PipeHandle = Context->FDODeviceExtension->InterfaceInformation->Pipes[Context->FDODeviceExtension->BulkOutPipeIndex].PipeHandle;
|
||||
}
|
||||
else
|
||||
|
@ -582,7 +582,7 @@ DumpCBW(
|
|||
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 @@ USBSTOR_SendModeSense(
|
|||
// first struct is the header
|
||||
// MODE_PARAMETER_HEADER / _MODE_PARAMETER_HEADER10
|
||||
//
|
||||
// followed by
|
||||
// followed by
|
||||
// MODE_PARAMETER_BLOCK
|
||||
//
|
||||
//
|
||||
//
|
||||
UNIMPLEMENTED
|
||||
|
||||
//
|
||||
|
@ -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
|
||||
|
@ -385,7 +391,7 @@ USBSTOR_GetBusInterface(
|
|||
|
||||
PVOID
|
||||
AllocateItem(
|
||||
IN POOL_TYPE PoolType,
|
||||
IN POOL_TYPE PoolType,
|
||||
IN ULONG ItemSize);
|
||||
|
||||
VOID
|
||||
|
@ -406,7 +412,7 @@ NTSTATUS
|
|||
NTAPI
|
||||
USBSTOR_SyncForwardIrpCompletionRoutine(
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp,
|
||||
PIRP Irp,
|
||||
PVOID Context);
|
||||
|
||||
NTSTATUS
|
||||
|
@ -452,7 +458,7 @@ NTSTATUS
|
|||
NTAPI
|
||||
USBSTOR_CSWCompletionRoutine(
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp,
|
||||
PIRP Irp,
|
||||
PVOID Ctx);
|
||||
|
||||
NTSTATUS
|
||||
|
|
Loading…
Reference in a new issue