VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Core
diff options
context:
space:
mode:
Diffstat (limited to 'src/Core')
-rw-r--r--src/Core/RandomNumberGenerator.cpp5
-rw-r--r--src/Core/VolumeCreator.h68
2 files changed, 73 insertions, 0 deletions
diff --git a/src/Core/RandomNumberGenerator.cpp b/src/Core/RandomNumberGenerator.cpp
index 38a228e..91247d8 100644
--- a/src/Core/RandomNumberGenerator.cpp
+++ b/src/Core/RandomNumberGenerator.cpp
@@ -14,6 +14,11 @@
#include <sys/types.h>
#include <errno.h>
#include <fcntl.h>
+
+#ifndef ERESTART
+#define ERESTART EINTR
+#endif
+
#endif
#include "RandomNumberGenerator.h"
diff --git a/src/Core/VolumeCreator.h b/src/Core/VolumeCreator.h
index 6b8f143..fc40f34 100644
--- a/src/Core/VolumeCreator.h
+++ b/src/Core/VolumeCreator.h
@@ -16,6 +16,12 @@
#include "Platform/Platform.h"
#include "Volume/Volume.h"
#include "RandomNumberGenerator.h"
+#if defined (TC_LINUX)
+#include "Platform/Unix/Process.h"
+#include <errno.h>
+#endif
+
+#define VC_MIN_BTRFS_VOLUME_SIZE 114294784ULL
namespace VeraCrypt
{
@@ -44,6 +50,7 @@ namespace VeraCrypt
Ext2,
Ext3,
Ext4,
+ Btrfs,
MacOsExt,
APFS,
UFS
@@ -63,6 +70,67 @@ 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 (ExecutedProcessFailed& epe)
+ {
+ // only permission error is accepted in case of failure of the command
+ if (epe.GetExitCode () == EPERM || epe.GetExitCode () == EACCES)
+ bRet = true;
+ }
+ catch (SystemException& se)
+ {
+ // if a permission error occured, then we consider that the command exists
+ if (se.GetErrorCode () == EPERM || se.GetErrorCode () == EACCES)
+ bRet = true;
+ }
+ catch (exception &e)
+ {
+ }
+#else
+ bRet = true;
+#endif
+ }
+
+ return bRet;
+ }
};
FilesystemType::Enum Filesystem;