VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Core/VolumeCreator.h3
-rw-r--r--src/Main/Forms/VolumeCreationWizard.cpp15
-rw-r--r--src/Main/Forms/VolumeFormatOptionsWizardPage.cpp11
-rw-r--r--src/Main/Forms/VolumeFormatOptionsWizardPage.h2
-rw-r--r--src/Main/TextUserInterface.cpp9
5 files changed, 30 insertions, 10 deletions
diff --git a/src/Core/VolumeCreator.h b/src/Core/VolumeCreator.h
index fc40f34d..3e051bc7 100644
--- a/src/Core/VolumeCreator.h
+++ b/src/Core/VolumeCreator.h
@@ -21,7 +21,8 @@
#include <errno.h>
#endif
-#define VC_MIN_BTRFS_VOLUME_SIZE 114294784ULL
+#define VC_MIN_LARGE_BTRFS_VOLUME_SIZE 114294784ULL
+#define VC_MIN_SMALL_BTRFS_VOLUME_SIZE 16777216ULL
namespace VeraCrypt
{
diff --git a/src/Main/Forms/VolumeCreationWizard.cpp b/src/Main/Forms/VolumeCreationWizard.cpp
index 4df20301..5d814e89 100644
--- a/src/Main/Forms/VolumeCreationWizard.cpp
+++ b/src/Main/Forms/VolumeCreationWizard.cpp
@@ -258,7 +258,10 @@ namespace VeraCrypt
case Step::FormatOptions:
{
- VolumeFormatOptionsWizardPage *page = new VolumeFormatOptionsWizardPage (GetPageParent(), VolumeSize, SectorSize,
+ shared_ptr <VolumeLayout> layout ((OuterVolume || SelectedVolumeType != VolumeType::Hidden)? (VolumeLayout*) new VolumeLayoutV2Normal() : (VolumeLayout*) new VolumeLayoutV2Hidden());
+ uint64 filesystemSize = layout->GetMaxDataSize (VolumeSize);
+
+ VolumeFormatOptionsWizardPage *page = new VolumeFormatOptionsWizardPage (GetPageParent(), filesystemSize, SectorSize,
SelectedVolumePath.IsDevice() && (OuterVolume || SelectedVolumeType != VolumeType::Hidden), OuterVolume, LargeFilesSupport);
page->SetPageTitle (_("Format Options"));
@@ -484,6 +487,9 @@ namespace VeraCrypt
shared_ptr <VolumeInfo> volume = Core->MountVolume (mountOptions);
finally_do_arg (shared_ptr <VolumeInfo>, volume, { Core->DismountVolume (finally_arg, true); });
+
+ shared_ptr <VolumeLayout> layout((volume->Type == VolumeType::Normal)? (VolumeLayout*) new VolumeLayoutV2Normal() : (VolumeLayout*) new VolumeLayoutV2Hidden());
+ uint64 filesystemSize = layout->GetMaxDataSize (VolumeSize);
Thread::Sleep (2000); // Try to prevent race conditions caused by OS
@@ -527,7 +533,14 @@ namespace VeraCrypt
args.push_back ("-f");
if (SelectedFilesystemType == VolumeCreationOptions::FilesystemType::Btrfs)
+ {
args.push_back ("-f");
+ if (filesystemSize < VC_MIN_LARGE_BTRFS_VOLUME_SIZE)
+ {
+ // use mixed mode for small BTRFS volumes
+ args.push_back ("-M");
+ }
+ }
args.push_back (string (virtualDevice));
diff --git a/src/Main/Forms/VolumeFormatOptionsWizardPage.cpp b/src/Main/Forms/VolumeFormatOptionsWizardPage.cpp
index 30f8c6ba..d3bd5216 100644
--- a/src/Main/Forms/VolumeFormatOptionsWizardPage.cpp
+++ b/src/Main/Forms/VolumeFormatOptionsWizardPage.cpp
@@ -17,7 +17,7 @@
namespace VeraCrypt
{
- VolumeFormatOptionsWizardPage::VolumeFormatOptionsWizardPage (wxPanel* parent, uint64 volumeSize, uint32 sectorSize, bool enableQuickFormatButton, bool disableNoneFilesystem, bool disable32bitFilesystems)
+ VolumeFormatOptionsWizardPage::VolumeFormatOptionsWizardPage (wxPanel* parent, uint64 filesystemSize, uint32 sectorSize, bool enableQuickFormatButton, bool disableNoneFilesystem, bool disable32bitFilesystems)
: VolumeFormatOptionsWizardPageBase (parent)
{
InfoStaticText->SetLabel (_(
@@ -26,7 +26,7 @@ namespace VeraCrypt
if (!disableNoneFilesystem)
FilesystemTypeChoice->Append (LangString["NONE"], (void *) VolumeCreationOptions::FilesystemType::None);
- if (!disable32bitFilesystems && volumeSize <= TC_MAX_FAT_SECTOR_COUNT * sectorSize)
+ if (!disable32bitFilesystems && filesystemSize <= TC_MAX_FAT_SECTOR_COUNT * sectorSize)
FilesystemTypeChoice->Append (L"FAT", (void *) VolumeCreationOptions::FilesystemType::FAT);
#ifdef TC_WINDOWS
@@ -43,9 +43,8 @@ namespace VeraCrypt
FilesystemTypeChoice->Append (L"exFAT", (void *) VolumeCreationOptions::FilesystemType::exFAT);
if (VolumeCreationOptions::FilesystemType::IsFsFormatterPresent (VolumeCreationOptions::FilesystemType::Btrfs))
{
- uint64 minVolumeSizeForBtrfs = VC_MIN_BTRFS_VOLUME_SIZE + (uint64) (VC_MAX (TC_TOTAL_VOLUME_HEADERS_SIZE, TC_HIDDEN_VOLUME_HOST_FS_RESERVED_END_AREA_SIZE_HIGH));
- // minimum size to be able to format as Btrfs is 114294784 bytes
- if (volumeSize >= minVolumeSizeForBtrfs)
+ // minimum size to be able to format as Btrfs is 16777216 bytes
+ if (filesystemSize >= VC_MIN_SMALL_BTRFS_VOLUME_SIZE)
FilesystemTypeChoice->Append (L"Btrfs", (void *) VolumeCreationOptions::FilesystemType::Btrfs);
}
#elif defined (TC_MACOSX)
@@ -57,7 +56,7 @@ namespace VeraCrypt
FilesystemTypeChoice->Append (L"UFS", (void *) VolumeCreationOptions::FilesystemType::UFS);
#endif
- if (!disable32bitFilesystems && volumeSize <= TC_MAX_FAT_SECTOR_COUNT * sectorSize)
+ if (!disable32bitFilesystems && filesystemSize <= TC_MAX_FAT_SECTOR_COUNT * sectorSize)
SetFilesystemType (VolumeCreationOptions::FilesystemType::FAT);
else
SetFilesystemType (VolumeCreationOptions::FilesystemType::GetPlatformNative());
diff --git a/src/Main/Forms/VolumeFormatOptionsWizardPage.h b/src/Main/Forms/VolumeFormatOptionsWizardPage.h
index 25ca2b37..b38f6e99 100644
--- a/src/Main/Forms/VolumeFormatOptionsWizardPage.h
+++ b/src/Main/Forms/VolumeFormatOptionsWizardPage.h
@@ -21,7 +21,7 @@ namespace VeraCrypt
class VolumeFormatOptionsWizardPage : public VolumeFormatOptionsWizardPageBase
{
public:
- VolumeFormatOptionsWizardPage (wxPanel* parent, uint64 volumeSize, uint32 sectorSize, bool enableQuickFormatButton = true, bool disableNoneFilesystem = false, bool disable32bitFilesystems = false);
+ VolumeFormatOptionsWizardPage (wxPanel* parent, uint64 filesystemSize, uint32 sectorSize, bool enableQuickFormatButton = true, bool disableNoneFilesystem = false, bool disable32bitFilesystems = false);
VolumeCreationOptions::FilesystemType::Enum GetFilesystemType () const;
bool IsValid () { return true; }
diff --git a/src/Main/TextUserInterface.cpp b/src/Main/TextUserInterface.cpp
index 95becfdf..0ad0b958 100644
--- a/src/Main/TextUserInterface.cpp
+++ b/src/Main/TextUserInterface.cpp
@@ -810,7 +810,7 @@ namespace VeraCrypt
}
if (options->Filesystem == VolumeCreationOptions::FilesystemType::Btrfs
- && (filesystemSize < VC_MIN_BTRFS_VOLUME_SIZE))
+ && (filesystemSize < VC_MIN_SMALL_BTRFS_VOLUME_SIZE))
{
throw_err (_("Specified volume size is too small to be used with Btrfs filesystem."));
}
@@ -939,7 +939,14 @@ namespace VeraCrypt
args.push_back ("-f");
if (options->Filesystem == VolumeCreationOptions::FilesystemType::Btrfs)
+ {
args.push_back ("-f");
+ if (filesystemSize < VC_MIN_LARGE_BTRFS_VOLUME_SIZE)
+ {
+ // use mixed mode for small BTRFS volumes
+ args.push_back ("-M");
+ }
+ }
args.push_back (string (virtualDevice));