Skip to content

Commit

Permalink
[fat] align start of data region to MB
Browse files Browse the repository at this point in the history
* Closes #2387
  • Loading branch information
slackingfred authored and pbatard committed Jan 10, 2024
1 parent 70e8748 commit 2cebf91
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
9 changes: 8 additions & 1 deletion src/format_fat32.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ BOOL FormatLargeFAT32(DWORD DriveIndex, uint64_t PartitionOffset, DWORD ClusterS
DWORD BytesPerSect = 0;
DWORD SectorsPerCluster = 0;
DWORD TotalSectors = 0;
DWORD AlignSectors = 0;
DWORD SystemAreaSize = 0;
DWORD UserAreaSize = 0;
ULONGLONG qTotalSectors = 0;
Expand Down Expand Up @@ -295,7 +296,6 @@ BOOL FormatLargeFAT32(DWORD DriveIndex, uint64_t PartitionOffset, DWORD ClusterS
SectorsPerCluster = ClusterSize / BytesPerSect;

pFAT32BootSect->bSecPerClus = (BYTE)SectorsPerCluster;
pFAT32BootSect->wRsvdSecCnt = (WORD)ReservedSectCount;
pFAT32BootSect->bNumFATs = (BYTE)NumFATs;
pFAT32BootSect->wRootEntCnt = 0;
pFAT32BootSect->wTotSec16 = 0;
Expand All @@ -310,6 +310,13 @@ BOOL FormatLargeFAT32(DWORD DriveIndex, uint64_t PartitionOffset, DWORD ClusterS
FatSize = GetFATSizeSectors(pFAT32BootSect->dTotSec32, pFAT32BootSect->wRsvdSecCnt,
pFAT32BootSect->bSecPerClus, pFAT32BootSect->bNumFATs, BytesPerSect);

// Update reserved sector count so that the start of data region is aligned to a MB boundary
SystemAreaSize = ReservedSectCount + NumFATs * FatSize;
AlignSectors = (1 * MB) / BytesPerSect;
SystemAreaSize = (SystemAreaSize + AlignSectors - 1) / AlignSectors * AlignSectors;
ReservedSectCount = SystemAreaSize - NumFATs * FatSize;

pFAT32BootSect->wRsvdSecCnt = (WORD)ReservedSectCount;
pFAT32BootSect->dFATSz32 = FatSize;
pFAT32BootSect->wExtFlags = 0;
pFAT32BootSect->wFSVer = 0;
Expand Down
10 changes: 5 additions & 5 deletions src/rufus.rc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 232, 326
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 4.4.2098"
CAPTION "Rufus 4.4.2099"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
Expand Down Expand Up @@ -392,8 +392,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 4,4,2098,0
PRODUCTVERSION 4,4,2098,0
FILEVERSION 4,4,2099,0
PRODUCTVERSION 4,4,2099,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -411,13 +411,13 @@ BEGIN
VALUE "Comments", "https://rufus.ie"
VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "4.4.2098"
VALUE "FileVersion", "4.4.2099"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "� 2011-2024 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
VALUE "OriginalFilename", "rufus-4.4.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "4.4.2098"
VALUE "ProductVersion", "4.4.2099"
END
END
BLOCK "VarFileInfo"
Expand Down

0 comments on commit 2cebf91

Please sign in to comment.