diff --git a/reactos/boot/freeldr/freeldr/fs/fat.c b/reactos/boot/freeldr/freeldr/fs/fat.c index 4a605007ae5..f76b73ac8fa 100644 --- a/reactos/boot/freeldr/freeldr/fs/fat.c +++ b/reactos/boot/freeldr/freeldr/fs/fat.c @@ -22,7 +22,7 @@ #define NDEBUG #include -#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 = {