mirror of
https://github.com/reactos/reactos.git
synced 2025-06-10 20:34:59 +00:00
[VFATLIB]
Update the amount of FAT entries taking into account that the first two are reserved and thus not usable. Patch by Wim Hueskes CORE-11283 #resolve #comment Committed in r71370, thanks for your patch! svn path=/trunk/; revision=71370
This commit is contained in:
parent
3fa137bf9c
commit
02fde17b6f
1 changed files with 17 additions and 0 deletions
|
@ -397,6 +397,9 @@ Fat32Format(IN HANDLE FileHandle,
|
|||
ULONG TmpVal1;
|
||||
ULONG TmpVal2;
|
||||
NTSTATUS Status;
|
||||
ULONG UsableFatEntries;
|
||||
ULONG FirstDataSector;
|
||||
ULONG DataClusters;
|
||||
|
||||
/* Calculate cluster size */
|
||||
if (ClusterSize == 0)
|
||||
|
@ -469,6 +472,20 @@ Fat32Format(IN HANDLE FileHandle,
|
|||
BootSector.FATSectors32 = (TmpVal1 + (TmpVal2 - 1)) / TmpVal2;
|
||||
DPRINT("FATSectors32 = %lu\n", BootSector.FATSectors32);
|
||||
|
||||
/* edge case: first 2 fat entries are not usable, so the calculation might need a correction */
|
||||
UsableFatEntries = BootSector.FATSectors32 * (BootSector.BytesPerSector / 4) - 2;
|
||||
FirstDataSector = BootSector.ReservedSectors + BootSector.FATCount * BootSector.FATSectors32;
|
||||
DataClusters = (BootSector.SectorsHuge - FirstDataSector) / BootSector.SectorsPerCluster;
|
||||
if (DataClusters > UsableFatEntries)
|
||||
{
|
||||
/* Need more fat entries */
|
||||
BootSector.FATSectors32 += (DataClusters - UsableFatEntries);
|
||||
|
||||
DPRINT("UsableFatEntries = %lu\n", UsableFatEntries);
|
||||
DPRINT("DataClusters = %lu\n", DataClusters);
|
||||
DPRINT("BootSector.FATSectors32 incremented to %lu\n", BootSector.FATSectors32);
|
||||
}
|
||||
|
||||
/* Init context data */
|
||||
Context->TotalSectorCount =
|
||||
2 + (BootSector.FATSectors32 * BootSector.FATCount) + BootSector.SectorsPerCluster;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue