- 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)

svn path=/trunk/; revision=39025
This commit is contained in:
Pierre Schweitzer 2009-01-22 17:25:28 +00:00
parent 63677b493d
commit 68ca50178c
3 changed files with 69 additions and 2 deletions

View file

@ -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 */

View file

@ -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 */

View file

@ -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;