[FASTFAT]

- Handle STATUS_VERIFY_REQUIRED for write requests
- Clear the device to verify after retrieving it
- Fixes write failure after changing floppy media
[CDFS]
- Reissue the I/O request if IoVerifyVolume was successful
- Fixes read after a media change

svn path=/trunk/; revision=52372
This commit is contained in:
Cameron Gutman 2011-06-19 19:43:52 +00:00
parent cef5719846
commit e2d92bfd5e
2 changed files with 35 additions and 11 deletions

View file

@ -50,6 +50,7 @@ CdfsReadSectors(IN PDEVICE_OBJECT DeviceObject,
PIRP Irp;
NTSTATUS Status;
again:
KeInitializeEvent(&Event,
NotificationEvent,
FALSE);
@ -102,14 +103,19 @@ CdfsReadSectors(IN PDEVICE_OBJECT DeviceObject,
if (Status == STATUS_VERIFY_REQUIRED)
{
PDEVICE_OBJECT DeviceToVerify;
NTSTATUS NewStatus;
DPRINT1("STATUS_VERIFY_REQUIRED\n");
DeviceToVerify = IoGetDeviceToVerify(PsGetCurrentThread());
IoSetDeviceToVerify(PsGetCurrentThread(), NULL);
NewStatus = IoVerifyVolume(DeviceToVerify, FALSE);
DPRINT1("IoVerifyVolume() returned (Status %lx)\n", NewStatus);
Status = IoVerifyVolume(DeviceToVerify, FALSE);
DPRINT1("IoVerifyVolume() returned (Status %lx)\n", Status);
if (NT_SUCCESS(Status))
{
DPRINT1("Volume verify succeeded; trying request again\n");
goto again;
}
}
DPRINT("CdfsReadSectors() failed (Status %x)\n", Status);
@ -146,6 +152,7 @@ CdfsDeviceIoControl (IN PDEVICE_OBJECT DeviceObject,
InputBuffer, InputBufferSize, OutputBuffer, OutputBufferSize,
OutputBufferSize ? *OutputBufferSize : 0);
again:
KeInitializeEvent (&Event, NotificationEvent, FALSE);
DPRINT("Building device I/O control request ...\n");
@ -191,7 +198,6 @@ CdfsDeviceIoControl (IN PDEVICE_OBJECT DeviceObject,
if (Status == STATUS_VERIFY_REQUIRED)
{
PDEVICE_OBJECT DeviceToVerify;
NTSTATUS NewStatus;
DPRINT1("STATUS_VERIFY_REQUIRED\n");
DeviceToVerify = IoGetDeviceToVerify(PsGetCurrentThread());
@ -199,8 +205,14 @@ CdfsDeviceIoControl (IN PDEVICE_OBJECT DeviceObject,
if (DeviceToVerify)
{
NewStatus = IoVerifyVolume(DeviceToVerify, FALSE);
DPRINT1("IoVerifyVolume() returned (Status %lx)\n", NewStatus);
Status = IoVerifyVolume(DeviceToVerify, FALSE);
DPRINT1("IoVerifyVolume() returned (Status %lx)\n", Status);
}
if (NT_SUCCESS(Status))
{
DPRINT1("Volume verify succeeded; trying request again\n");
goto again;
}
}

View file

@ -697,12 +697,11 @@ VfatRead(PVFAT_IRP_CONTEXT IrpContext)
}
Status = VfatReadFileData(IrpContext, Length, ByteOffset, &ReturnedLength);
/**/
if (Status == STATUS_VERIFY_REQUIRED)
{
DPRINT("VfatReadFile returned STATUS_VERIFY_REQUIRED\n");
DPRINT("VfatReadFileData returned STATUS_VERIFY_REQUIRED\n");
DeviceToVerify = IoGetDeviceToVerify(PsGetCurrentThread());
IoSetDeviceToVerify(PsGetCurrentThread(), DeviceToVerify);
IoSetDeviceToVerify(PsGetCurrentThread(), NULL);
Status = IoVerifyVolume (DeviceToVerify, FALSE);
if (NT_SUCCESS(Status))
@ -710,9 +709,8 @@ VfatRead(PVFAT_IRP_CONTEXT IrpContext)
Status = VfatReadFileData(IrpContext, Length,
ByteOffset, &ReturnedLength);
}
}
/**/
if (NT_SUCCESS(Status))
{
IrpContext->Irp->IoStatus.Information = ReturnedLength;
@ -769,6 +767,7 @@ NTSTATUS VfatWrite (PVFAT_IRP_CONTEXT IrpContext)
ULONG OldAllocationSize;
PVOID Buffer;
ULONG BytesPerSector;
PDEVICE_OBJECT DeviceToVerify;
ASSERT(IrpContext);
@ -990,6 +989,19 @@ 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;