mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 20:25:39 +00:00
Implemented IOCTL_DISK_GET_PARTITION_INFO.
Removed internal disk size limit. svn path=/trunk/; revision=2706
This commit is contained in:
parent
c08d8bcfb9
commit
724d0e6c2f
2 changed files with 91 additions and 61 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: ide.c,v 1.51 2002/02/08 02:57:08 chorns Exp $
|
/* $Id: ide.c,v 1.52 2002/03/12 20:16:53 ekohl Exp $
|
||||||
*
|
*
|
||||||
* IDE.C - IDE Disk driver
|
* IDE.C - IDE Disk driver
|
||||||
* written by Rex Jolliff
|
* written by Rex Jolliff
|
||||||
|
@ -78,7 +78,7 @@
|
||||||
#define VERSION "V0.1.5"
|
#define VERSION "V0.1.5"
|
||||||
|
|
||||||
/* uncomment the following line to enable the secondary ide channel */
|
/* uncomment the following line to enable the secondary ide channel */
|
||||||
//#define ENABLE_SECONDARY_IDE_CHANNEL
|
#define ENABLE_SECONDARY_IDE_CHANNEL
|
||||||
|
|
||||||
// ------------------------------------------------------- File Static Data
|
// ------------------------------------------------------- File Static Data
|
||||||
|
|
||||||
|
@ -953,12 +953,19 @@ IDECreateDiskDevice(IN PDRIVER_OBJECT DriverObject,
|
||||||
DeviceExtension->LogicalHeads = DrvParms->LogicalHeads;
|
DeviceExtension->LogicalHeads = DrvParms->LogicalHeads;
|
||||||
DeviceExtension->LogicalCylinders =
|
DeviceExtension->LogicalCylinders =
|
||||||
(DrvParms->Capabilities & IDE_DRID_LBA_SUPPORTED) ? DrvParms->TMCylinders : DrvParms->LogicalCyls;
|
(DrvParms->Capabilities & IDE_DRID_LBA_SUPPORTED) ? DrvParms->TMCylinders : DrvParms->LogicalCyls;
|
||||||
DeviceExtension->Offset = 0;
|
|
||||||
DeviceExtension->Size = SectorCount;
|
DeviceExtension->StartingOffset.QuadPart = 0;
|
||||||
DPRINT("%wZ: offset %lu size %lu \n",
|
DeviceExtension->PartitionLength.QuadPart = (ULONGLONG)SectorCount *
|
||||||
|
(ULONGLONG)DrvParms->BytesPerSector;
|
||||||
|
DeviceExtension->HiddenSectors = 0;
|
||||||
|
DeviceExtension->PartitionNumber = 0;
|
||||||
|
DeviceExtension->PartitionType = 0;
|
||||||
|
DeviceExtension->BootIndicator = FALSE;
|
||||||
|
|
||||||
|
DPRINT("%wZ: offset %I64d length %I64d\n",
|
||||||
&DeviceName,
|
&DeviceName,
|
||||||
DeviceExtension->Offset,
|
DeviceExtension->StartingOffset.QuadPart,
|
||||||
DeviceExtension->Size);
|
DeviceExtension->PartitionLength.QuadPart);
|
||||||
|
|
||||||
/* Initialize the DPC object here */
|
/* Initialize the DPC object here */
|
||||||
IoInitializeDpcRequest(*DeviceObject,
|
IoInitializeDpcRequest(*DeviceObject,
|
||||||
|
@ -1061,18 +1068,24 @@ IDECreatePartitionDevice(IN PDRIVER_OBJECT DriverObject,
|
||||||
DeviceExtension->LogicalCylinders =
|
DeviceExtension->LogicalCylinders =
|
||||||
(DrvParms->Capabilities & IDE_DRID_LBA_SUPPORTED) ? DrvParms->TMCylinders : DrvParms->LogicalCyls;
|
(DrvParms->Capabilities & IDE_DRID_LBA_SUPPORTED) ? DrvParms->TMCylinders : DrvParms->LogicalCyls;
|
||||||
|
|
||||||
DeviceExtension->Offset = PartitionInfo->StartingOffset.QuadPart / 512; /* DrvParms->BytesPerSector */
|
DeviceExtension->StartingOffset = PartitionInfo->StartingOffset;
|
||||||
DeviceExtension->Size = PartitionInfo->PartitionLength.QuadPart / 512; /* DrvParms->BytesPerSector */
|
DeviceExtension->PartitionLength = PartitionInfo->PartitionLength;
|
||||||
|
DeviceExtension->HiddenSectors = PartitionInfo->HiddenSectors;
|
||||||
|
DeviceExtension->PartitionNumber = PartitionInfo->PartitionNumber;
|
||||||
|
DeviceExtension->PartitionType = PartitionInfo->PartitionType;
|
||||||
|
DeviceExtension->BootIndicator = PartitionInfo->BootIndicator;
|
||||||
|
|
||||||
DPRINT("%wZ: offset %lu size %lu \n",
|
DPRINT("%wZ: offset %I64d size %I64d\n",
|
||||||
&DeviceName,
|
&DeviceName,
|
||||||
DeviceExtension->Offset,
|
DeviceExtension->StartingOffset.QuadPart,
|
||||||
DeviceExtension->Size);
|
DeviceExtension->PartitionLength.QuadPart);
|
||||||
|
|
||||||
/* Initialize the DPC object here */
|
/* Initialize the DPC object here */
|
||||||
IoInitializeDpcRequest(*DeviceObject, IDEDpcForIsr);
|
IoInitializeDpcRequest(*DeviceObject, IDEDpcForIsr);
|
||||||
|
|
||||||
DPRINT("%wZ %luMB\n", &DeviceName, DeviceExtension->Size / 2048);
|
DPRINT("%wZ %I64dMB\n",
|
||||||
|
&DeviceName,
|
||||||
|
DeviceExtension->PartitionLength.QuadPart >> 20);
|
||||||
|
|
||||||
/* assign arc name */
|
/* assign arc name */
|
||||||
swprintf(ArcNameBuffer,
|
swprintf(ArcNameBuffer,
|
||||||
|
@ -1307,8 +1320,8 @@ IDEDispatchOpenClose(IN PDEVICE_OBJECT pDO,
|
||||||
// NTSTATUS
|
// NTSTATUS
|
||||||
//
|
//
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS STDCALL
|
||||||
STDCALL IDEDispatchReadWrite(IN PDEVICE_OBJECT pDO,
|
IDEDispatchReadWrite(IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp)
|
IN PIRP Irp)
|
||||||
{
|
{
|
||||||
ULONG IrpInsertKey;
|
ULONG IrpInsertKey;
|
||||||
|
@ -1317,47 +1330,28 @@ STDCALL IDEDispatchReadWrite(IN PDEVICE_OBJECT pDO,
|
||||||
PIDE_DEVICE_EXTENSION DeviceExtension;
|
PIDE_DEVICE_EXTENSION DeviceExtension;
|
||||||
|
|
||||||
IrpStack = IoGetCurrentIrpStackLocation(Irp);
|
IrpStack = IoGetCurrentIrpStackLocation(Irp);
|
||||||
DeviceExtension = (PIDE_DEVICE_EXTENSION)pDO->DeviceExtension;
|
DeviceExtension = (PIDE_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||||
|
|
||||||
// Validate operation parameters
|
// Validate operation parameters
|
||||||
AdjustedOffset = RtlEnlargedIntegerMultiply(DeviceExtension->Offset,
|
AdjustedOffset.QuadPart = DeviceExtension->StartingOffset.QuadPart +
|
||||||
DeviceExtension->BytesPerSector);
|
IrpStack->Parameters.Read.ByteOffset.QuadPart;
|
||||||
DPRINT("Offset:%ld * BytesPerSector:%ld = AdjOffset:%ld:%ld\n",
|
DPRINT("AdjustedOffset: %I64x\n", AdjustedOffset.QuadPart);
|
||||||
DeviceExtension->Offset,
|
|
||||||
DeviceExtension->BytesPerSector,
|
AdjustedExtent.QuadPart = AdjustedOffset.QuadPart +
|
||||||
(unsigned long) AdjustedOffset.u.HighPart,
|
(ULONGLONG)IrpStack->Parameters.Read.Length;
|
||||||
(unsigned long) AdjustedOffset.u.LowPart);
|
DPRINT("AdjustedExtent: %I64x\n", AdjustedExtent.QuadPart);
|
||||||
DPRINT("AdjOffset:%ld:%ld + ByteOffset:%ld:%ld\n",
|
|
||||||
(unsigned long) AdjustedOffset.u.HighPart,
|
PartitionExtent.QuadPart = DeviceExtension->StartingOffset.QuadPart +
|
||||||
(unsigned long) AdjustedOffset.u.LowPart,
|
DeviceExtension->PartitionLength.QuadPart;
|
||||||
(unsigned long) IrpStack->Parameters.Read.ByteOffset.u.HighPart,
|
DPRINT("PartitionExtent: %I64x\n", PartitionExtent.QuadPart);
|
||||||
(unsigned long) IrpStack->Parameters.Read.ByteOffset.u.LowPart);
|
|
||||||
AdjustedOffset = RtlLargeIntegerAdd(AdjustedOffset,
|
|
||||||
IrpStack->Parameters.Read.ByteOffset);
|
|
||||||
DPRINT(" = AdjOffset:%ld:%ld\n",
|
|
||||||
(unsigned long) AdjustedOffset.u.HighPart,
|
|
||||||
(unsigned long) AdjustedOffset.u.LowPart);
|
|
||||||
AdjustedExtent = RtlLargeIntegerAdd(AdjustedOffset,
|
|
||||||
RtlConvertLongToLargeInteger(IrpStack->Parameters.Read.Length));
|
|
||||||
DPRINT("AdjOffset:%ld:%ld + Length:%ld = AdjExtent:%ld:%ld\n",
|
|
||||||
(unsigned long) AdjustedOffset.u.HighPart,
|
|
||||||
(unsigned long) AdjustedOffset.u.LowPart,
|
|
||||||
IrpStack->Parameters.Read.Length,
|
|
||||||
(unsigned long) AdjustedExtent.u.HighPart,
|
|
||||||
(unsigned long) AdjustedExtent.u.LowPart);
|
|
||||||
/*FIXME: this assumption will fail on drives bigger than 1TB */
|
|
||||||
PartitionExtent.QuadPart = DeviceExtension->Offset + DeviceExtension->Size;
|
|
||||||
PartitionExtent = RtlExtendedIntegerMultiply(PartitionExtent,
|
|
||||||
DeviceExtension->BytesPerSector);
|
|
||||||
if ((AdjustedExtent.QuadPart > PartitionExtent.QuadPart) ||
|
if ((AdjustedExtent.QuadPart > PartitionExtent.QuadPart) ||
|
||||||
(IrpStack->Parameters.Read.Length & (DeviceExtension->BytesPerSector - 1)))
|
(IrpStack->Parameters.Read.Length & (DeviceExtension->BytesPerSector - 1)))
|
||||||
{
|
{
|
||||||
DPRINT("Request failed on bad parameters\n",0);
|
DPRINT("Request failed on bad parameters\n",0);
|
||||||
DPRINT("AdjustedExtent=%d:%d PartitionExtent=%d:%d ReadLength=%d\n",
|
DPRINT("AdjustedExtent=%I64x PartitionExtent=%I64x ReadLength=%lx\n",
|
||||||
(unsigned int) AdjustedExtent.u.HighPart,
|
AdjustedExtent.QuadPart,
|
||||||
(unsigned int) AdjustedExtent.u.LowPart,
|
PartitionExtent.QuadPart,
|
||||||
(unsigned int) PartitionExtent.u.HighPart,
|
|
||||||
(unsigned int) PartitionExtent.u.LowPart,
|
|
||||||
IrpStack->Parameters.Read.Length);
|
IrpStack->Parameters.Read.Length);
|
||||||
Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
|
Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
@ -1369,9 +1363,9 @@ DPRINT("AdjOffset:%ld:%ld + Length:%ld = AdjExtent:%ld:%ld\n",
|
||||||
|
|
||||||
// Start the packet and insert the request in order of sector offset
|
// Start the packet and insert the request in order of sector offset
|
||||||
assert(DeviceExtension->BytesPerSector == 512);
|
assert(DeviceExtension->BytesPerSector == 512);
|
||||||
InsertKeyLI = RtlLargeIntegerShiftRight(IrpStack->Parameters.Read.ByteOffset, 9);
|
InsertKeyLI.QuadPart = IrpStack->Parameters.Read.ByteOffset.QuadPart >> 9;
|
||||||
IrpInsertKey = InsertKeyLI.u.LowPart;
|
IrpInsertKey = InsertKeyLI.u.LowPart;
|
||||||
IoStartPacket(DeviceExtension->DeviceObject, Irp, &IrpInsertKey, NULL);
|
IoStartPacket(DeviceObject, Irp, &IrpInsertKey, NULL);
|
||||||
|
|
||||||
DPRINT("Returning STATUS_PENDING\n");
|
DPRINT("Returning STATUS_PENDING\n");
|
||||||
return STATUS_PENDING;
|
return STATUS_PENDING;
|
||||||
|
@ -1439,6 +1433,37 @@ DPRINT("DiskDeviceExtension->BytesPerSector %lu\n", DiskDeviceExtension->BytesPe
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCTL_DISK_GET_PARTITION_INFO:
|
case IOCTL_DISK_GET_PARTITION_INFO:
|
||||||
|
DPRINT("IOCTL_DISK_GET_PARTITION_INFO\n");
|
||||||
|
if (IrpStack->Parameters.DeviceIoControl.OutputBufferLength <
|
||||||
|
sizeof(PARTITION_INFORMATION))
|
||||||
|
{
|
||||||
|
Irp->IoStatus.Status = STATUS_INFO_LENGTH_MISMATCH;
|
||||||
|
}
|
||||||
|
else if (DeviceExtension->PartitionNumber == 0)
|
||||||
|
{
|
||||||
|
Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PPARTITION_INFORMATION PartitionInfo;
|
||||||
|
|
||||||
|
PartitionInfo = (PPARTITION_INFORMATION)Irp->AssociatedIrp.SystemBuffer;
|
||||||
|
|
||||||
|
PartitionInfo->PartitionType = DeviceExtension->PartitionType;
|
||||||
|
PartitionInfo->StartingOffset = DeviceExtension->StartingOffset;
|
||||||
|
PartitionInfo->PartitionLength = DeviceExtension->PartitionLength;
|
||||||
|
PartitionInfo->HiddenSectors = DeviceExtension->HiddenSectors;
|
||||||
|
PartitionInfo->PartitionNumber = DeviceExtension->PartitionNumber;
|
||||||
|
PartitionInfo->BootIndicator = DeviceExtension->BootIndicator;
|
||||||
|
PartitionInfo->RewritePartition = FALSE;
|
||||||
|
PartitionInfo->RecognizedPartition =
|
||||||
|
IsRecognizedPartition(DeviceExtension->PartitionType);
|
||||||
|
|
||||||
|
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||||
|
Irp->IoStatus.Information = sizeof(PARTITION_INFORMATION);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case IOCTL_DISK_SET_PARTITION_INFO:
|
case IOCTL_DISK_SET_PARTITION_INFO:
|
||||||
RC = STATUS_INVALID_DEVICE_REQUEST;
|
RC = STATUS_INVALID_DEVICE_REQUEST;
|
||||||
Irp->IoStatus.Status = RC;
|
Irp->IoStatus.Status = RC;
|
||||||
|
|
|
@ -139,8 +139,13 @@ typedef struct _IDE_DEVICE_EXTENSION
|
||||||
int LogicalCylinders;
|
int LogicalCylinders;
|
||||||
int SectorsPerLogCyl;
|
int SectorsPerLogCyl;
|
||||||
int SectorsPerLogTrk;
|
int SectorsPerLogTrk;
|
||||||
int Offset;
|
|
||||||
int Size;
|
LARGE_INTEGER StartingOffset;
|
||||||
|
LARGE_INTEGER PartitionLength;
|
||||||
|
ULONG HiddenSectors;
|
||||||
|
ULONG PartitionNumber;
|
||||||
|
UCHAR PartitionType;
|
||||||
|
BOOLEAN BootIndicator;
|
||||||
|
|
||||||
int Operation;
|
int Operation;
|
||||||
ULONG BytesRequested;
|
ULONG BytesRequested;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue