mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 17:34:57 +00:00
- Make caching enable/disable a runtime switch instead of a compile time one.
svn path=/trunk/; revision=32107
This commit is contained in:
parent
005a190594
commit
c7a1042e5c
1 changed files with 34 additions and 30 deletions
|
@ -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,28 +336,30 @@ BOOLEAN FatOpenVolume(UCHAR DriveNumber, ULONGLONG VolumeStartSector, ULONGLONG
|
|||
}
|
||||
MmHeapFree(FatVolumeBootSector);
|
||||
|
||||
#ifdef CACHE_ENABLED
|
||||
//
|
||||
// Initialize the disk cache for this drive
|
||||
//
|
||||
if (!CacheInitializeDrive(DriveNumber))
|
||||
if (gCacheEnabled)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// Force the FAT sectors into the cache
|
||||
// as long as it is FAT12 or FAT16. FAT32 can
|
||||
// have a multi-megabyte FAT so we don't want that.
|
||||
//
|
||||
if (FatType != FAT32 && FatType != FATX32)
|
||||
{
|
||||
if (!CacheForceDiskSectorsIntoCache(DriveNumber, ActiveFatSectorStart, SectorsPerFat))
|
||||
//
|
||||
// Initialize the disk cache for this drive
|
||||
//
|
||||
if (!CacheInitializeDrive(DriveNumber))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// Force the FAT sectors into the cache
|
||||
// as long as it is FAT12 or FAT16. FAT32 can
|
||||
// have a multi-megabyte FAT so we don't want that.
|
||||
//
|
||||
if (FatType != FAT32 && FatType != FATX32)
|
||||
{
|
||||
if (!CacheForceDiskSectorsIntoCache(DriveNumber, ActiveFatSectorStart, SectorsPerFat))
|
||||
{
|
||||
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,21 +1423,24 @@ ULONG FatGetFilePointer(FILE *FileHandle)
|
|||
|
||||
BOOLEAN FatReadVolumeSectors(ULONG DriveNumber, ULONG SectorNumber, ULONG SectorCount, PVOID Buffer)
|
||||
{
|
||||
#ifdef CACHE_ENABLED
|
||||
return CacheReadDiskSectors(DriveNumber, SectorNumber + FatVolumeStartSector, SectorCount, Buffer);
|
||||
#else
|
||||
// Now try to read in the block
|
||||
if (!MachDiskReadLogicalSectors(DriveNumber, SectorNumber + FatVolumeStartSector, SectorCount, (PVOID)DISKREADBUFFER))
|
||||
if (gCacheEnabled)
|
||||
{
|
||||
return FALSE;
|
||||
return CacheReadDiskSectors(DriveNumber, SectorNumber + FatVolumeStartSector, SectorCount, Buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Now try to read in the block
|
||||
if (!MachDiskReadLogicalSectors(DriveNumber, SectorNumber + FatVolumeStartSector, SectorCount, (PVOID)DISKREADBUFFER))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Copy data to the caller
|
||||
RtlCopyMemory(Buffer, (PVOID)DISKREADBUFFER, SectorCount * BytesPerSector);
|
||||
// Copy data to the caller
|
||||
RtlCopyMemory(Buffer, (PVOID)DISKREADBUFFER, SectorCount * BytesPerSector);
|
||||
|
||||
// Return success
|
||||
return TRUE;
|
||||
#endif
|
||||
// Return success
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
const FS_VTBL FatVtbl = {
|
||||
|
|
Loading…
Reference in a new issue