Author: pschweitzer
Date: Sun May 22 07:56:45 2016
New Revision: 71370
URL:
http://svn.reactos.org/svn/reactos?rev=71370&view=rev
Log:
[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!
Modified:
trunk/reactos/sdk/lib/fslib/vfatlib/fat32.c
Modified: trunk/reactos/sdk/lib/fslib/vfatlib/fat32.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/fslib/vfatlib/fat3…
==============================================================================
--- trunk/reactos/sdk/lib/fslib/vfatlib/fat32.c [iso-8859-1] (original)
+++ trunk/reactos/sdk/lib/fslib/vfatlib/fat32.c [iso-8859-1] Sun May 22 07:56:45 2016
@@ -397,6 +397,9 @@
ULONG TmpVal1;
ULONG TmpVal2;
NTSTATUS Status;
+ ULONG UsableFatEntries;
+ ULONG FirstDataSector;
+ ULONG DataClusters;
/* Calculate cluster size */
if (ClusterSize == 0)
@@ -469,6 +472,20 @@
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;