diff --git a/src/config/CMakeLists.txt b/src/config/CMakeLists.txt --- a/src/config/CMakeLists.txt +++ b/src/config/CMakeLists.txt @@ -134,6 +134,8 @@ check_symbol_exists(getifaddrs "sys/types.h;ifaddrs.h" HAVE_DECL_GETIFADDRS) check_symbol_exists(freeifaddrs "sys/types.h;ifaddrs.h" HAVE_DECL_FREEIFADDRS) +check_symbol_exists(fdatasync "unistd.h" HAVE_FDATASYNC) + check_cxx_source_compiles(" #include /* for syscall */ #include /* for SYS_getrandom */ diff --git a/src/util/system.cpp b/src/util/system.cpp --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -3,6 +3,10 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#if defined(HAVE_CONFIG_H) +#include // For HAVE_FDATASYNC +#endif + #include #include @@ -1141,7 +1145,7 @@ return false; } #else -#if defined(HAVE_FDATASYNC) +#if HAVE_FDATASYNC // Ignore EINVAL for filesystems that don't support sync if (fdatasync(fileno(file)) != 0 && errno != EINVAL) { LogPrintf("%s: fdatasync failed: %d\n", __func__, errno);