mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00: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;
|
||||
}
|
||||
|
|
10
src/rufus.rc
10
src/rufus.rc
|
@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
|||
IDD_DIALOG DIALOGEX 12, 12, 242, 376
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
EXSTYLE WS_EX_ACCEPTFILES
|
||||
CAPTION "Rufus 2.8.868"
|
||||
CAPTION "Rufus 2.8.869"
|
||||
FONT 8, "Segoe UI Symbol", 400, 0, 0x0
|
||||
BEGIN
|
||||
LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8
|
||||
|
@ -320,8 +320,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 2,8,868,0
|
||||
PRODUCTVERSION 2,8,868,0
|
||||
FILEVERSION 2,8,869,0
|
||||
PRODUCTVERSION 2,8,869,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -338,13 +338,13 @@ BEGIN
|
|||
BEGIN
|
||||
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
|
||||
VALUE "FileDescription", "Rufus"
|
||||
VALUE "FileVersion", "2.8.868"
|
||||
VALUE "FileVersion", "2.8.869"
|
||||
VALUE "InternalName", "Rufus"
|
||||
VALUE "LegalCopyright", "© 2011-2016 Pete Batard (GPL v3)"
|
||||
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
|
||||
VALUE "OriginalFilename", "rufus.exe"
|
||||
VALUE "ProductName", "Rufus"
|
||||
VALUE "ProductVersion", "2.8.868"
|
||||
VALUE "ProductVersion", "2.8.869"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
|
@ -92,7 +92,7 @@ libfat_open(int (*readfunc) (intptr_t, void *, size_t, libfat_sector_t),
|
|||
} else
|
||||
goto barf; /* Impossibly many clusters */
|
||||
|
||||
minfatsize >>= LIBFAT_SECTOR_SHIFT;
|
||||
minfatsize = (minfatsize + LIBFAT_SECTOR_SIZE - 1) >> LIBFAT_SECTOR_SHIFT;
|
||||
|
||||
if (minfatsize > fatsize)
|
||||
goto barf; /* The FATs don't fit */
|
||||
|
|
Loading…
Reference in a new issue