mirror of
https://github.com/vgough/encfs.git
synced 2024-11-21 15:33:16 +01:00
Properly check for fdatasync()
This commit is contained in:
parent
11a83b85ba
commit
af6c593b38
@ -93,6 +93,12 @@ check_cxx_source_compiles ("#include <sys/types.h>
|
||||
" XATTR_ADD_OPT)
|
||||
set (CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE})
|
||||
|
||||
# Check if we have fdatasync.
|
||||
include (CheckCXXSourceCompiles)
|
||||
check_cxx_source_compiles ("#include <unistd.h>
|
||||
int main() { fdatasync(0); return 1; }
|
||||
" FDATASYNC)
|
||||
|
||||
# Check if we have some standard functions.
|
||||
include (CheckFuncs)
|
||||
check_function_exists_glibc (lchmod HAVE_LCHMOD)
|
||||
|
@ -236,15 +236,13 @@ int FileNode::sync(bool datasync) {
|
||||
int fh = io->open(O_RDONLY);
|
||||
if (fh >= 0) {
|
||||
int res = -EIO;
|
||||
#ifdef linux
|
||||
#ifdef FDATASYNC
|
||||
if (datasync)
|
||||
res = fdatasync(fh);
|
||||
else
|
||||
res = fsync(fh);
|
||||
#else
|
||||
(void)datasync;
|
||||
// no fdatasync support
|
||||
// TODO: use autoconfig to check for it..
|
||||
res = fsync(fh);
|
||||
#endif
|
||||
|
||||
|
@ -270,11 +270,13 @@ int RawFileIO::truncate(off_t size) {
|
||||
knownSize = true;
|
||||
}
|
||||
|
||||
#if !defined(__FreeBSD__) && !defined(__APPLE__)
|
||||
if (fd >= 0 && canWrite) {
|
||||
#ifdef FDATASYNC
|
||||
::fdatasync(fd);
|
||||
}
|
||||
#else
|
||||
::fsync(fd);
|
||||
#endif
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user