mirror of
https://github.com/reactos/reactos.git
synced 2025-05-01 03:29:37 +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,
|
ULONG CurrentCluster,
|
||||||
PULONG NextCluster)
|
PULONG NextCluster)
|
||||||
{
|
{
|
||||||
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
PVOID BaseAddress;
|
PVOID BaseAddress;
|
||||||
ULONG FATOffset;
|
ULONG FATOffset;
|
||||||
ULONG ChunkSize;
|
ULONG ChunkSize;
|
||||||
|
@ -49,10 +50,16 @@ FAT32GetNextCluster(
|
||||||
if (CurrentCluster >= 0xffffff8 && CurrentCluster <= 0xfffffff)
|
if (CurrentCluster >= 0xffffff8 && CurrentCluster <= 0xfffffff)
|
||||||
CurrentCluster = 0xffffffff;
|
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);
|
CcUnpinData(Context);
|
||||||
*NextCluster = CurrentCluster;
|
*NextCluster = CurrentCluster;
|
||||||
return STATUS_SUCCESS;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -64,6 +71,7 @@ FAT16GetNextCluster(
|
||||||
ULONG CurrentCluster,
|
ULONG CurrentCluster,
|
||||||
PULONG NextCluster)
|
PULONG NextCluster)
|
||||||
{
|
{
|
||||||
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
PVOID BaseAddress;
|
PVOID BaseAddress;
|
||||||
ULONG FATOffset;
|
ULONG FATOffset;
|
||||||
ULONG ChunkSize;
|
ULONG ChunkSize;
|
||||||
|
@ -81,10 +89,18 @@ FAT16GetNextCluster(
|
||||||
CurrentCluster = *((PUSHORT)((char*)BaseAddress + (FATOffset % ChunkSize)));
|
CurrentCluster = *((PUSHORT)((char*)BaseAddress + (FATOffset % ChunkSize)));
|
||||||
if (CurrentCluster >= 0xfff8 && CurrentCluster <= 0xffff)
|
if (CurrentCluster >= 0xfff8 && CurrentCluster <= 0xffff)
|
||||||
CurrentCluster = 0xffffffff;
|
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);
|
CcUnpinData(Context);
|
||||||
*NextCluster = CurrentCluster;
|
*NextCluster = CurrentCluster;
|
||||||
return STATUS_SUCCESS;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -671,8 +687,10 @@ GetNextCluster(
|
||||||
|
|
||||||
if (CurrentCluster == 0)
|
if (CurrentCluster == 0)
|
||||||
{
|
{
|
||||||
ASSERT(CurrentCluster != 0);
|
DPRINT1("WARNING: File system corruption detected. You may need to run a disk repair utility.\n");
|
||||||
return STATUS_INVALID_PARAMETER;
|
if (VfatGlobalData->Flags & VFAT_BREAK_ON_CORRUPTION)
|
||||||
|
ASSERT(CurrentCluster != 0);
|
||||||
|
return STATUS_FILE_CORRUPT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExAcquireResourceSharedLite(&DeviceExt->FatResource, TRUE);
|
ExAcquireResourceSharedLite(&DeviceExt->FatResource, TRUE);
|
||||||
|
|
|
@ -91,6 +91,9 @@ DriverEntry(
|
||||||
RtlZeroMemory (VfatGlobalData, sizeof(VFAT_GLOBAL_DATA));
|
RtlZeroMemory (VfatGlobalData, sizeof(VFAT_GLOBAL_DATA));
|
||||||
VfatGlobalData->DriverObject = DriverObject;
|
VfatGlobalData->DriverObject = DriverObject;
|
||||||
VfatGlobalData->DeviceObject = DeviceObject;
|
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;
|
DeviceObject->Flags |= DO_DIRECT_IO;
|
||||||
DriverObject->MajorFunction[IRP_MJ_CLOSE] = VfatBuildRequest;
|
DriverObject->MajorFunction[IRP_MJ_CLOSE] = VfatBuildRequest;
|
||||||
|
|
|
@ -315,6 +315,8 @@ typedef struct DEVICE_EXTENSION
|
||||||
PVPB SpareVPB;
|
PVPB SpareVPB;
|
||||||
} DEVICE_EXTENSION, VCB, *PVCB;
|
} DEVICE_EXTENSION, VCB, *PVCB;
|
||||||
|
|
||||||
|
#define VFAT_BREAK_ON_CORRUPTION 1
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
PDRIVER_OBJECT DriverObject;
|
PDRIVER_OBJECT DriverObject;
|
||||||
|
|
Loading…
Reference in a new issue