util: detect and warn when using exFAT on macOS

exFAT is known to cause corruption on macOS. See #28552.

Therefore we should warn when using this fs format for either the blocks
or data directories on macOS.

Co-authored-by: l0rinc <pap.lorinc@gmail.com>
This commit is contained in:
willcl-ark
2024-12-05 22:06:13 +00:00
committed by will
parent 2bb06bcaf2
commit db3228042b
4 changed files with 61 additions and 0 deletions

View File

@@ -1866,6 +1866,26 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
}
}
#ifdef __APPLE__
auto check_and_warn_fs{[&](const fs::path& path, std::string_view desc) {
const auto path_desc{strprintf("%s (\"%s\")", desc, fs::PathToString(path))};
switch (GetFilesystemType(path)) {
case FSType::EXFAT:
InitWarning(strprintf(_("The %s path uses exFAT, which is known to have intermittent corruption problems on macOS. "
"Move this directory to a different filesystem to avoid data loss."), path_desc));
break;
case FSType::ERROR:
LogInfo("Failed to detect filesystem type for %s", path_desc);
break;
case FSType::OTHER:
break;
}
}};
check_and_warn_fs(args.GetDataDirNet(), "data directory");
check_and_warn_fs(args.GetBlocksDirPath(), "blocks directory");
#endif
#if HAVE_SYSTEM
const std::string block_notify = args.GetArg("-blocknotify", "");
if (!block_notify.empty()) {