VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Core/Unix/CoreUnix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Core/Unix/CoreUnix.cpp')
-rw-r--r--src/Core/Unix/CoreUnix.cpp42
1 files changed, 35 insertions, 7 deletions
diff --git a/src/Core/Unix/CoreUnix.cpp b/src/Core/Unix/CoreUnix.cpp
index 26076a28..1868eb6d 100644
--- a/src/Core/Unix/CoreUnix.cpp
+++ b/src/Core/Unix/CoreUnix.cpp
@@ -303,17 +303,45 @@ namespace VeraCrypt
continue;
shared_ptr <VolumeInfo> mountedVol;
- try
+ // Introduce a retry mechanism with a timeout for control file access
+ // This workaround is limited to FUSE-T mounted volume under macOS for
+ // which md.Device starts with "fuse-t:"
+#ifdef VC_MACOSX_FUSET
+ bool isFuseT = wstring(mf.Device).find(L"fuse-t:") == 0;
+ int controlFileRetries = 10; // 10 retries with 500ms sleep each, total 5 seconds
+ while (!mountedVol && (controlFileRetries-- > 0))
+#endif
{
- 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);
+ }
+ catch (const std::exception& e)
+ {
+#ifdef VC_MACOSX_FUSET
+ // 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 (isFuseT && string (e.what()).find ("VeraCrypt::Serializer::ValidateName") != string::npos)
+ {
+ Thread::Sleep(500); // Wait before retrying
+ }
+ else
+ {
+ break; // Control file not found or other error
+ }
+#endif
+ }
}
- catch (...)
+
+ if (!mountedVol)
{
- continue;
+ continue; // Skip to the next mounted filesystem
}
if (!volumePath.IsEmpty() && wstring (mountedVol->Path).compare (volumePath) != 0)