mirror of
https://github.com/veracrypt/VeraCrypt
synced 2024-11-27 21:43:29 +01: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:
parent
0ab412a8de
commit
1fb59b58ee
@ -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
|
||||
{
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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());
|
||||
|
@ -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; }
|
||||
|
@ -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));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user