Author: pschweitzer
Date: Sun Nov  2 23:11:22 2014
New Revision: 65205

URL: http://svn.reactos.org/svn/reactos?rev=65205&view=rev
Log:
[DISK]
Add a hack to forcibly set sector size in case of weird input. This is noisy on 
purpose.
Also, be more informative in case of read rejection. Are we reading beyond 
partition or do we have invalid sector size?
With the hack, the invalid sector size should disappear.

This is to help debugging the recent errors with the removal of 
IopParseDevice() hack

Modified:
    trunk/reactos/drivers/storage/class/disk/disk.c

Modified: trunk/reactos/drivers/storage/class/disk/disk.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/storage/class/disk/disk.c?rev=65205&r1=65204&r2=65205&view=diff
==============================================================================
--- trunk/reactos/drivers/storage/class/disk/disk.c     [iso-8859-1] (original)
+++ trunk/reactos/drivers/storage/class/disk/disk.c     [iso-8859-1] Sun Nov  2 
23:11:22 2014
@@ -1515,6 +1515,15 @@
     LARGE_INTEGER startingOffset;
 
     //
+    // HACK: How can we end here with null sector size?!
+    //
+
+    if (deviceExtension->DiskGeometry->Geometry.BytesPerSector == 0) {
+        DPRINT1("Hack! Received invalid sector size\n");
+        deviceExtension->DiskGeometry->Geometry.BytesPerSector = 512;
+    }
+
+    //
     // Verify parameters of this request.
     // Check that ending sector is within partition and
     // that number of bytes to transfer is a multiple of
@@ -1550,7 +1559,18 @@
             Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
         }
 
-        DPRINT1("STATUS_INVALID_PARAMETER\n");
+        if (startingOffset.QuadPart > 
deviceExtension->PartitionLength.QuadPart) {
+            DPRINT1("Reading beyond partition end! startingOffset: %I64d, 
PartitionLength: %I64d\n", startingOffset.QuadPart, 
deviceExtension->PartitionLength.QuadPart);
+        }
+
+        if (transferByteCount & 
(deviceExtension->DiskGeometry->Geometry.BytesPerSector - 1)) {
+            DPRINT1("Not reading sectors! TransferByteCount: %lu, 
BytesPerSector: %lu\n", transferByteCount, 
deviceExtension->DiskGeometry->Geometry.BytesPerSector);
+        }
+
+        if (Irp->IoStatus.Status == STATUS_DEVICE_NOT_READY) {
+            DPRINT1("Failing due to device not ready!\n");
+        }
+
         return STATUS_INVALID_PARAMETER;
     }
 


Reply via email to