Author: tfaber
Date: Sun Nov 1 08:55:47 2015
New Revision: 69768
URL:
http://svn.reactos.org/svn/reactos?rev=69768&view=rev
Log:
[FASTFAT]
- Return the appropriate status code when encountering file system corruption
- When encountering corruption, print a message by default instead of breaking into the
debugger
Modified:
trunk/reactos/drivers/filesystems/fastfat/fat.c
trunk/reactos/drivers/filesystems/fastfat/iface.c
trunk/reactos/drivers/filesystems/fastfat/vfat.h
Modified: trunk/reactos/drivers/filesystems/fastfat/fat.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/fat.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/fat.c [iso-8859-1] Sun Nov 1 08:55:47 2015
@@ -31,6 +31,7 @@
ULONG CurrentCluster,
PULONG NextCluster)
{
+ NTSTATUS Status = STATUS_SUCCESS;
PVOID BaseAddress;
ULONG FATOffset;
ULONG ChunkSize;
@@ -49,10 +50,16 @@
if (CurrentCluster >= 0xffffff8 && CurrentCluster <= 0xfffffff)
CurrentCluster = 0xffffffff;
- ASSERT(CurrentCluster != 0);
+ if (CurrentCluster == 0)
+ {
+ DPRINT1("WARNING: File system corruption detected. You may need to run a
disk repair utility.\n");
+ Status = STATUS_FILE_CORRUPT_ERROR;
+ if (VfatGlobalData->Flags & VFAT_BREAK_ON_CORRUPTION)
+ ASSERT(CurrentCluster != 0);
+ }
CcUnpinData(Context);
*NextCluster = CurrentCluster;
- return STATUS_SUCCESS;
+ return Status;
}
/*
@@ -64,6 +71,7 @@
ULONG CurrentCluster,
PULONG NextCluster)
{
+ NTSTATUS Status = STATUS_SUCCESS;
PVOID BaseAddress;
ULONG FATOffset;
ULONG ChunkSize;
@@ -81,10 +89,18 @@
CurrentCluster = *((PUSHORT)((char*)BaseAddress + (FATOffset % ChunkSize)));
if (CurrentCluster >= 0xfff8 && CurrentCluster <= 0xffff)
CurrentCluster = 0xffffffff;
- ASSERT(CurrentCluster != 0);
+
+ if (CurrentCluster == 0)
+ {
+ DPRINT1("WARNING: File system corruption detected. You may need to run a
disk repair utility.\n");
+ Status = STATUS_FILE_CORRUPT_ERROR;
+ if (VfatGlobalData->Flags & VFAT_BREAK_ON_CORRUPTION)
+ ASSERT(CurrentCluster != 0);
+ }
+
CcUnpinData(Context);
*NextCluster = CurrentCluster;
- return STATUS_SUCCESS;
+ return Status;
}
/*
@@ -671,8 +687,10 @@
if (CurrentCluster == 0)
{
- ASSERT(CurrentCluster != 0);
- return STATUS_INVALID_PARAMETER;
+ DPRINT1("WARNING: File system corruption detected. You may need to run a
disk repair utility.\n");
+ if (VfatGlobalData->Flags & VFAT_BREAK_ON_CORRUPTION)
+ ASSERT(CurrentCluster != 0);
+ return STATUS_FILE_CORRUPT_ERROR;
}
ExAcquireResourceSharedLite(&DeviceExt->FatResource, TRUE);
Modified: trunk/reactos/drivers/filesystems/fastfat/iface.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/iface.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/iface.c [iso-8859-1] Sun Nov 1 08:55:47
2015
@@ -91,6 +91,9 @@
RtlZeroMemory (VfatGlobalData, sizeof(VFAT_GLOBAL_DATA));
VfatGlobalData->DriverObject = DriverObject;
VfatGlobalData->DeviceObject = DeviceObject;
+ /* Enable this to enter the debugger when file system corruption
+ * has been detected:
+ VfatGlobalData->Flags = VFAT_BREAK_ON_CORRUPTION; */
DeviceObject->Flags |= DO_DIRECT_IO;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = VfatBuildRequest;
Modified: trunk/reactos/drivers/filesystems/fastfat/vfat.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat/vfat.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat/vfat.h [iso-8859-1] Sun Nov 1 08:55:47
2015
@@ -315,6 +315,8 @@
PVPB SpareVPB;
} DEVICE_EXTENSION, VCB, *PVCB;
+#define VFAT_BREAK_ON_CORRUPTION 1
+
typedef struct
{
PDRIVER_OBJECT DriverObject;