VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Platform/Unix
diff options
context:
space:
mode:
authorkokokodak <82901997+kokokodak@users.noreply.github.com>2021-07-14 14:43:34 +0300
committerGitHub <noreply@github.com>2021-07-14 13:43:34 +0200
commitc8830a04b4adc3048b76c658fa1084e749f188da (patch)
treeeebca034aa351f33461d8980e478eb7cbe27c825 /src/Platform/Unix
parent0ff7f4548a433b10fa9eb5c61bbe589eb6b9eed1 (diff)
downloadVeraCrypt-c8830a04b4adc3048b76c658fa1084e749f188da.tar.gz
VeraCrypt-c8830a04b4adc3048b76c658fa1084e749f188da.zip
Add support for OpenBSD (#779)
* OpenBSD: add basic support modified: Build/Include/Makefile.inc modified: Driver/Fuse/FuseService.cpp modified: Main/FatalErrorHandler.cpp modified: Makefile modified: Platform/Unix/File.cpp modified: Platform/Unix/FilesystemPath.cpp modified: Platform/Unix/SystemInfo.cpp * OpenBSD: some necessary files were missing new file: Core/Unix/OpenBSD/CoreOpenBSD.cpp new file: Core/Unix/OpenBSD/CoreOpenBSD.h new file: Core/Unix/OpenBSD/System.h
Diffstat (limited to 'src/Platform/Unix')
-rw-r--r--src/Platform/Unix/File.cpp15
-rw-r--r--src/Platform/Unix/FilesystemPath.cpp2
-rw-r--r--src/Platform/Unix/SystemInfo.cpp2
3 files changed, 18 insertions, 1 deletions
diff --git a/src/Platform/Unix/File.cpp b/src/Platform/Unix/File.cpp
index cfb17e13..457a627d 100644
--- a/src/Platform/Unix/File.cpp
+++ b/src/Platform/Unix/File.cpp
@@ -23,6 +23,12 @@
#include <sys/disk.h>
#endif
+#ifdef TC_OPENBSD
+#include <sys/ioctl.h>
+#include <sys/dkio.h>
+#include <sys/disklabel.h>
+#endif
+
#ifdef TC_SOLARIS
#include <stropts.h>
#include <sys/dkio.h>
@@ -113,6 +119,11 @@ namespace VeraCrypt
throw_sys_sub_if (ioctl (FileHandle, DIOCGSECTORSIZE, &sectorSize) == -1, wstring (Path));
return (uint32) sectorSize;
+#elif defined (TC_OPENBSD)
+ struct disklabel dl;
+ throw_sys_sub_if (ioctl (FileHandle, DIOCGPDINFO, &dl) == -1, wstring (Path));
+ return (uint32) dl.d_secsize;
+
#elif defined (TC_SOLARIS)
struct dk_minfo mediaInfo;
throw_sys_sub_if (ioctl (FileHandle, DKIOCGMEDIAINFO, &mediaInfo) == -1, wstring (Path));
@@ -171,6 +182,10 @@ namespace VeraCrypt
throw_sys_sub_if (ioctl (FileHandle, DKIOCGETBLOCKSIZE, &blockSize) == -1, wstring (Path));
throw_sys_sub_if (ioctl (FileHandle, DKIOCGETBLOCKCOUNT, &blockCount) == -1, wstring (Path));
return blockCount * blockSize;
+# elif TC_OPENBSD
+ struct disklabel dl;
+ throw_sys_sub_if (ioctl (FileHandle, DIOCGPDINFO, &dl) == -1, wstring (Path));
+ return DL_GETDSIZE(&dl);
# else
uint64 mediaSize;
throw_sys_sub_if (ioctl (FileHandle, DIOCGMEDIASIZE, &mediaSize) == -1, wstring (Path));
diff --git a/src/Platform/Unix/FilesystemPath.cpp b/src/Platform/Unix/FilesystemPath.cpp
index 674b395b..e6841d0f 100644
--- a/src/Platform/Unix/FilesystemPath.cpp
+++ b/src/Platform/Unix/FilesystemPath.cpp
@@ -15,7 +15,7 @@
#include "Platform/StringConverter.h"
#include <stdio.h>
#include <sys/stat.h>
-#if !defined(__FreeBSD__) && !defined(__APPLE__)
+#if !defined(__FreeBSD__) && !defined(__APPLE__) && !defined(__OpenBSD__)
#include <sys/sysmacros.h>
#endif
diff --git a/src/Platform/Unix/SystemInfo.cpp b/src/Platform/Unix/SystemInfo.cpp
index d4f648bb..f09674aa 100644
--- a/src/Platform/Unix/SystemInfo.cpp
+++ b/src/Platform/Unix/SystemInfo.cpp
@@ -24,6 +24,8 @@ namespace VeraCrypt
return L"Mac OS X";
#elif defined (TC_FREEBSD)
return L"FreeBSD";
+#elif defined (TC_OPENBSD)
+ return L"OpenBSD";
#elif defined (TC_SOLARIS)
return L"Solaris";
#else