1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-11 11:08:02 -06:00

MacOSX: Add for using FUSE-T instead of MacFUSE

The build script build_veracrypt_macosx.h now accepts the argument -f to enable fuse-t support.
It is also possible to set the environment variable VC_OSX_FUSET to 1 for FUSE-T support.
A change was done in CoreUnix::GetMountedVolumes to add a waiting loop  for control file to be accessible because when using FUSE-T there always a delay before control file can be serialized.
This commit is contained in:
Mounir IDRASSI
2024-06-22 01:13:20 +02:00
parent 8b01b533cf
commit edde1d45f6
8 changed files with 1112 additions and 12 deletions

View File

@@ -303,17 +303,39 @@ namespace VeraCrypt
continue;
shared_ptr <VolumeInfo> mountedVol;
try
// Introduce a retry mechanism with a timeout for control file access
int controlFileRetries = 5;
while (controlFileRetries-- > 0)
{
shared_ptr <File> controlFile (new File);
controlFile->Open (string (mf.MountPoint) + FuseService::GetControlPath());
try
{
shared_ptr <File> controlFile (new File);
controlFile->Open (string (mf.MountPoint) + FuseService::GetControlPath());
shared_ptr <Stream> controlFileStream (new FileStream (controlFile));
mountedVol = Serializable::DeserializeNew <VolumeInfo> (controlFileStream);
shared_ptr <Stream> controlFileStream (new FileStream (controlFile));
mountedVol = Serializable::DeserializeNew <VolumeInfo> (controlFileStream);
break; // Control file opened successfully
}
catch (const std::exception& e)
{
// if exception starts with "VeraCrypt::Serializer::ValidateName", then
// serialization is not ready yet and we need to wait before retrying
// this happens when FUSE-T is used under macOS and if it is the first time
// the volume is mounted
if (string (e.what()).find ("VeraCrypt::Serializer::ValidateName") != string::npos)
{
Thread::Sleep(250); // Wait before retrying
}
else
{
break; // Control file not found
}
}
}
catch (...)
if (!mountedVol)
{
continue;
continue; // Skip to the next mounted filesystem
}
if (!volumePath.IsEmpty() && wstring (mountedVol->Path).compare (volumePath) != 0)
@@ -700,6 +722,7 @@ namespace VeraCrypt
}
catch (...)
{
wcout << L"Exception. Error mounting volume: " << wstring(*options.Path) << endl;
try
{
VolumeInfoList mountedVolumes = GetMountedVolumes (*options.Path);

View File

@@ -119,6 +119,7 @@ namespace VeraCrypt
void CoreMacOSX::MountAuxVolumeImage (const DirectoryPath &auxMountPoint, const MountOptions &options) const
{
#ifndef VC_MACOSX_FUSET
// Check FUSE version
char fuseVersionString[MAXHOSTNAMELEN + 1] = { 0 };
size_t fuseVersionStringLength = MAXHOSTNAMELEN;
@@ -153,7 +154,7 @@ namespace VeraCrypt
if (fuseVersionMajor < 2 || (fuseVersionMajor == 2 && fuseVersionMinor < 5))
throw HigherFuseVersionRequired (SRC_POS);
#endif
// Mount volume image
string volImage = string (auxMountPoint) + FuseService::GetVolumeImagePath();