check for windows NTFS compression on monerod startup

This commit is contained in:
eversinc33 2024-12-29 22:23:32 +01:00
parent 941ecefab2
commit d9dbc49f3b

View file

@ -120,6 +120,18 @@ bool isFat32(const wchar_t* root_path)
return wcscmp(L"FAT32", &fs[0]) == 0;
}
bool isNtfsCompressed(const wchar_t* file_path)
{
DWORD file_attributes = ::GetFileAttributesW(file_path);
if (file_attributes == INVALID_FILE_ATTRIBUTES)
{
MERROR("Failed to get '" << file_path << "' file attributes. Error code: " << ::GetLastError());
return false;
}
return file_attributes & FILE_ATTRIBUTE_COMPRESSED;
}
#endif
int main(int argc, char const * argv[])
@ -262,6 +274,21 @@ int main(int argc, char const * argv[])
{
MERROR("Data directory resides on FAT32 volume that has 4GiB file size limit, blockchain might get corrupted.");
}
// Check for NTFS compression on both the data folder and the lmdb folder
// Compression can corrupt the blockchain on disk
if (isNtfsCompressed(data_dir.c_str()))
{
MERROR("Data directory is using NTFS compression, blockchain might get corrupted.");
}
bf::path db_path {bf::path(data_dir) / "lmdb"};
if (bf::exists(db_path))
{
if (isNtfsCompressed(db_path.c_str()))
{
MERROR("Database directory is using NTFS compression, blockchain might get corrupted.");
}
}
#endif
// FIXME: not sure on windows implementation default, needs further review