VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Platform/Unix/File.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Platform/Unix/File.cpp')
-rw-r--r--src/Platform/Unix/File.cpp15
1 files changed, 15 insertions, 0 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
@@ -22,8 +22,14 @@
#ifdef TC_BSD
#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>
#endif
@@ -112,8 +118,13 @@ namespace VeraCrypt
u_int sectorSize;
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));
return mediaInfo.dki_lbsize;
@@ -170,8 +181,12 @@ namespace VeraCrypt
uint64 blockCount;
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));
return mediaSize;