mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2026-06-17 01:56:10 -05:00
macOS: force fresh exFAT layout when formatting volumes
Pass -R to newfs_exfat in both GUI and text-mode volume creation so macOS derives a fresh exFAT layout instead of preserving stale geometry from an existing exFAT boot region. This matches Finder/Disk Utility erase behavior. Validated on Windows 11: chkdsk no longer reports boot-region corruption on volumes formatted this way. Fixes #1021.
This commit is contained in:
@@ -907,6 +907,9 @@ namespace VeraCrypt
|
||||
}
|
||||
|
||||
#ifdef TC_MACOSX
|
||||
if (IsMacOSXExFATFormatter (fsFormatter))
|
||||
AddMacOSXExFATFormatterArgs (args);
|
||||
|
||||
if (IsMacOSXAPFSFormatter (fsFormatter) && !useElevatedAPFSFormatter)
|
||||
AddMacOSXAPFSFormatterUserArgs (args);
|
||||
#endif
|
||||
|
||||
@@ -61,11 +61,20 @@ namespace VeraCrypt
|
||||
return deviceIdentifier;
|
||||
}
|
||||
|
||||
inline bool IsMacOSXAPFSFormatter (const string &fsFormatter)
|
||||
inline string GetMacOSXFormatterName (const string &fsFormatter)
|
||||
{
|
||||
size_t namePos = fsFormatter.find_last_of ('/');
|
||||
string fsFormatterName = namePos == string::npos ? fsFormatter : fsFormatter.substr (namePos + 1);
|
||||
return fsFormatterName == "newfs_apfs";
|
||||
return namePos == string::npos ? fsFormatter : fsFormatter.substr (namePos + 1);
|
||||
}
|
||||
|
||||
inline bool IsMacOSXAPFSFormatter (const string &fsFormatter)
|
||||
{
|
||||
return GetMacOSXFormatterName (fsFormatter) == "newfs_apfs";
|
||||
}
|
||||
|
||||
inline bool IsMacOSXExFATFormatter (const string &fsFormatter)
|
||||
{
|
||||
return GetMacOSXFormatterName (fsFormatter) == "newfs_exfat";
|
||||
}
|
||||
|
||||
inline bool UseElevatedMacOSXAPFSFormatter (const string &fsFormatter)
|
||||
@@ -88,6 +97,12 @@ namespace VeraCrypt
|
||||
args.push_back (gid.str());
|
||||
}
|
||||
|
||||
inline void AddMacOSXExFATFormatterArgs (list <string> &args)
|
||||
{
|
||||
// Match Disk Utility/Finder erase behavior by deriving a fresh exFAT layout.
|
||||
args.push_back ("-R");
|
||||
}
|
||||
|
||||
struct MacOSXFormatterDeviceOwnerRestore
|
||||
{
|
||||
MacOSXFormatterDeviceOwnerRestore (const FilesystemPath &path, const UserId &owner)
|
||||
|
||||
@@ -1136,6 +1136,9 @@ namespace VeraCrypt
|
||||
}
|
||||
|
||||
#ifdef TC_MACOSX
|
||||
if (IsMacOSXExFATFormatter (fsFormatter))
|
||||
AddMacOSXExFATFormatterArgs (args);
|
||||
|
||||
if (IsMacOSXAPFSFormatter (fsFormatter) && !useElevatedAPFSFormatter)
|
||||
AddMacOSXAPFSFormatterUserArgs (args);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user