mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2026-07-05 20:48:00 -05:00
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:
@@ -989,6 +989,40 @@ namespace VeraCrypt
|
|||||||
filesystemType = StringConverter::ToWide (SelectNtfsKernelFilesystemType());
|
filesystemType = StringConverter::ToWide (SelectNtfsKernelFilesystemType());
|
||||||
internalMountOnly = true;
|
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
|
#endif
|
||||||
|
|
||||||
void CoreUnix::MountFilesystem (const DevicePath &devicePath, const DirectoryPath &mountPoint, const string &filesystemType, bool readOnly, const string &systemMountOptions, bool internalMountOnly) const
|
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;
|
bool internalMountOnly = false;
|
||||||
|
|
||||||
#ifdef TC_LINUX
|
#ifdef TC_LINUX
|
||||||
ResolveNtfsKernelMountOptions (loopDev, options.MountNtfsWithKernelDriver, filesystemType, internalMountOnly);
|
bool allowFilesystemTypeFallback = filesystemType.empty();
|
||||||
#endif
|
|
||||||
|
|
||||||
|
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,
|
MountFilesystem (loopDev, *options.MountPoint,
|
||||||
StringConverter::ToSingle (filesystemType),
|
StringConverter::ToSingle (filesystemType),
|
||||||
options.Protection == VolumeProtection::ReadOnly,
|
options.Protection == VolumeProtection::ReadOnly,
|
||||||
StringConverter::ToSingle (options.FilesystemOptions),
|
StringConverter::ToSingle (options.FilesystemOptions),
|
||||||
internalMountOnly);
|
internalMountOnly);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return loopDev;
|
return loopDev;
|
||||||
|
|||||||
@@ -80,6 +80,10 @@ namespace VeraCrypt
|
|||||||
bool IsFilesystemTypeRegistered (const string &filesystemType) const;
|
bool IsFilesystemTypeRegistered (const string &filesystemType) const;
|
||||||
bool IsKernelFilesystemTypeAvailable (const string &filesystemType) const;
|
bool IsKernelFilesystemTypeAvailable (const string &filesystemType) const;
|
||||||
bool IsNtfsReadWriteKernelFilesystemTypeAvailable () 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,
|
void ResolveNtfsKernelMountOptions (const DevicePath &devicePath, bool mountNtfsWithKernelDriver,
|
||||||
wstring &filesystemType, bool &internalMountOnly) const;
|
wstring &filesystemType, bool &internalMountOnly) const;
|
||||||
string SelectNtfsKernelFilesystemType () const;
|
string SelectNtfsKernelFilesystemType () const;
|
||||||
|
|||||||
@@ -630,11 +630,14 @@ namespace VeraCrypt
|
|||||||
{
|
{
|
||||||
wstring filesystemType = options.FilesystemType;
|
wstring filesystemType = options.FilesystemType;
|
||||||
bool internalMountOnly = false;
|
bool internalMountOnly = false;
|
||||||
|
bool allowFilesystemTypeFallback = filesystemType.empty();
|
||||||
|
|
||||||
ResolveNtfsKernelMountOptions (nativeDevPath, options.MountNtfsWithKernelDriver, filesystemType, internalMountOnly);
|
ResolveNtfsKernelMountOptions (nativeDevPath, options.MountNtfsWithKernelDriver, filesystemType, internalMountOnly);
|
||||||
|
allowFilesystemTypeFallback = allowFilesystemTypeFallback && filesystemType.empty() && !internalMountOnly;
|
||||||
|
|
||||||
MountFilesystem (nativeDevPath, *options.MountPoint,
|
MountFilesystemWithFallback (nativeDevPath, *options.MountPoint,
|
||||||
StringConverter::ToSingle (filesystemType),
|
StringConverter::ToSingle (filesystemType),
|
||||||
|
allowFilesystemTypeFallback,
|
||||||
options.Protection == VolumeProtection::ReadOnly,
|
options.Protection == VolumeProtection::ReadOnly,
|
||||||
StringConverter::ToSingle (options.FilesystemOptions),
|
StringConverter::ToSingle (options.FilesystemOptions),
|
||||||
internalMountOnly);
|
internalMountOnly);
|
||||||
|
|||||||
Reference in New Issue
Block a user