mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-11 11:08:02 -06:00
Linux: Reduce minimal size requirement for BTRFS support to 16 MiB by using mixed mode for volumes whose size is less than 109 MiB
This commit is contained in:
@@ -21,7 +21,8 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#endif
|
#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
|
namespace VeraCrypt
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -258,7 +258,10 @@ namespace VeraCrypt
|
|||||||
|
|
||||||
case Step::FormatOptions:
|
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);
|
SelectedVolumePath.IsDevice() && (OuterVolume || SelectedVolumeType != VolumeType::Hidden), OuterVolume, LargeFilesSupport);
|
||||||
|
|
||||||
page->SetPageTitle (_("Format Options"));
|
page->SetPageTitle (_("Format Options"));
|
||||||
@@ -484,6 +487,9 @@ namespace VeraCrypt
|
|||||||
|
|
||||||
shared_ptr <VolumeInfo> volume = Core->MountVolume (mountOptions);
|
shared_ptr <VolumeInfo> volume = Core->MountVolume (mountOptions);
|
||||||
finally_do_arg (shared_ptr <VolumeInfo>, volume, { Core->DismountVolume (finally_arg, true); });
|
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
|
Thread::Sleep (2000); // Try to prevent race conditions caused by OS
|
||||||
|
|
||||||
@@ -527,7 +533,14 @@ namespace VeraCrypt
|
|||||||
args.push_back ("-f");
|
args.push_back ("-f");
|
||||||
|
|
||||||
if (SelectedFilesystemType == VolumeCreationOptions::FilesystemType::Btrfs)
|
if (SelectedFilesystemType == VolumeCreationOptions::FilesystemType::Btrfs)
|
||||||
|
{
|
||||||
args.push_back ("-f");
|
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));
|
args.push_back (string (virtualDevice));
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
namespace VeraCrypt
|
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)
|
: VolumeFormatOptionsWizardPageBase (parent)
|
||||||
{
|
{
|
||||||
InfoStaticText->SetLabel (_(
|
InfoStaticText->SetLabel (_(
|
||||||
@@ -26,7 +26,7 @@ namespace VeraCrypt
|
|||||||
if (!disableNoneFilesystem)
|
if (!disableNoneFilesystem)
|
||||||
FilesystemTypeChoice->Append (LangString["NONE"], (void *) VolumeCreationOptions::FilesystemType::None);
|
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);
|
FilesystemTypeChoice->Append (L"FAT", (void *) VolumeCreationOptions::FilesystemType::FAT);
|
||||||
|
|
||||||
#ifdef TC_WINDOWS
|
#ifdef TC_WINDOWS
|
||||||
@@ -43,9 +43,8 @@ namespace VeraCrypt
|
|||||||
FilesystemTypeChoice->Append (L"exFAT", (void *) VolumeCreationOptions::FilesystemType::exFAT);
|
FilesystemTypeChoice->Append (L"exFAT", (void *) VolumeCreationOptions::FilesystemType::exFAT);
|
||||||
if (VolumeCreationOptions::FilesystemType::IsFsFormatterPresent (VolumeCreationOptions::FilesystemType::Btrfs))
|
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 16777216 bytes
|
||||||
// minimum size to be able to format as Btrfs is 114294784 bytes
|
if (filesystemSize >= VC_MIN_SMALL_BTRFS_VOLUME_SIZE)
|
||||||
if (volumeSize >= minVolumeSizeForBtrfs)
|
|
||||||
FilesystemTypeChoice->Append (L"Btrfs", (void *) VolumeCreationOptions::FilesystemType::Btrfs);
|
FilesystemTypeChoice->Append (L"Btrfs", (void *) VolumeCreationOptions::FilesystemType::Btrfs);
|
||||||
}
|
}
|
||||||
#elif defined (TC_MACOSX)
|
#elif defined (TC_MACOSX)
|
||||||
@@ -57,7 +56,7 @@ namespace VeraCrypt
|
|||||||
FilesystemTypeChoice->Append (L"UFS", (void *) VolumeCreationOptions::FilesystemType::UFS);
|
FilesystemTypeChoice->Append (L"UFS", (void *) VolumeCreationOptions::FilesystemType::UFS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!disable32bitFilesystems && volumeSize <= TC_MAX_FAT_SECTOR_COUNT * sectorSize)
|
if (!disable32bitFilesystems && filesystemSize <= TC_MAX_FAT_SECTOR_COUNT * sectorSize)
|
||||||
SetFilesystemType (VolumeCreationOptions::FilesystemType::FAT);
|
SetFilesystemType (VolumeCreationOptions::FilesystemType::FAT);
|
||||||
else
|
else
|
||||||
SetFilesystemType (VolumeCreationOptions::FilesystemType::GetPlatformNative());
|
SetFilesystemType (VolumeCreationOptions::FilesystemType::GetPlatformNative());
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace VeraCrypt
|
|||||||
class VolumeFormatOptionsWizardPage : public VolumeFormatOptionsWizardPageBase
|
class VolumeFormatOptionsWizardPage : public VolumeFormatOptionsWizardPageBase
|
||||||
{
|
{
|
||||||
public:
|
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;
|
VolumeCreationOptions::FilesystemType::Enum GetFilesystemType () const;
|
||||||
bool IsValid () { return true; }
|
bool IsValid () { return true; }
|
||||||
|
|||||||
@@ -810,7 +810,7 @@ namespace VeraCrypt
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (options->Filesystem == VolumeCreationOptions::FilesystemType::Btrfs
|
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."));
|
throw_err (_("Specified volume size is too small to be used with Btrfs filesystem."));
|
||||||
}
|
}
|
||||||
@@ -939,7 +939,14 @@ namespace VeraCrypt
|
|||||||
args.push_back ("-f");
|
args.push_back ("-f");
|
||||||
|
|
||||||
if (options->Filesystem == VolumeCreationOptions::FilesystemType::Btrfs)
|
if (options->Filesystem == VolumeCreationOptions::FilesystemType::Btrfs)
|
||||||
|
{
|
||||||
args.push_back ("-f");
|
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));
|
args.push_back (string (virtualDevice));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user