Skip to content

Commit 2cebf91

Browse files
slackingfredpbatard
authored andcommitted
[fat] align start of data region to MB
* Closes #2387
1 parent 70e8748 commit 2cebf91

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/format_fat32.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ BOOL FormatLargeFAT32(DWORD DriveIndex, uint64_t PartitionOffset, DWORD ClusterS
175175
DWORD BytesPerSect = 0;
176176
DWORD SectorsPerCluster = 0;
177177
DWORD TotalSectors = 0;
178+
DWORD AlignSectors = 0;
178179
DWORD SystemAreaSize = 0;
179180
DWORD UserAreaSize = 0;
180181
ULONGLONG qTotalSectors = 0;
@@ -295,7 +296,6 @@ BOOL FormatLargeFAT32(DWORD DriveIndex, uint64_t PartitionOffset, DWORD ClusterS
295296
SectorsPerCluster = ClusterSize / BytesPerSect;
296297

297298
pFAT32BootSect->bSecPerClus = (BYTE)SectorsPerCluster;
298-
pFAT32BootSect->wRsvdSecCnt = (WORD)ReservedSectCount;
299299
pFAT32BootSect->bNumFATs = (BYTE)NumFATs;
300300
pFAT32BootSect->wRootEntCnt = 0;
301301
pFAT32BootSect->wTotSec16 = 0;
@@ -310,6 +310,13 @@ BOOL FormatLargeFAT32(DWORD DriveIndex, uint64_t PartitionOffset, DWORD ClusterS
310310
FatSize = GetFATSizeSectors(pFAT32BootSect->dTotSec32, pFAT32BootSect->wRsvdSecCnt,
311311
pFAT32BootSect->bSecPerClus, pFAT32BootSect->bNumFATs, BytesPerSect);
312312

313+
// Update reserved sector count so that the start of data region is aligned to a MB boundary
314+
SystemAreaSize = ReservedSectCount + NumFATs * FatSize;
315+
AlignSectors = (1 * MB) / BytesPerSect;
316+
SystemAreaSize = (SystemAreaSize + AlignSectors - 1) / AlignSectors * AlignSectors;
317+
ReservedSectCount = SystemAreaSize - NumFATs * FatSize;
318+
319+
pFAT32BootSect->wRsvdSecCnt = (WORD)ReservedSectCount;
313320
pFAT32BootSect->dFATSz32 = FatSize;
314321
pFAT32BootSect->wExtFlags = 0;
315322
pFAT32BootSect->wFSVer = 0;

src/rufus.rc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
3333
IDD_DIALOG DIALOGEX 12, 12, 232, 326
3434
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
3535
EXSTYLE WS_EX_ACCEPTFILES
36-
CAPTION "Rufus 4.4.2098"
36+
CAPTION "Rufus 4.4.2099"
3737
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
3838
BEGIN
3939
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@@ -392,8 +392,8 @@ END
392392
//
393393

394394
VS_VERSION_INFO VERSIONINFO
395-
FILEVERSION 4,4,2098,0
396-
PRODUCTVERSION 4,4,2098,0
395+
FILEVERSION 4,4,2099,0
396+
PRODUCTVERSION 4,4,2099,0
397397
FILEFLAGSMASK 0x3fL
398398
#ifdef _DEBUG
399399
FILEFLAGS 0x1L
@@ -411,13 +411,13 @@ BEGIN
411411
VALUE "Comments", "https://rufus.ie"
412412
VALUE "CompanyName", "Akeo Consulting"
413413
VALUE "FileDescription", "Rufus"
414-
VALUE "FileVersion", "4.4.2098"
414+
VALUE "FileVersion", "4.4.2099"
415415
VALUE "InternalName", "Rufus"
416416
VALUE "LegalCopyright", "� 2011-2024 Pete Batard (GPL v3)"
417417
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
418418
VALUE "OriginalFilename", "rufus-4.4.exe"
419419
VALUE "ProductName", "Rufus"
420-
VALUE "ProductVersion", "4.4.2098"
420+
VALUE "ProductVersion", "4.4.2099"
421421
END
422422
END
423423
BLOCK "VarFileInfo"

0 commit comments

Comments
 (0)