mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[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 svn path=/trunk/; revision=69768
This commit is contained in:
parent
feadd48d1c
commit
668e97e38d
3 changed files with 29 additions and 6 deletions
|
@ -31,6 +31,7 @@ FAT32GetNextCluster(
|
|||
ULONG CurrentCluster,
|
||||
PULONG NextCluster)
|
||||
{
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
PVOID BaseAddress;
|
||||
ULONG FATOffset;
|
||||
ULONG ChunkSize;
|
||||
|
@ -49,10 +50,16 @@ FAT32GetNextCluster(
|
|||
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 @@ FAT16GetNextCluster(
|
|||
ULONG CurrentCluster,
|
||||
PULONG NextCluster)
|
||||
{
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
PVOID BaseAddress;
|
||||
ULONG FATOffset;
|
||||
ULONG ChunkSize;
|
||||
|
@ -81,10 +89,18 @@ FAT16GetNextCluster(
|
|||
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 @@ GetNextCluster(
|
|||
|
||||
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);
|
||||
|
|
|
@ -91,6 +91,9 @@ DriverEntry(
|
|||
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;
|
||||
|
|
|
@ -315,6 +315,8 @@ typedef struct DEVICE_EXTENSION
|
|||
PVPB SpareVPB;
|
||||
} DEVICE_EXTENSION, VCB, *PVCB;
|
||||
|
||||
#define VFAT_BREAK_ON_CORRUPTION 1
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PDRIVER_OBJECT DriverObject;
|
||||
|
|
Loading…
Reference in a new issue