https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b9b461bde95804f3dcf14…
commit b9b461bde95804f3dcf1455a1bfbf25cfdb8aedc
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Sun Dec 24 21:54:09 2017 +0100
[DISK] Properly implement querying partition information for partition 0.
In spite of what was implemented in our NT DDK sample, this is a legit operation.
This may have been turned legit starting NT5 (reminder, our implementation is
NT4 based...). So, in this situation, just return the information about the whole
disk (and not a random size) and also, mark everything with default values.
See disk_new for an example of how it works in NT5+.
CORE-14124
---
drivers/storage/class/disk/disk.c | 71 ++++++++++++++++++++++-----------------
1 file changed, 41 insertions(+), 30 deletions(-)
diff --git a/drivers/storage/class/disk/disk.c b/drivers/storage/class/disk/disk.c
index e0c775688d..cb84565691 100644
--- a/drivers/storage/class/disk/disk.c
+++ b/drivers/storage/class/disk/disk.c
@@ -2235,58 +2235,69 @@ Return Value:
sizeof(PARTITION_INFORMATION)) {
status = STATUS_INFO_LENGTH_MISMATCH;
-
+ break;
}
-#if 0 // HACK: ReactOS partition numbers must be wrong
- else if (diskData->PartitionNumber == 0) {
+
+ //
+ // Update the geometry in case it has changed.
+ //
+
+ status = UpdateRemovableGeometry (DeviceObject, Irp);
+
+ if (!NT_SUCCESS(status)) {
//
- // Partition zero is not a partition so this is not a
- // reasonable request.
+ // Note the drive is not ready.
//
- status = STATUS_INVALID_DEVICE_REQUEST;
-
+ diskData->DriveNotReady = TRUE;
+ break;
}
-#endif
- else {
- PPARTITION_INFORMATION outputBuffer;
+ //
+ // Note the drive is now ready.
+ //
- if (diskData->PartitionNumber == 0) {
- DPRINT1("HACK: Handling partition 0 request!\n");
- //ASSERT(FALSE);
- }
+ diskData->DriveNotReady = FALSE;
- //
- // Update the geometry in case it has changed.
- //
+ //
+ // Handle the case were we query the whole disk
+ //
- status = UpdateRemovableGeometry (DeviceObject, Irp);
+ if (diskData->PartitionNumber == 0) {
- if (!NT_SUCCESS(status)) {
+ PPARTITION_INFORMATION outputBuffer;
- //
- // Note the drive is not ready.
- //
+ outputBuffer =
+ (PPARTITION_INFORMATION)Irp->AssociatedIrp.SystemBuffer;
- diskData->DriveNotReady = TRUE;
- break;
- }
+ outputBuffer->PartitionType = PARTITION_ENTRY_UNUSED;
+ outputBuffer->StartingOffset = deviceExtension->StartingOffset;
+ outputBuffer->PartitionLength.QuadPart = deviceExtension->PartitionLength.QuadPart;
+ outputBuffer->HiddenSectors = 0;
+ outputBuffer->PartitionNumber = diskData->PartitionNumber;
+ outputBuffer->BootIndicator = FALSE;
+ outputBuffer->RewritePartition = FALSE;
+ outputBuffer->RecognizedPartition = FALSE;
+
+ status = STATUS_SUCCESS;
+ Irp->IoStatus.Information = sizeof(PARTITION_INFORMATION);
+
+ } else {
+
+ PPARTITION_INFORMATION outputBuffer;
//
- // Note the drive is now ready.
+ // We query a single partition here
+ // FIXME: this can only work for MBR-based disks, check for this!
//
- diskData->DriveNotReady = FALSE;
-
outputBuffer =
(PPARTITION_INFORMATION)Irp->AssociatedIrp.SystemBuffer;
outputBuffer->PartitionType = diskData->PartitionType;
outputBuffer->StartingOffset = deviceExtension->StartingOffset;
- outputBuffer->PartitionLength.QuadPart = (diskData->PartitionNumber) ?
- deviceExtension->PartitionLength.QuadPart : 0x1FFFFFFFFFFFFFFFLL; // HACK
+ outputBuffer->PartitionLength.QuadPart = deviceExtension->PartitionLength.QuadPart;
outputBuffer->HiddenSectors = diskData->HiddenSectors;
outputBuffer->PartitionNumber = diskData->PartitionNumber;
outputBuffer->BootIndicator = diskData->BootIndicator;