Reads of the FAT on FAT32 filesystems go through the cache, writes are

disabled

svn path=/trunk/; revision=1604
This commit is contained in:
David Welch 2001-02-06 00:41:19 +00:00
parent 076c1c6ac3
commit b2fe7525bf

View file

@ -1,5 +1,5 @@
/* /*
* $Id: fat.c,v 1.16 2001/01/16 23:22:03 dwelch Exp $ * $Id: fat.c,v 1.17 2001/02/06 00:41:19 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -31,25 +31,41 @@ Fat32GetNextCluster (PDEVICE_EXTENSION DeviceExt,
* disk read * disk read
*/ */
{ {
ULONG FATsector; PVOID BaseAddress;
ULONG FATeis; BOOLEAN Valid;
PULONG Block; PCACHE_SEGMENT CacheSeg;
NTSTATUS Status; NTSTATUS Status;
ULONG FATOffset;
Block = ExAllocatePool (NonPagedPool, 1024); FATOffset = (DeviceExt->FATStart * BLOCKSIZE) +
FATsector = CurrentCluster / (512 / sizeof (ULONG)); (CurrentCluster * sizeof(ULONG));
FATeis = CurrentCluster - (FATsector * (512 / sizeof (ULONG)));
Status = VfatReadSectors (DeviceExt->StorageDevice, Status = CcRequestCacheSegment(DeviceExt->StorageBcb,
(ULONG) (DeviceExt->FATStart + FATsector), 1, PAGE_ROUND_DOWN(FATOffset),
(UCHAR *) Block); &BaseAddress,
&Valid,
&CacheSeg);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
return(Status); return(Status);
} }
CurrentCluster = Block[FATeis]; if (!Valid)
{
Status = VfatReadSectors(DeviceExt->StorageDevice,
PAGE_ROUND_DOWN(FATOffset) / BLOCKSIZE,
PAGESIZE / BLOCKSIZE,
BaseAddress);
if (!NT_SUCCESS(Status))
{
CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, FALSE);
return(Status);
}
}
CurrentCluster = *((PUSHORT)BaseAddress + (FATOffset % PAGESIZE));
if (CurrentCluster >= 0xffffff8 && CurrentCluster <= 0xfffffff) if (CurrentCluster >= 0xffffff8 && CurrentCluster <= 0xfffffff)
CurrentCluster = 0xffffffff; CurrentCluster = 0xffffffff;
ExFreePool (Block); CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, TRUE);
*NextCluster = CurrentCluster; *NextCluster = CurrentCluster;
return (STATUS_SUCCESS); return (STATUS_SUCCESS);
} }
@ -571,6 +587,7 @@ FAT32WriteCluster (PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
* FUNCTION: Writes a cluster to the FAT32 physical tables * FUNCTION: Writes a cluster to the FAT32 physical tables
*/ */
{ {
#if 0
ULONG FATsector; ULONG FATsector;
ULONG FATeis; ULONG FATeis;
PUSHORT Block; PUSHORT Block;
@ -596,6 +613,8 @@ FAT32WriteCluster (PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
Start += pBoot->FATSectors; Start += pBoot->FATSectors;
} }
ExFreePool (Block); ExFreePool (Block);
#endif
KeBugCheck(0);
} }
NTSTATUS NTSTATUS