VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Driver/Fuse/FuseService.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Driver/Fuse/FuseService.cpp')
-rw-r--r--src/Driver/Fuse/FuseService.cpp33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/Driver/Fuse/FuseService.cpp b/src/Driver/Fuse/FuseService.cpp
index 97316532..5b12ba4d 100644
--- a/src/Driver/Fuse/FuseService.cpp
+++ b/src/Driver/Fuse/FuseService.cpp
@@ -3,15 +3,20 @@
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
by the TrueCrypt License 3.0.
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2016 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2017 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages.
*/
+#ifdef TC_OPENBSD
+#define FUSE_USE_VERSION 26
+#else
#define FUSE_USE_VERSION 25
+#endif
+
#include <errno.h>
#include <fcntl.h>
#include <fuse.h>
#include <iostream>
@@ -50,9 +55,13 @@ namespace VeraCrypt
return 0;
}
+#ifdef TC_OPENBSD
+ static void *fuse_service_init (struct fuse_conn_info *)
+#else
static void *fuse_service_init ()
+#endif
{
try
{
// Termination signals are handled by a separate process to allow clean dismount on shutdown
@@ -213,16 +222,16 @@ namespace VeraCrypt
SecureBuffer alignedBuffer (alignedSize);
FuseService::ReadVolumeSectors (alignedBuffer, alignedOffset);
- BufferPtr ((byte *) buf, size).CopyFrom (alignedBuffer.GetRange (offset % sectorSize, size));
+ BufferPtr ((uint8 *) buf, size).CopyFrom (alignedBuffer.GetRange (offset % sectorSize, size));
}
else
{
- FuseService::ReadVolumeSectors (BufferPtr ((byte *) buf, size), offset);
+ FuseService::ReadVolumeSectors (BufferPtr ((uint8 *) buf, size), offset);
}
}
- catch (MissingVolumeData)
+ catch (MissingVolumeData&)
{
return 0;
}
@@ -231,9 +240,9 @@ namespace VeraCrypt
if (strcmp (path, FuseService::GetControlPath()) == 0)
{
shared_ptr <Buffer> infoBuf = FuseService::GetVolumeInfo();
- BufferPtr outBuf ((byte *)buf, size);
+ BufferPtr outBuf ((uint8 *)buf, size);
if (offset >= (off_t) infoBuf->Size())
return 0;
@@ -283,18 +292,18 @@ namespace VeraCrypt
return -EACCES;
if (strcmp (path, FuseService::GetVolumeImagePath()) == 0)
{
- FuseService::WriteVolumeSectors (BufferPtr ((byte *) buf, size), offset);
+ FuseService::WriteVolumeSectors (BufferPtr ((uint8 *) buf, size), offset);
return size;
}
if (strcmp (path, FuseService::GetControlPath()) == 0)
{
if (FuseService::AuxDeviceInfoReceived())
return -EACCES;
- FuseService::ReceiveAuxDeviceInfo (ConstBufferPtr ((const byte *)buf, size));
+ FuseService::ReceiveAuxDeviceInfo (ConstBufferPtr ((const uint8 *)buf, size));
return size;
}
}
#ifdef TC_FREEBSD
@@ -349,9 +358,9 @@ namespace VeraCrypt
try
{
throw;
}
- catch (std::bad_alloc)
+ catch (std::bad_alloc&)
{
return -ENOMEM;
}
catch (ParameterIncorrect &e)
@@ -574,23 +583,27 @@ namespace VeraCrypt
sigaction (SIGQUIT, &action, nullptr);
sigaction (SIGTERM, &action, nullptr);
// Wait for the exit of the main service
- byte buf[1];
+ uint8 buf[1];
if (read (SignalHandlerPipe->GetReadFD(), buf, sizeof (buf))) { } // Errors ignored
_exit (0);
}
SignalHandlerPipe->GetWriteFD();
+#ifdef TC_OPENBSD
+ _exit (fuse_main (argc, argv, &fuse_service_oper, NULL));
+#else
_exit (fuse_main (argc, argv, &fuse_service_oper));
+#endif
}
VolumeInfo FuseService::OpenVolumeInfo;
Mutex FuseService::OpenVolumeInfoMutex;
shared_ptr <Volume> FuseService::MountedVolume;
VolumeSlotNumber FuseService::SlotNumber;
uid_t FuseService::UserId;
gid_t FuseService::GroupId;
- auto_ptr <Pipe> FuseService::SignalHandlerPipe;
+ unique_ptr <Pipe> FuseService::SignalHandlerPipe;
}