Enabled driver letter assignment for removable drives.

svn path=/trunk/; revision=2981
This commit is contained in:
Eric Kohl 2002-05-26 20:18:18 +00:00
parent 9ca6cf1169
commit 32e8099716

View file

@ -1,4 +1,4 @@
/* $Id: xhaldrv.c,v 1.21 2002/05/25 13:32:25 ekohl Exp $ /* $Id: xhaldrv.c,v 1.22 2002/05/26 20:18:18 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -84,7 +84,7 @@ xHalQueryDriveLayout(IN PUNICODE_STRING DeviceName,
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT("Status %x\n",Status); DPRINT("Status %x\n",Status);
return Status; return(Status);
} }
KeInitializeEvent(&Event, KeInitializeEvent(&Event,
@ -103,7 +103,7 @@ xHalQueryDriveLayout(IN PUNICODE_STRING DeviceName,
if (Irp == NULL) if (Irp == NULL)
{ {
ObDereferenceObject(FileObject); ObDereferenceObject(FileObject);
return STATUS_INSUFFICIENT_RESOURCES; return(STATUS_INSUFFICIENT_RESOURCES);
} }
Status = IoCallDriver(DeviceObject, Status = IoCallDriver(DeviceObject,
@ -118,9 +118,16 @@ xHalQueryDriveLayout(IN PUNICODE_STRING DeviceName,
Status = StatusBlock.Status; Status = StatusBlock.Status;
} }
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{
if (DeviceObject->Characteristics & FILE_REMOVABLE_MEDIA)
{
DiskGeometry.BytesPerSector = 512;
}
else
{ {
ObDereferenceObject(FileObject); ObDereferenceObject(FileObject);
return Status; return(Status);
}
} }
DPRINT("DiskGeometry.BytesPerSector: %d\n", DPRINT("DiskGeometry.BytesPerSector: %d\n",
@ -158,7 +165,7 @@ xHalQueryDriveLayout(IN PUNICODE_STRING DeviceName,
ObDereferenceObject(FileObject); ObDereferenceObject(FileObject);
return Status; return(Status);
} }
@ -390,7 +397,7 @@ xHalIoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
&LayoutArray[i]); &LayoutArray[i]);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DbgPrint("xHalpQueryDriveLayout() failed (Status = 0x%lx)\n", DbgPrint("xHalQueryDriveLayout() failed (Status = 0x%lx)\n",
Status); Status);
LayoutArray[i] = NULL; LayoutArray[i] = NULL;
continue; continue;
@ -430,7 +437,7 @@ xHalIoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
DPRINT("Assigning bootable primary partition on first harddisk:\n"); DPRINT("Assigning bootable primary partition on first harddisk:\n");
if (ConfigInfo->DiskCount > 0) if (ConfigInfo->DiskCount > 0)
{ {
/* search for bootable partition */ /* Search for bootable partition */
for (j = 0; j < LayoutArray[0]->PartitionCount; j++) for (j = 0; j < LayoutArray[0]->PartitionCount; j++)
{ {
if ((LayoutArray[0]->PartitionEntry[j].BootIndicator == TRUE) && if ((LayoutArray[0]->PartitionEntry[j].BootIndicator == TRUE) &&
@ -442,7 +449,7 @@ xHalIoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
RtlInitUnicodeString(&UnicodeString2, RtlInitUnicodeString(&UnicodeString2,
Buffer2); Buffer2);
/* assign it */ /* Assign drive */
DPRINT(" %wZ\n", &UnicodeString2); DPRINT(" %wZ\n", &UnicodeString2);
HalpAssignDrive(&UnicodeString2, HalpAssignDrive(&UnicodeString2,
AUTO_DRIVE, AUTO_DRIVE,
@ -455,12 +462,13 @@ xHalIoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
DPRINT("Assigning remaining primary partitions:\n"); DPRINT("Assigning remaining primary partitions:\n");
for (i = 0; i < ConfigInfo->DiskCount; i++) for (i = 0; i < ConfigInfo->DiskCount; i++)
{ {
/* search for primary partitions */ /* Search for primary partitions */
for (j = 0; j < PARTITION_TBL_SIZE; j++) for (j = 0; (j < PARTITION_TBL_SIZE) && (j < LayoutArray[i]->PartitionCount); j++)
{ {
if (!(i == 0 && if ((i == 0) && (LayoutArray[i]->PartitionEntry[j].BootIndicator == TRUE))
LayoutArray[i]->PartitionEntry[j].BootIndicator == TRUE) && continue;
IsUsablePartition(LayoutArray[i]->PartitionEntry[j].PartitionType))
if (IsUsablePartition(LayoutArray[i]->PartitionEntry[j].PartitionType))
{ {
swprintf(Buffer2, swprintf(Buffer2,
L"\\Device\\Harddisk%d\\Partition%d", L"\\Device\\Harddisk%d\\Partition%d",
@ -469,7 +477,7 @@ xHalIoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
RtlInitUnicodeString(&UnicodeString2, RtlInitUnicodeString(&UnicodeString2,
Buffer2); Buffer2);
/* assign it */ /* Assign drive */
DPRINT(" %wZ\n", DPRINT(" %wZ\n",
&UnicodeString2); &UnicodeString2);
HalpAssignDrive(&UnicodeString2, HalpAssignDrive(&UnicodeString2,
@ -485,7 +493,7 @@ xHalIoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
{ {
if (LayoutArray[i]) if (LayoutArray[i])
{ {
/* search for extended partitions */ /* Search for extended partitions */
for (j = PARTITION_TBL_SIZE; j < LayoutArray[i]->PartitionCount; j++) for (j = PARTITION_TBL_SIZE; j < LayoutArray[i]->PartitionCount; j++)
{ {
if (IsUsablePartition(LayoutArray[i]->PartitionEntry[j].PartitionType) && if (IsUsablePartition(LayoutArray[i]->PartitionEntry[j].PartitionType) &&
@ -498,7 +506,7 @@ xHalIoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
RtlInitUnicodeString(&UnicodeString2, RtlInitUnicodeString(&UnicodeString2,
Buffer2); Buffer2);
/* assign it */ /* Assign drive */
DPRINT(" %wZ\n", DPRINT(" %wZ\n",
&UnicodeString2); &UnicodeString2);
HalpAssignDrive(&UnicodeString2, HalpAssignDrive(&UnicodeString2,
@ -509,10 +517,8 @@ xHalIoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
} }
} }
#if 0
/* TEST */
/* Assign removable disk drives */ /* Assign removable disk drives */
DPRINT("Assigning extended (logical) partitions:\n"); DPRINT("Assigning removable disk drives:\n");
for (i = 0; i < ConfigInfo->DiskCount; i++) for (i = 0; i < ConfigInfo->DiskCount; i++)
{ {
/* Search for virtual partitions */ /* Search for virtual partitions */
@ -525,7 +531,7 @@ xHalIoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
RtlInitUnicodeString(&UnicodeString2, RtlInitUnicodeString(&UnicodeString2,
Buffer2); Buffer2);
/* assign it */ /* Assign drive */
DPRINT(" %wZ\n", DPRINT(" %wZ\n",
&UnicodeString2); &UnicodeString2);
HalpAssignDrive(&UnicodeString2, HalpAssignDrive(&UnicodeString2,
@ -533,8 +539,6 @@ xHalIoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
DOSDEVICE_DRIVE_REMOVABLE); DOSDEVICE_DRIVE_REMOVABLE);
} }
} }
/* TEST END */
#endif
/* Free layout array */ /* Free layout array */
for (i = 0; i < ConfigInfo->DiskCount; i++) for (i = 0; i < ConfigInfo->DiskCount; i++)
@ -554,7 +558,7 @@ xHalIoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
RtlInitUnicodeString(&UnicodeString1, RtlInitUnicodeString(&UnicodeString1,
Buffer1); Buffer1);
/* assign drive letters A: or B: or first free drive letter */ /* Assign drive letters A: or B: or first free drive letter */
DPRINT(" %wZ\n", DPRINT(" %wZ\n",
&UnicodeString1); &UnicodeString1);
HalpAssignDrive(&UnicodeString1, HalpAssignDrive(&UnicodeString1,
@ -572,7 +576,7 @@ xHalIoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
RtlInitUnicodeString(&UnicodeString1, RtlInitUnicodeString(&UnicodeString1,
Buffer1); Buffer1);
/* assign first free drive letter */ /* Assign first free drive letter */
DPRINT(" %wZ\n", &UnicodeString1); DPRINT(" %wZ\n", &UnicodeString1);
HalpAssignDrive(&UnicodeString1, HalpAssignDrive(&UnicodeString1,
AUTO_DRIVE, AUTO_DRIVE,
@ -581,7 +585,6 @@ xHalIoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
/* Anything else ?? */ /* Anything else ?? */
ExFreePool(Buffer2); ExFreePool(Buffer2);
ExFreePool(Buffer1); ExFreePool(Buffer1);
} }
@ -666,11 +669,11 @@ xHalIoReadPartitionTable(PDEVICE_OBJECT DeviceObject,
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DbgPrint("xHalIoReadPartitonTable failed (Status = 0x%08lx)\n", DPRINT("Failed to read partition table sector (Status = 0x%08lx)\n",
Status); Status);
ExFreePool(SectorBuffer); ExFreePool(SectorBuffer);
ExFreePool(LayoutBuffer); ExFreePool(LayoutBuffer);
return Status; return(Status);
} }
PartitionTable = (PPARTITION_TABLE)(SectorBuffer+PARTITION_OFFSET); PartitionTable = (PPARTITION_TABLE)(SectorBuffer+PARTITION_OFFSET);
@ -800,6 +803,7 @@ xHalIoReadPartitionTable(PDEVICE_OBJECT DeviceObject,
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
NTSTATUS FASTCALL NTSTATUS FASTCALL
xHalIoSetPartitionInformation(IN PDEVICE_OBJECT DeviceObject, xHalIoSetPartitionInformation(IN PDEVICE_OBJECT DeviceObject,
IN ULONG SectorSize, IN ULONG SectorSize,