diff --git a/src/io/FileOutputStream.cxx b/src/io/FileOutputStream.cxx index ec573b5f3..a7cd50fe3 100644 --- a/src/io/FileOutputStream.cxx +++ b/src/io/FileOutputStream.cxx @@ -252,7 +252,12 @@ FileOutputStream::Sync() { assert(IsDefined()); - if (fdatasync(fd.Get()) < 0) +#ifdef __linux__ + const bool success = fdatasync(fd.Get()) == 0; +#else + const bool success = fsync(fd.Get()) == 0; +#endif + if (!success) throw FormatErrno("Failed to sync %s", GetPath().c_str()); }