VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2023-07-01 23:36:05 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2023-07-01 23:36:05 +0200
commit2a728dec8855c2a1b89267e959d6046a47981230 (patch)
treee36649d35431f60112df944db0f655719fc24206 /src
parent580423b5dde31a1f5582ac4aa84c9deca6c2c261 (diff)
downloadVeraCrypt-2a728dec8855c2a1b89267e959d6046a47981230.tar.gz
VeraCrypt-2a728dec8855c2a1b89267e959d6046a47981230.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/Format/Tcformat.c32
1 files changed, 26 insertions, 6 deletions
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);
}