diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2020-08-05 02:05:18 +0200 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2020-08-05 02:08:12 +0200 |
commit | 388e44c8095c04eac53ca6500363ebfb0d8f14bb (patch) | |
tree | 4d0439848321a308f63d51edcc559695b10fb9db /src/Core | |
parent | c8b501062d31afb37168f676fa3168ad8b1e9007 (diff) | |
download | VeraCrypt-388e44c8095c04eac53ca6500363ebfb0d8f14bb.tar.gz VeraCrypt-388e44c8095c04eac53ca6500363ebfb0d8f14bb.zip |
Linux: Add support for Btrfs filesystem when creating volumes
Diffstat (limited to 'src/Core')
-rw-r--r-- | src/Core/VolumeCreator.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/Core/VolumeCreator.h b/src/Core/VolumeCreator.h index 6b8f1436..22956451 100644 --- a/src/Core/VolumeCreator.h +++ b/src/Core/VolumeCreator.h @@ -16,6 +16,11 @@ #include "Platform/Platform.h" #include "Volume/Volume.h" #include "RandomNumberGenerator.h" +#if defined (TC_LINUX) +#include "Platform/Unix/Process.h" +#endif + +#define VC_MIN_BTRFS_VOLUME_SIZE 114294784ULL namespace VeraCrypt { @@ -44,6 +49,7 @@ namespace VeraCrypt Ext2, Ext3, Ext4, + Btrfs, MacOsExt, APFS, UFS @@ -63,6 +69,55 @@ namespace VeraCrypt return VolumeCreationOptions::FilesystemType::FAT; #endif } + + static const char* GetFsFormatter (VolumeCreationOptions::FilesystemType::Enum fsType) + { + switch (fsType) + { + #if defined (TC_LINUX) + case VolumeCreationOptions::FilesystemType::Ext2: return "mkfs.ext2"; + case VolumeCreationOptions::FilesystemType::Ext3: return "mkfs.ext3"; + case VolumeCreationOptions::FilesystemType::Ext4: return "mkfs.ext4"; + case VolumeCreationOptions::FilesystemType::NTFS: return "mkfs.ntfs"; + case VolumeCreationOptions::FilesystemType::exFAT: return "mkfs.exfat"; + case VolumeCreationOptions::FilesystemType::Btrfs: return "mkfs.btrfs"; + #elif defined (TC_MACOSX) + case VolumeCreationOptions::FilesystemType::MacOsExt: return "newfs_hfs"; + case VolumeCreationOptions::FilesystemType::exFAT: return "newfs_exfat"; + case VolumeCreationOptions::FilesystemType::APFS: return "newfs_apfs"; + #elif defined (TC_FREEBSD) || defined (TC_SOLARIS) + case VolumeCreationOptions::FilesystemType::UFS: return "newfs" ; + #endif + default: return NULL; + } + } + + static bool IsFsFormatterPresent (VolumeCreationOptions::FilesystemType::Enum fsType) + { + bool bRet = false; + const char* fsFormatter = GetFsFormatter (fsType); + if (fsFormatter) + { +#if defined (TC_LINUX) + try + { + list <string> args; + + args.push_back ("-V"); + Process::Execute (fsFormatter, args); + + bRet = true; + } + catch (exception &e) + { + } +#else + bRet = true; +#endif + } + + return bRet; + } }; FilesystemType::Enum Filesystem; |