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
|
* Proper computation of FAT size
|
||||||
*
|
* See: http://www.syslinux.org/archives/2016-February/024850.html
|
||||||
* DWORD RootDirSectors = 0;
|
* and subsequent replies.
|
||||||
* DWORD TmpVal1, TmpVal2, FATSz;
|
|
||||||
*
|
|
||||||
* TmpVal1 = DskSize - (ReservedSecCnt + RootDirSectors);
|
|
||||||
* TmpVal2 = (256 * SecPerClus) + NumFATs;
|
|
||||||
* TmpVal2 = TmpVal2 / 2;
|
|
||||||
* FATSz = (TmpVal1 + (TmpVal2 - 1)) / TmpVal2;
|
|
||||||
*
|
|
||||||
* return( FatSz );
|
|
||||||
*/
|
*/
|
||||||
static DWORD GetFATSizeSectors(DWORD DskSize, DWORD ReservedSecCnt, DWORD SecPerClus, DWORD NumFATs, DWORD BytesPerSect)
|
static DWORD GetFATSizeSectors(DWORD DskSize, DWORD ReservedSecCnt, DWORD SecPerClus, DWORD NumFATs, DWORD BytesPerSect)
|
||||||
{
|
{
|
||||||
ULONGLONG Numerator, Denominator;
|
ULONGLONG Numerator, Denominator;
|
||||||
ULONGLONG FatElementSize = 4;
|
ULONGLONG FatElementSize = 4;
|
||||||
|
ULONGLONG ReservedClusCnt = 2;
|
||||||
ULONGLONG FatSz;
|
ULONGLONG FatSz;
|
||||||
|
|
||||||
// This is based on
|
Numerator = DskSize - ReservedSecCnt + ReservedClusCnt * SecPerClus;
|
||||||
// http://hjem.get2net.dk/rune_moeller_barnkob/filesystems/fat.html
|
Denominator = SecPerClus * BytesPerSect / FatElementSize + NumFATs;
|
||||||
Numerator = FatElementSize * (DskSize - ReservedSecCnt);
|
FatSz = Numerator / Denominator + 1; // +1 to ensure we are rounded up
|
||||||
Denominator = (SecPerClus * BytesPerSect) + (FatElementSize * NumFATs);
|
|
||||||
FatSz = Numerator / Denominator;
|
|
||||||
// round up
|
|
||||||
FatSz += 1;
|
|
||||||
|
|
||||||
return (DWORD)FatSz;
|
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
|
IDD_DIALOG DIALOGEX 12, 12, 242, 376
|
||||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
EXSTYLE WS_EX_ACCEPTFILES
|
EXSTYLE WS_EX_ACCEPTFILES
|
||||||
CAPTION "Rufus 2.8.868"
|
CAPTION "Rufus 2.8.869"
|
||||||
FONT 8, "Segoe UI Symbol", 400, 0, 0x0
|
FONT 8, "Segoe UI Symbol", 400, 0, 0x0
|
||||||
BEGIN
|
BEGIN
|
||||||
LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8
|
LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8
|
||||||
|
@ -320,8 +320,8 @@ END
|
||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 2,8,868,0
|
FILEVERSION 2,8,869,0
|
||||||
PRODUCTVERSION 2,8,868,0
|
PRODUCTVERSION 2,8,869,0
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
|
@ -338,13 +338,13 @@ BEGIN
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
|
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
|
||||||
VALUE "FileDescription", "Rufus"
|
VALUE "FileDescription", "Rufus"
|
||||||
VALUE "FileVersion", "2.8.868"
|
VALUE "FileVersion", "2.8.869"
|
||||||
VALUE "InternalName", "Rufus"
|
VALUE "InternalName", "Rufus"
|
||||||
VALUE "LegalCopyright", "© 2011-2016 Pete Batard (GPL v3)"
|
VALUE "LegalCopyright", "© 2011-2016 Pete Batard (GPL v3)"
|
||||||
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
|
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
|
||||||
VALUE "OriginalFilename", "rufus.exe"
|
VALUE "OriginalFilename", "rufus.exe"
|
||||||
VALUE "ProductName", "Rufus"
|
VALUE "ProductName", "Rufus"
|
||||||
VALUE "ProductVersion", "2.8.868"
|
VALUE "ProductVersion", "2.8.869"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
|
@ -92,7 +92,7 @@ libfat_open(int (*readfunc) (intptr_t, void *, size_t, libfat_sector_t),
|
||||||
} else
|
} else
|
||||||
goto barf; /* Impossibly many clusters */
|
goto barf; /* Impossibly many clusters */
|
||||||
|
|
||||||
minfatsize >>= LIBFAT_SECTOR_SHIFT;
|
minfatsize = (minfatsize + LIBFAT_SECTOR_SIZE - 1) >> LIBFAT_SECTOR_SHIFT;
|
||||||
|
|
||||||
if (minfatsize > fatsize)
|
if (minfatsize > fatsize)
|
||||||
goto barf; /* The FATs don't fit */
|
goto barf; /* The FATs don't fit */
|
||||||
|
|
Loading…
Reference in a new issue