mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +00:00
[FASTFAT]
- Move verification code to the BlockDev* functions (like CDFS does) so functions that call those directly will have verification handled for them - Add verification handling for IOCTL requests svn path=/trunk/; revision=52374
This commit is contained in:
parent
af892bdd85
commit
ae5018a9dd
3 changed files with 84 additions and 43 deletions
|
@ -38,6 +38,10 @@ VfatReadWritePartialCompletion (IN PDEVICE_OBJECT DeviceObject,
|
|||
{
|
||||
IrpContext->Flags |= IRPCONTEXT_PENDINGRETURNED;
|
||||
}
|
||||
else
|
||||
{
|
||||
IrpContext->Flags &= ~IRPCONTEXT_PENDINGRETURNED;
|
||||
}
|
||||
if (!NT_SUCCESS(Irp->IoStatus.Status))
|
||||
{
|
||||
IrpContext->Irp->IoStatus.Status = Irp->IoStatus.Status;
|
||||
|
@ -67,6 +71,7 @@ VfatReadDisk (IN PDEVICE_OBJECT pDeviceObject,
|
|||
KEVENT event;
|
||||
NTSTATUS Status;
|
||||
|
||||
again:
|
||||
KeInitializeEvent (&event, NotificationEvent, FALSE);
|
||||
|
||||
DPRINT ("VfatReadDisk(pDeviceObject %p, Offset %I64x, Length %d, Buffer %p)\n",
|
||||
|
@ -104,6 +109,25 @@ VfatReadDisk (IN PDEVICE_OBJECT pDeviceObject,
|
|||
Status = IoStatus.Status;
|
||||
}
|
||||
|
||||
if (Status == STATUS_VERIFY_REQUIRED)
|
||||
{
|
||||
PDEVICE_OBJECT DeviceToVerify;
|
||||
|
||||
DPRINT1 ("Media change detected!\n");
|
||||
|
||||
/* Find the device to verify and reset the thread field to empty value again. */
|
||||
DeviceToVerify = IoGetDeviceToVerify (PsGetCurrentThread ());
|
||||
IoSetDeviceToVerify (PsGetCurrentThread (), NULL);
|
||||
Status = IoVerifyVolume (DeviceToVerify,
|
||||
FALSE);
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1 ("Volume verification successful; Reissuing read request\n");
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
|
||||
if (!NT_SUCCESS (Status))
|
||||
{
|
||||
DPRINT ("IO failed!!! VfatReadDisk : Error code: %x\n", Status);
|
||||
|
@ -134,6 +158,7 @@ VfatReadDiskPartial (IN PVFAT_IRP_CONTEXT IrpContext,
|
|||
|
||||
Buffer = (PCHAR)MmGetMdlVirtualAddress(IrpContext->Irp->MdlAddress) + BufferOffset;
|
||||
|
||||
again:
|
||||
Irp = IoAllocateIrp(IrpContext->DeviceExt->StorageDevice->StackSize, TRUE);
|
||||
if (Irp == NULL)
|
||||
{
|
||||
|
@ -190,6 +215,25 @@ VfatReadDiskPartial (IN PVFAT_IRP_CONTEXT IrpContext,
|
|||
Status = IrpContext->Irp->IoStatus.Status;
|
||||
}
|
||||
|
||||
if (Status == STATUS_VERIFY_REQUIRED)
|
||||
{
|
||||
PDEVICE_OBJECT DeviceToVerify;
|
||||
|
||||
DPRINT1 ("Media change detected!\n");
|
||||
|
||||
/* Find the device to verify and reset the thread field to empty value again. */
|
||||
DeviceToVerify = IoGetDeviceToVerify (PsGetCurrentThread ());
|
||||
IoSetDeviceToVerify (PsGetCurrentThread (), NULL);
|
||||
Status = IoVerifyVolume (DeviceToVerify,
|
||||
FALSE);
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1 ("Volume verification successful; Reissuing read request\n");
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
|
||||
DPRINT("%x\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
@ -212,6 +256,7 @@ VfatWriteDiskPartial (IN PVFAT_IRP_CONTEXT IrpContext,
|
|||
|
||||
Buffer = (PCHAR)MmGetMdlVirtualAddress(IrpContext->Irp->MdlAddress) + BufferOffset;
|
||||
|
||||
again:
|
||||
DPRINT ("Building asynchronous FSD Request...\n");
|
||||
Irp = IoAllocateIrp(IrpContext->DeviceExt->StorageDevice->StackSize, TRUE);
|
||||
if (Irp == NULL)
|
||||
|
@ -268,6 +313,25 @@ VfatWriteDiskPartial (IN PVFAT_IRP_CONTEXT IrpContext,
|
|||
Status = IrpContext->Irp->IoStatus.Status;
|
||||
}
|
||||
|
||||
if (Status == STATUS_VERIFY_REQUIRED)
|
||||
{
|
||||
PDEVICE_OBJECT DeviceToVerify;
|
||||
|
||||
DPRINT1 ("Media change detected!\n");
|
||||
|
||||
/* Find the device to verify and reset the thread field to empty value again. */
|
||||
DeviceToVerify = IoGetDeviceToVerify (PsGetCurrentThread ());
|
||||
IoSetDeviceToVerify (PsGetCurrentThread (), NULL);
|
||||
Status = IoVerifyVolume (DeviceToVerify,
|
||||
FALSE);
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1 ("Volume verification successful; Reissuing write request\n");
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -292,6 +356,7 @@ VfatBlockDeviceIoControl (IN PDEVICE_OBJECT DeviceObject,
|
|||
InputBuffer, InputBufferSize, OutputBuffer, OutputBufferSize,
|
||||
OutputBufferSize ? *OutputBufferSize : 0);
|
||||
|
||||
again:
|
||||
KeInitializeEvent (&Event, NotificationEvent, FALSE);
|
||||
|
||||
DPRINT("Building device I/O control request ...\n");
|
||||
|
@ -328,6 +393,25 @@ VfatBlockDeviceIoControl (IN PDEVICE_OBJECT DeviceObject,
|
|||
|
||||
Status = IoStatus.Status;
|
||||
}
|
||||
|
||||
if (Status == STATUS_VERIFY_REQUIRED)
|
||||
{
|
||||
PDEVICE_OBJECT DeviceToVerify;
|
||||
|
||||
DPRINT1 ("Media change detected!\n");
|
||||
|
||||
/* Find the device to verify and reset the thread field to empty value again. */
|
||||
DeviceToVerify = IoGetDeviceToVerify (PsGetCurrentThread ());
|
||||
IoSetDeviceToVerify (PsGetCurrentThread (), NULL);
|
||||
Status = IoVerifyVolume (DeviceToVerify,
|
||||
FALSE);
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1 ("Volume verification successful; Reissuing IOCTL request\n");
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
|
||||
if (OutputBufferSize)
|
||||
{
|
||||
|
|
|
@ -372,20 +372,6 @@ VfatOpenFile (
|
|||
0,
|
||||
FALSE);
|
||||
|
||||
if (Status == STATUS_VERIFY_REQUIRED)
|
||||
|
||||
{
|
||||
PDEVICE_OBJECT DeviceToVerify;
|
||||
|
||||
DPRINT ("Media change detected!\n");
|
||||
DPRINT ("Device %p\n", DeviceExt->StorageDevice);
|
||||
|
||||
/* Find the device to verify and reset the thread field to empty value again. */
|
||||
DeviceToVerify = IoGetDeviceToVerify (PsGetCurrentThread ());
|
||||
IoSetDeviceToVerify (PsGetCurrentThread (), NULL);
|
||||
Status = IoVerifyVolume (DeviceToVerify,
|
||||
FALSE);
|
||||
}
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT ("Status %lx\n", Status);
|
||||
|
|
|
@ -537,7 +537,6 @@ VfatRead(PVFAT_IRP_CONTEXT IrpContext)
|
|||
PERESOURCE Resource = NULL;
|
||||
LARGE_INTEGER ByteOffset;
|
||||
PVOID Buffer;
|
||||
PDEVICE_OBJECT DeviceToVerify;
|
||||
ULONG BytesPerSector;
|
||||
|
||||
ASSERT(IrpContext);
|
||||
|
@ -697,20 +696,6 @@ VfatRead(PVFAT_IRP_CONTEXT IrpContext)
|
|||
}
|
||||
|
||||
Status = VfatReadFileData(IrpContext, Length, ByteOffset, &ReturnedLength);
|
||||
if (Status == STATUS_VERIFY_REQUIRED)
|
||||
{
|
||||
DPRINT("VfatReadFileData returned STATUS_VERIFY_REQUIRED\n");
|
||||
DeviceToVerify = IoGetDeviceToVerify(PsGetCurrentThread());
|
||||
IoSetDeviceToVerify(PsGetCurrentThread(), NULL);
|
||||
Status = IoVerifyVolume (DeviceToVerify, FALSE);
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Status = VfatReadFileData(IrpContext, Length,
|
||||
ByteOffset, &ReturnedLength);
|
||||
}
|
||||
}
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
IrpContext->Irp->IoStatus.Information = ReturnedLength;
|
||||
|
@ -767,7 +752,6 @@ NTSTATUS VfatWrite (PVFAT_IRP_CONTEXT IrpContext)
|
|||
ULONG OldAllocationSize;
|
||||
PVOID Buffer;
|
||||
ULONG BytesPerSector;
|
||||
PDEVICE_OBJECT DeviceToVerify;
|
||||
|
||||
ASSERT(IrpContext);
|
||||
|
||||
|
@ -989,19 +973,6 @@ NTSTATUS VfatWrite (PVFAT_IRP_CONTEXT IrpContext)
|
|||
}
|
||||
|
||||
Status = VfatWriteFileData(IrpContext, Length, ByteOffset);
|
||||
if (Status == STATUS_VERIFY_REQUIRED)
|
||||
{
|
||||
DPRINT("VfatWriteFileData returned STATUS_VERIFY_REQUIRED\n");
|
||||
DeviceToVerify = IoGetDeviceToVerify(PsGetCurrentThread());
|
||||
IoSetDeviceToVerify(PsGetCurrentThread(), NULL);
|
||||
Status = IoVerifyVolume (DeviceToVerify, FALSE);
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Status = VfatWriteFileData(IrpContext, Length, ByteOffset);
|
||||
}
|
||||
}
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
IrpContext->Irp->IoStatus.Information = Length;
|
||||
|
|
Loading…
Reference in a new issue