[ros-diffs] [pschweitzer] 39025: - Implemented FatPerformDevIoCtrl - Use it while mounting new volume to get the right sector size. This fixes a TODO (that was looking as a hack :p)

pschweitzer at svn.reactos.org pschweitzer at svn.reactos.org
Thu Jan 22 18:25:28 CET 2009


Author: pschweitzer
Date: Thu Jan 22 11:25:28 2009
New Revision: 39025

URL: http://svn.reactos.org/svn/reactos?rev=39025&view=rev
Log:
- Implemented FatPerformDevIoCtrl
- Use it while mounting new volume to get the right sector size. This fixes a TODO (that was looking as a hack :p)

Modified:
    trunk/reactos/drivers/filesystems/fastfat_new/device.c
    trunk/reactos/drivers/filesystems/fastfat_new/fastfat.h
    trunk/reactos/drivers/filesystems/fastfat_new/fsctl.c

Modified: trunk/reactos/drivers/filesystems/fastfat_new/device.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat_new/device.c?rev=39025&r1=39024&r2=39025&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat_new/device.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat_new/device.c [iso-8859-1] Thu Jan 22 11:25:28 2009
@@ -21,4 +21,51 @@
     return STATUS_NOT_IMPLEMENTED;
 }
 
+NTSTATUS
+FatPerformDevIoCtrl(PDEVICE_OBJECT DeviceObject,
+		            ULONG ControlCode,
+		            PVOID InputBuffer,
+		            ULONG InputBufferSize,
+		            PVOID OutputBuffer,
+		            ULONG OutputBufferSize,
+		            BOOLEAN Override)
+{
+    PIRP Irp;
+    KEVENT Event;
+    NTSTATUS Status;
+    PIO_STACK_LOCATION Stack;
+    IO_STATUS_BLOCK IoStatus;
+
+    KeInitializeEvent(&Event, NotificationEvent, FALSE);
+
+    Irp = IoBuildDeviceIoControlRequest(ControlCode,
+				                        DeviceObject,
+				                        InputBuffer,
+				                        InputBufferSize,
+				                        OutputBuffer,
+				                        OutputBufferSize,
+				                        FALSE,
+				                        &Event,
+				                        &IoStatus);
+    if (Irp == NULL)
+    {
+        return STATUS_INSUFFICIENT_RESOURCES;
+    }
+
+    if (Override)
+    {
+        Stack = IoGetNextIrpStackLocation(Irp);
+        Stack->Flags |= SL_OVERRIDE_VERIFY_VOLUME;
+    }
+
+    Status = IoCallDriver(DeviceObject, Irp);
+    if (Status == STATUS_PENDING)
+    {
+        KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
+        Status = IoStatus.Status;
+    }
+
+    return Status;
+}
+
 /* EOF */

Modified: trunk/reactos/drivers/filesystems/fastfat_new/fastfat.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat_new/fastfat.h?rev=39025&r1=39024&r2=39025&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat_new/fastfat.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat_new/fastfat.h [iso-8859-1] Thu Jan 22 11:25:28 2009
@@ -342,6 +342,15 @@
 NTSTATUS NTAPI
 FatDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp);
 
+NTSTATUS
+FatPerformDevIoCtrl(PDEVICE_OBJECT DeviceObject,
+		            ULONG ControlCode,
+		            PVOID InputBuffer,
+		            ULONG InputBufferSize,
+		            PVOID OutputBuffer,
+		            ULONG OutputBufferSize,
+		            BOOLEAN Override);
+
 /*  ------------------------------------------------------  direntry.c  */
 
 /*  -----------------------------------------------------------  fcb.c  */

Modified: trunk/reactos/drivers/filesystems/fastfat_new/fsctl.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat_new/fsctl.c?rev=39025&r1=39024&r2=39025&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat_new/fsctl.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat_new/fsctl.c [iso-8859-1] Thu Jan 22 11:25:28 2009
@@ -55,6 +55,7 @@
                PDEVICE_OBJECT FsDeviceObject)
 {
     NTSTATUS Status;
+    DISK_GEOMETRY DiskGeometry;
     PVOLUME_DEVICE_OBJECT VolumeDevice;
 
     DPRINT1("FatMountVolume()\n");
@@ -89,8 +90,18 @@
     /* Init stack size */
     VolumeDevice->DeviceObject.StackSize = TargetDeviceObject->StackSize + 1;
 
-    /* TODO: IOCTL_DISK_GET_DRIVE_GEOMETRY to obtain BytesPerSector */
-    VolumeDevice->DeviceObject.SectorSize = 512;
+    /* Get sector size */
+    Status = FatPerformDevIoCtrl(TargetDeviceObject,
+                                 IOCTL_DISK_GET_DRIVE_GEOMETRY,
+                                 NULL,
+                                 0,
+                                 &DiskGeometry,
+                                 sizeof(DISK_GEOMETRY),
+                                 TRUE);
+
+    if (!NT_SUCCESS(Status)) return Status;
+
+    VolumeDevice->DeviceObject.SectorSize = DiskGeometry.BytesPerSector;
 
     /* Signal we're done with initializing */
     VolumeDevice->DeviceObject.Flags &= ~DO_DEVICE_INITIALIZING;



More information about the Ros-diffs mailing list