- Make caching enable/disable a runtime switch instead of a compile time one.

svn path=/trunk/; revision=32107
This commit is contained in:
Aleksey Bragin 2008-02-03 18:51:48 +00:00
parent 005a190594
commit c7a1042e5c

View file

@ -22,7 +22,7 @@
#define NDEBUG
#include <debug.h>
#define CACHE_ENABLED
BOOLEAN gCacheEnabled = TRUE;
ULONG BytesPerSector; /* Number of bytes per sector */
ULONG SectorsPerCluster; /* Number of sectors per cluster */
@ -336,7 +336,8 @@ BOOLEAN FatOpenVolume(UCHAR DriveNumber, ULONGLONG VolumeStartSector, ULONGLONG
}
MmHeapFree(FatVolumeBootSector);
#ifdef CACHE_ENABLED
if (gCacheEnabled)
{
//
// Initialize the disk cache for this drive
//
@ -357,7 +358,8 @@ BOOLEAN FatOpenVolume(UCHAR DriveNumber, ULONGLONG VolumeStartSector, ULONGLONG
return FALSE;
}
}
#else
}
else
{
GEOMETRY DriveGeometry;
ULONG BlockSize;
@ -370,7 +372,6 @@ BOOLEAN FatOpenVolume(UCHAR DriveNumber, ULONGLONG VolumeStartSector, ULONGLONG
BlockSize = MachDiskGetCacheableBlockCount(DriveNumber);
}
#endif
return TRUE;
}
@ -1422,9 +1423,12 @@ ULONG FatGetFilePointer(FILE *FileHandle)
BOOLEAN FatReadVolumeSectors(ULONG DriveNumber, ULONG SectorNumber, ULONG SectorCount, PVOID Buffer)
{
#ifdef CACHE_ENABLED
if (gCacheEnabled)
{
return CacheReadDiskSectors(DriveNumber, SectorNumber + FatVolumeStartSector, SectorCount, Buffer);
#else
}
else
{
// Now try to read in the block
if (!MachDiskReadLogicalSectors(DriveNumber, SectorNumber + FatVolumeStartSector, SectorCount, (PVOID)DISKREADBUFFER))
{
@ -1436,7 +1440,7 @@ BOOLEAN FatReadVolumeSectors(ULONG DriveNumber, ULONG SectorNumber, ULONG Sector
// Return success
return TRUE;
#endif
}
}
const FS_VTBL FatVtbl = {