mirror of
https://github.com/pbatard/rufus.git
synced 2025-05-19 01:15:12 -04:00
[core] fix computation of FAT size for Large FAT32
* Ridgecropt's GetFATSizeSectors() computation was incorrect and resulted in data sectors being "wasted" (unaddressable) * See: http://www.syslinux.org/archives/2016-February/024850.html * Also revert the minfatsize check of Syslinux, since it no longer fails.
This commit is contained in:
parent
ade5639c00
commit
b9caf8b605
3 changed files with 13 additions and 24 deletions
25
src/format.c
25
src/format.c
|
@ -347,31 +347,20 @@ static DWORD GetVolumeID(void)
|
|||
}
|
||||
|
||||
/*
|
||||
* This is the Microsoft calculation from FATGEN
|
||||
*
|
||||
* DWORD RootDirSectors = 0;
|
||||
* DWORD TmpVal1, TmpVal2, FATSz;
|
||||
*
|
||||
* TmpVal1 = DskSize - (ReservedSecCnt + RootDirSectors);
|
||||
* TmpVal2 = (256 * SecPerClus) + NumFATs;
|
||||
* TmpVal2 = TmpVal2 / 2;
|
||||
* FATSz = (TmpVal1 + (TmpVal2 - 1)) / TmpVal2;
|
||||
*
|
||||
* return( FatSz );
|
||||
* Proper computation of FAT size
|
||||
* See: http://www.syslinux.org/archives/2016-February/024850.html
|
||||
* and subsequent replies.
|
||||
*/
|
||||
static DWORD GetFATSizeSectors(DWORD DskSize, DWORD ReservedSecCnt, DWORD SecPerClus, DWORD NumFATs, DWORD BytesPerSect)
|
||||
{
|
||||
ULONGLONG Numerator, Denominator;
|
||||
ULONGLONG FatElementSize = 4;
|
||||
ULONGLONG ReservedClusCnt = 2;
|
||||
ULONGLONG FatSz;
|
||||
|
||||
// This is based on
|
||||
// http://hjem.get2net.dk/rune_moeller_barnkob/filesystems/fat.html
|
||||
Numerator = FatElementSize * (DskSize - ReservedSecCnt);
|
||||
Denominator = (SecPerClus * BytesPerSect) + (FatElementSize * NumFATs);
|
||||
FatSz = Numerator / Denominator;
|
||||
// round up
|
||||
FatSz += 1;
|
||||
Numerator = DskSize - ReservedSecCnt + ReservedClusCnt * SecPerClus;
|
||||
Denominator = SecPerClus * BytesPerSect / FatElementSize + NumFATs;
|
||||
FatSz = Numerator / Denominator + 1; // +1 to ensure we are rounded up
|
||||
|
||||
return (DWORD)FatSz;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue