diff --git a/reactos/drivers/filesystems/fastfat_new/device.c b/reactos/drivers/filesystems/fastfat_new/device.c index 739a82dfc9a..a3103aab365 100644 --- a/reactos/drivers/filesystems/fastfat_new/device.c +++ b/reactos/drivers/filesystems/fastfat_new/device.c @@ -21,4 +21,51 @@ FatDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp) 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 */ diff --git a/reactos/drivers/filesystems/fastfat_new/fastfat.h b/reactos/drivers/filesystems/fastfat_new/fastfat.h index 44984e60722..07c6488669e 100644 --- a/reactos/drivers/filesystems/fastfat_new/fastfat.h +++ b/reactos/drivers/filesystems/fastfat_new/fastfat.h @@ -342,6 +342,15 @@ DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath); 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 */ diff --git a/reactos/drivers/filesystems/fastfat_new/fsctl.c b/reactos/drivers/filesystems/fastfat_new/fsctl.c index e835fe3214c..1fb53c72d0b 100644 --- a/reactos/drivers/filesystems/fastfat_new/fsctl.c +++ b/reactos/drivers/filesystems/fastfat_new/fsctl.c @@ -55,6 +55,7 @@ FatMountVolume(PFAT_IRP_CONTEXT IrpContext, PDEVICE_OBJECT FsDeviceObject) { NTSTATUS Status; + DISK_GEOMETRY DiskGeometry; PVOLUME_DEVICE_OBJECT VolumeDevice; DPRINT1("FatMountVolume()\n"); @@ -89,8 +90,18 @@ FatMountVolume(PFAT_IRP_CONTEXT IrpContext, /* 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;