diff options
author | Jertzukka <Jertzukka@gmail.com> | 2023-05-27 19:08:51 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-27 18:08:51 +0200 |
commit | 4e5529bee0eb5f319f0e2a9530a43eaca911ebfb (patch) | |
tree | 7a8b27562a0681b70c4b7d12e1b1de2b8276483a /src/Main/TextUserInterface.cpp | |
parent | 7ae63335ac1a6179807a73f4794b7f279c05e85c (diff) | |
download | VeraCrypt-4e5529bee0eb5f319f0e2a9530a43eaca911ebfb.tar.gz VeraCrypt-4e5529bee0eb5f319f0e2a9530a43eaca911ebfb.zip |
Prevent failing fs options being shown in --text --create (#1078)
Removes the options exFAT and Btrfs being shown when creating a
volume in text mode when the system does not support them and will
end up erroring out at the end. Hide Btrfs option when the volume
is too small, as we will anyways fail right after.
Hardcoded numbering changed to dynamic as the available options
are not necessarily consecutive.
Diffstat (limited to 'src/Main/TextUserInterface.cpp')
-rw-r--r-- | src/Main/TextUserInterface.cpp | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/src/Main/TextUserInterface.cpp b/src/Main/TextUserInterface.cpp index b147a3d4..ec3ed531 100644 --- a/src/Main/TextUserInterface.cpp +++ b/src/Main/TextUserInterface.cpp @@ -814,6 +814,7 @@ namespace VeraCrypt // Filesystem options->FilesystemClusterSize = 0; + uint64 filesystemSize = layout->GetMaxDataSize (options->Size); if (options->Filesystem == VolumeCreationOptions::FilesystemType::Unknown) { @@ -827,33 +828,40 @@ namespace VeraCrypt vector <VolumeCreationOptions::FilesystemType::Enum> filesystems; - ShowInfo (L" 1) " + LangString["NONE"]); filesystems.push_back (VolumeCreationOptions::FilesystemType::None); - ShowInfo (L" 2) FAT"); filesystems.push_back (VolumeCreationOptions::FilesystemType::FAT); - + ShowInfo (wxString::Format (L" %li) %s", filesystems.size() + 1, LangString["NONE"])); filesystems.push_back (VolumeCreationOptions::FilesystemType::None); + ShowInfo (wxString::Format (L" %li) %s", filesystems.size() + 1, "FAT")); filesystems.push_back (VolumeCreationOptions::FilesystemType::FAT); #if defined (TC_LINUX) - ShowInfo (L" 3) Linux Ext2"); filesystems.push_back (VolumeCreationOptions::FilesystemType::Ext2); - ShowInfo (L" 4) Linux Ext3"); filesystems.push_back (VolumeCreationOptions::FilesystemType::Ext3); - ShowInfo (L" 5) Linux Ext4"); filesystems.push_back (VolumeCreationOptions::FilesystemType::Ext4); - ShowInfo (L" 6) NTFS"); filesystems.push_back (VolumeCreationOptions::FilesystemType::NTFS); - ShowInfo (L" 7) exFAT"); filesystems.push_back (VolumeCreationOptions::FilesystemType::exFAT); - ShowInfo (L" 8) Btrfs"); filesystems.push_back (VolumeCreationOptions::FilesystemType::Btrfs); + ShowInfo (wxString::Format (L" %li) %s", filesystems.size() + 1, "Linux Ext2")); filesystems.push_back (VolumeCreationOptions::FilesystemType::Ext2); + ShowInfo (wxString::Format (L" %li) %s", filesystems.size() + 1, "Linux Ext3")); filesystems.push_back (VolumeCreationOptions::FilesystemType::Ext3); + ShowInfo (wxString::Format (L" %li) %s", filesystems.size() + 1, "Linux Ext4")); filesystems.push_back (VolumeCreationOptions::FilesystemType::Ext4); + ShowInfo (wxString::Format (L" %li) %s", filesystems.size() + 1, "NTFS")); filesystems.push_back (VolumeCreationOptions::FilesystemType::NTFS); + if (VolumeCreationOptions::FilesystemType::IsFsFormatterPresent (VolumeCreationOptions::FilesystemType::exFAT)) + { + ShowInfo (wxString::Format (L" %li) %s", filesystems.size() + 1, "exFAT")); filesystems.push_back (VolumeCreationOptions::FilesystemType::exFAT); + } + if (VolumeCreationOptions::FilesystemType::IsFsFormatterPresent (VolumeCreationOptions::FilesystemType::Btrfs)) + { + // minimum size to be able to format as Btrfs is 16777216 bytes + if (filesystemSize >= VC_MIN_SMALL_BTRFS_VOLUME_SIZE) + { + ShowInfo (wxString::Format (L" %li) %s", filesystems.size() + 1, "Btrfs")); filesystems.push_back (VolumeCreationOptions::FilesystemType::Btrfs); + } + } #elif defined (TC_MACOSX) - ShowInfo (L" 3) Mac OS Extended"); filesystems.push_back (VolumeCreationOptions::FilesystemType::MacOsExt); - ShowInfo (L" 4) exFAT"); filesystems.push_back (VolumeCreationOptions::FilesystemType::exFAT); + ShowInfo (wxString::Format (L" %li) %s", filesystems.size() + 1, "Mac OS Extended")); filesystems.push_back (VolumeCreationOptions::FilesystemType::MacOsExt); + ShowInfo (wxString::Format (L" %li) %s", filesystems.size() + 1, "exFAT")); filesystems.push_back (VolumeCreationOptions::FilesystemType::exFAT); if (wxPlatformInfo::Get().CheckOSVersion (10, 13)) { - ShowInfo (L" 5) APFS"); filesystems.push_back (VolumeCreationOptions::FilesystemType::APFS); + ShowInfo (wxString::Format (L" %li) %s", filesystems.size() + 1, "APFS")); filesystems.push_back (VolumeCreationOptions::FilesystemType::APFS); } #elif defined (TC_FREEBSD) || defined (TC_SOLARIS) - ShowInfo (L" 3) UFS"); filesystems.push_back (VolumeCreationOptions::FilesystemType::UFS); + ShowInfo (wxString::Format (L" %li) %s", filesystems.size() + 1, "UFS")); filesystems.push_back (VolumeCreationOptions::FilesystemType::UFS); #endif options->Filesystem = filesystems[AskSelection (filesystems.size(), 2) - 1]; } } - uint64 filesystemSize = layout->GetMaxDataSize (options->Size); - if (options->Filesystem == VolumeCreationOptions::FilesystemType::FAT && (filesystemSize < TC_MIN_FAT_FS_SIZE || filesystemSize > TC_MAX_FAT_SECTOR_COUNT * options->SectorSize)) { |