mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 10:35:28 +00:00
[FASTFAT]
- Modify the VfatHasFileSystem() so that it allows a DO_VERIFY_VOLUME override, when required - Fix the implementation of VfatVerify() so that it actually really does the job it's supposed to do: - it will now use the appropriate DO for verification (lower DO and not volume DO) - it will properly clear the DO_VERIFY_VOLUME flag - Introduce a hack in VfatVerify() so that in case of removal media, if FATInfo is the same, it forces a dismount Effects of this commit: - It properly fixes CORE-9988. That means if a FAT media changes, now FastFAT properly handles it, and does not go to a code path producing (expected!) BSODs - The hack introduces a hacky way to make ReactOS remount FAT floppies when changed In short, changing FAT floppy in ReactOS doesn't make it BSOD any longer. CORE-9988 svn path=/trunk/; revision=73709
This commit is contained in:
parent
73bb103c3c
commit
8987f5fa46
1 changed files with 19 additions and 10 deletions
|
@ -40,7 +40,8 @@ NTSTATUS
|
|||
VfatHasFileSystem(
|
||||
PDEVICE_OBJECT DeviceToMount,
|
||||
PBOOLEAN RecognizedFS,
|
||||
PFATINFO pFatInfo)
|
||||
PFATINFO pFatInfo,
|
||||
BOOLEAN Override)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PARTITION_INFORMATION PartitionInfo;
|
||||
|
@ -64,7 +65,7 @@ VfatHasFileSystem(
|
|||
0,
|
||||
&DiskGeometry,
|
||||
&Size,
|
||||
FALSE);
|
||||
Override);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("VfatBlockDeviceIoControl failed (%x)\n", Status);
|
||||
|
@ -82,7 +83,7 @@ VfatHasFileSystem(
|
|||
0,
|
||||
&PartitionInfo,
|
||||
&Size,
|
||||
FALSE);
|
||||
Override);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("VfatBlockDeviceIoControl failed (%x)\n", Status);
|
||||
|
@ -137,7 +138,7 @@ VfatHasFileSystem(
|
|||
Offset.QuadPart = 0;
|
||||
|
||||
/* Try to recognize FAT12/FAT16/FAT32 partitions */
|
||||
Status = VfatReadDisk(DeviceToMount, &Offset, DiskGeometry.BytesPerSector, (PUCHAR) Boot, FALSE);
|
||||
Status = VfatReadDisk(DeviceToMount, &Offset, DiskGeometry.BytesPerSector, (PUCHAR) Boot, Override);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
if (Boot->Signatur1 != 0xaa55)
|
||||
|
@ -345,7 +346,7 @@ VfatMountDevice(
|
|||
|
||||
DPRINT("Mounting VFAT device...\n");
|
||||
|
||||
Status = VfatHasFileSystem(DeviceToMount, &RecognizedFS, &DeviceExt->FatInfo);
|
||||
Status = VfatHasFileSystem(DeviceToMount, &RecognizedFS, &DeviceExt->FatInfo, FALSE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return Status;
|
||||
|
@ -392,7 +393,7 @@ VfatMount(
|
|||
DeviceToMount = IrpContext->Stack->Parameters.MountVolume.DeviceObject;
|
||||
Vpb = IrpContext->Stack->Parameters.MountVolume.Vpb;
|
||||
|
||||
Status = VfatHasFileSystem(DeviceToMount, &RecognizedFS, &FatInfo);
|
||||
Status = VfatHasFileSystem(DeviceToMount, &RecognizedFS, &FatInfo, FALSE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
goto ByeBye;
|
||||
|
@ -645,19 +646,19 @@ VfatVerify(
|
|||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
FATINFO FatInfo;
|
||||
BOOLEAN RecognizedFS;
|
||||
PDEVICE_EXTENSION DeviceExt = IrpContext->DeviceExt;
|
||||
PDEVICE_EXTENSION DeviceExt;
|
||||
|
||||
DPRINT("VfatVerify(IrpContext %p)\n", IrpContext);
|
||||
|
||||
DeviceToVerify = IrpContext->Stack->Parameters.VerifyVolume.DeviceObject;
|
||||
Status = VfatBlockDeviceIoControl(DeviceToVerify,
|
||||
DeviceExt = DeviceToVerify->DeviceExtension;
|
||||
Status = VfatBlockDeviceIoControl(DeviceExt->StorageDevice,
|
||||
IOCTL_DISK_CHECK_VERIFY,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
TRUE);
|
||||
DeviceToVerify->Flags &= ~DO_VERIFY_VOLUME;
|
||||
if (!NT_SUCCESS(Status) && Status != STATUS_VERIFY_REQUIRED)
|
||||
{
|
||||
DPRINT("VfatBlockDeviceIoControl() failed (Status %lx)\n", Status);
|
||||
|
@ -665,19 +666,25 @@ VfatVerify(
|
|||
}
|
||||
else
|
||||
{
|
||||
Status = VfatHasFileSystem(DeviceToVerify, &RecognizedFS, &FatInfo);
|
||||
Status = VfatHasFileSystem(DeviceExt->StorageDevice, &RecognizedFS, &FatInfo, TRUE);
|
||||
if (!NT_SUCCESS(Status) || RecognizedFS == FALSE)
|
||||
{
|
||||
Status = STATUS_WRONG_VOLUME;
|
||||
}
|
||||
else if (sizeof(FATINFO) == RtlCompareMemory(&FatInfo, &DeviceExt->FatInfo, sizeof(FATINFO)))
|
||||
{
|
||||
DPRINT1("Same volume\n");
|
||||
/*
|
||||
* FIXME:
|
||||
* Preformatted floppy disks have very often a serial number of 0000:0000.
|
||||
* We should calculate a crc sum over the sectors from the root directory as secondary volume number.
|
||||
* Each write to the root directory must update this crc sum.
|
||||
*/
|
||||
/* HACK */
|
||||
if (!FatInfo.FixedMedia)
|
||||
{
|
||||
Status = STATUS_WRONG_VOLUME;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -685,6 +692,8 @@ VfatVerify(
|
|||
}
|
||||
}
|
||||
|
||||
IrpContext->Stack->Parameters.VerifyVolume.Vpb->RealDevice->Flags &= ~DO_VERIFY_VOLUME;
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue