1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-11 11:08:02 -06:00

Windows: Use full list of supported cluster sizes for NTFS, ReFS and exFAT filesystems

We keep FAT32 list of supported cluster sizes as it is today for compatibility with existing FAT code
This commit is contained in:
Mounir IDRASSI
2023-07-01 23:36:05 +02:00
parent 580423b5dd
commit 2a728dec88

View File

@@ -3705,24 +3705,44 @@ static void UpdateClusterSizeList (HWND hwndDlg, int fsType)
SendMessage (GetDlgItem (hwndDlg, IDC_CLUSTERSIZE), CB_RESETCONTENT, 0, 0); SendMessage (GetDlgItem (hwndDlg, IDC_CLUSTERSIZE), CB_RESETCONTENT, 0, 0);
AddComboPair (GetDlgItem (hwndDlg, IDC_CLUSTERSIZE), GetString ("DEFAULT"), 0); AddComboPair (GetDlgItem (hwndDlg, IDC_CLUSTERSIZE), GetString ("DEFAULT"), 0);
for (int i = 1; i <= 128; i *= 2) for (int i = 1; i <= 65536; i *= 2)
{ {
wstringstream s; wstringstream s;
DWORD size = GetFormatSectorSize() * i; DWORD size = GetFormatSectorSize() * i;
if (size > TC_MAX_FAT_CLUSTER_SIZE) /* cluster size makes sense only when there is a filesystem */
if (fsType == FILESYS_NONE)
break;
/* FAT supports at maximum 64K when sector size is 512, and at maximum 256K when sector size is larger than 512 */
/* For now we set maximum cluster size to 64K in all cases for compatibility with exiting FAT code in VeraCrypt */
if ((fsType == FILESYS_FAT) && (size > 64*BYTES_PER_KB))
break; break;
/* ReFS supports only 4KiB and 64KiB clusters */ /* ReFS supports only 4KiB and 64KiB clusters */
if ((fsType == FILESYS_REFS) && (size != 4*BYTES_PER_KB) && (size != 64*BYTES_PER_KB)) if ((fsType == FILESYS_REFS) && (size != 4*BYTES_PER_KB) && (size != 64*BYTES_PER_KB))
continue; continue;
if (size == 512) /* NTFS supports at maximum 2M cluster */
s << L"0.5"; if ((fsType == FILESYS_NTFS) && (size > 2*BYTES_PER_MB))
else break;
s << size / BYTES_PER_KB;
/* exFAT supports at maximum 32M cluster */
if ((fsType == FILESYS_EXFAT) && (size > 32*BYTES_PER_MB))
break;
if (size == 512)
s << L"0.5 " << GetString ("KB");
else if (size < BYTES_PER_MB)
{
s << size / BYTES_PER_KB;
s << L" " << GetString ("KB"); s << L" " << GetString ("KB");
}
else
{
s << size / BYTES_PER_MB;
s << L" " << GetString ("MB");
}
AddComboPair (GetDlgItem (hwndDlg, IDC_CLUSTERSIZE), s.str().c_str(), i); AddComboPair (GetDlgItem (hwndDlg, IDC_CLUSTERSIZE), s.str().c_str(), i);
} }