From 2a728dec8855c2a1b89267e959d6046a47981230 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sat, 1 Jul 2023 23:36:05 +0200 Subject: 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 --- src/Format/Tcformat.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'src/Format') diff --git a/src/Format/Tcformat.c b/src/Format/Tcformat.c index a2eb828d..e98a25da 100644 --- a/src/Format/Tcformat.c +++ b/src/Format/Tcformat.c @@ -3705,24 +3705,44 @@ static void UpdateClusterSizeList (HWND hwndDlg, int fsType) SendMessage (GetDlgItem (hwndDlg, IDC_CLUSTERSIZE), CB_RESETCONTENT, 0, 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; 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; /* ReFS supports only 4KiB and 64KiB clusters */ if ((fsType == FILESYS_REFS) && (size != 4*BYTES_PER_KB) && (size != 64*BYTES_PER_KB)) continue; + /* NTFS supports at maximum 2M cluster */ + if ((fsType == FILESYS_NTFS) && (size > 2*BYTES_PER_MB)) + break; + + /* exFAT supports at maximum 32M cluster */ + if ((fsType == FILESYS_EXFAT) && (size > 32*BYTES_PER_MB)) + break; + if (size == 512) - s << L"0.5"; - else + 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); } -- cgit v1.2.3