From c8830a04b4adc3048b76c658fa1084e749f188da Mon Sep 17 00:00:00 2001 From: kokokodak <82901997+kokokodak@users.noreply.github.com> Date: Wed, 14 Jul 2021 14:43:34 +0300 Subject: 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 --- src/Platform/Unix/File.cpp | 15 +++++++++++++++ src/Platform/Unix/FilesystemPath.cpp | 2 +- src/Platform/Unix/SystemInfo.cpp | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) (limited to 'src/Platform/Unix') 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 #endif +#ifdef TC_OPENBSD +#include +#include +#include +#endif + #ifdef TC_SOLARIS #include #include @@ -113,6 +119,11 @@ namespace VeraCrypt throw_sys_sub_if (ioctl (FileHandle, DIOCGSECTORSIZE, §orSize) == -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 #include -#if !defined(__FreeBSD__) && !defined(__APPLE__) +#if !defined(__FreeBSD__) && !defined(__APPLE__) && !defined(__OpenBSD__) #include #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 -- cgit v1.2.3