Linux: retry auto FAT mounts with blkid

Keep the historical auto-mount behavior as the first attempt when the user did not request a filesystem type. If that mount fails on Linux, detect the filesystem with blkid and retry only for FAT-family types that minimal mount implementations may not auto-probe.

Leave explicit filesystem types and NTFS kernel-driver resolution unchanged.
This commit is contained in:
Mounir IDRASSI
2026-06-21 18:08:29 +09:00
parent f1a6e23734
commit 26adb5e882
3 changed files with 54 additions and 3 deletions
+46 -2
View File
@@ -989,6 +989,40 @@ namespace VeraCrypt
filesystemType = StringConverter::ToWide (SelectNtfsKernelFilesystemType());
internalMountOnly = true;
}
string CoreUnix::DetectLinuxMountFallbackFilesystemType (const DevicePath &devicePath) const
{
string detectedFilesystemType = DetectFilesystemType (devicePath);
if (detectedFilesystemType == "vfat" || detectedFilesystemType == "exfat" || detectedFilesystemType == "msdos")
return detectedFilesystemType;
if (detectedFilesystemType == "fat")
return "vfat";
return string();
}
void CoreUnix::MountFilesystemWithFallback (const DevicePath &devicePath, const DirectoryPath &mountPoint,
const string &filesystemType, bool allowFilesystemTypeFallback, bool readOnly,
const string &systemMountOptions, bool internalMountOnly) const
{
try
{
MountFilesystem (devicePath, mountPoint, filesystemType, readOnly, systemMountOptions, internalMountOnly);
}
catch (ExecutedProcessFailed&)
{
if (!allowFilesystemTypeFallback || !filesystemType.empty() || internalMountOnly)
throw;
string fallbackFilesystemType = DetectLinuxMountFallbackFilesystemType (devicePath);
if (fallbackFilesystemType.empty())
throw;
MountFilesystem (devicePath, mountPoint, fallbackFilesystemType, readOnly, systemMountOptions, false);
}
}
#endif
void CoreUnix::MountFilesystem (const DevicePath &devicePath, const DirectoryPath &mountPoint, const string &filesystemType, bool readOnly, const string &systemMountOptions, bool internalMountOnly) const
@@ -1346,14 +1380,24 @@ namespace VeraCrypt
bool internalMountOnly = false;
#ifdef TC_LINUX
ResolveNtfsKernelMountOptions (loopDev, options.MountNtfsWithKernelDriver, filesystemType, internalMountOnly);
#endif
bool allowFilesystemTypeFallback = filesystemType.empty();
ResolveNtfsKernelMountOptions (loopDev, options.MountNtfsWithKernelDriver, filesystemType, internalMountOnly);
allowFilesystemTypeFallback = allowFilesystemTypeFallback && filesystemType.empty() && !internalMountOnly;
MountFilesystemWithFallback (loopDev, *options.MountPoint,
StringConverter::ToSingle (filesystemType),
allowFilesystemTypeFallback,
options.Protection == VolumeProtection::ReadOnly,
StringConverter::ToSingle (options.FilesystemOptions),
internalMountOnly);
#else
MountFilesystem (loopDev, *options.MountPoint,
StringConverter::ToSingle (filesystemType),
options.Protection == VolumeProtection::ReadOnly,
StringConverter::ToSingle (options.FilesystemOptions),
internalMountOnly);
#endif
}
return loopDev;
+4
View File
@@ -80,6 +80,10 @@ namespace VeraCrypt
bool IsFilesystemTypeRegistered (const string &filesystemType) const;
bool IsKernelFilesystemTypeAvailable (const string &filesystemType) const;
bool IsNtfsReadWriteKernelFilesystemTypeAvailable () const;
string DetectLinuxMountFallbackFilesystemType (const DevicePath &devicePath) const;
void MountFilesystemWithFallback (const DevicePath &devicePath, const DirectoryPath &mountPoint,
const string &filesystemType, bool allowFilesystemTypeFallback, bool readOnly,
const string &systemMountOptions, bool internalMountOnly) const;
void ResolveNtfsKernelMountOptions (const DevicePath &devicePath, bool mountNtfsWithKernelDriver,
wstring &filesystemType, bool &internalMountOnly) const;
string SelectNtfsKernelFilesystemType () const;
+4 -1
View File
@@ -630,11 +630,14 @@ namespace VeraCrypt
{
wstring filesystemType = options.FilesystemType;
bool internalMountOnly = false;
bool allowFilesystemTypeFallback = filesystemType.empty();
ResolveNtfsKernelMountOptions (nativeDevPath, options.MountNtfsWithKernelDriver, filesystemType, internalMountOnly);
allowFilesystemTypeFallback = allowFilesystemTypeFallback && filesystemType.empty() && !internalMountOnly;
MountFilesystem (nativeDevPath, *options.MountPoint,
MountFilesystemWithFallback (nativeDevPath, *options.MountPoint,
StringConverter::ToSingle (filesystemType),
allowFilesystemTypeFallback,
options.Protection == VolumeProtection::ReadOnly,
StringConverter::ToSingle (options.FilesystemOptions),
internalMountOnly);