Suggested by @MarcoFalke after #14627 and possibly #14420. We should warn if an unrecognised/incorrect section is present in bitcoin.conf. i.e `[testnet]` is present instead of `[test]`.
{
    std::lock_guard<std::mutex> ulock(cs_dir_locks);
    fs::path pathLockFile = directory / lockfile_name;
    
    if (dir_locks.count(pathLockFile.string())) {
        return true;
    }
    
    FILE* file = fsbridge::fopen(pathLockFile, "a");
    if (file) fclose(file);
    auto lock = MakeUnique<fsbridge::FileLock>(pathLockFile);
    if (!lock->TryLock()) {
        return error("Error while attempting to lock directory %s: %s", directory.string(), lock->GetReason());
    }
    if (!probe_only) {
        
        dir_locks.emplace(pathLockFile.string(), std::move(lock));
    }
    return true;
}
void ReleaseDirectoryLocks()
{
    std::lock_guard<std::mutex> ulock(cs_dir_locks);
    dir_locks.clear();
}
bool DirIsWritable(const fs::path& directory)