mirror of
https://github.com/vgough/encfs.git
synced 2025-06-21 04:08:04 +02: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)
|
" XATTR_ADD_OPT)
|
||||||
set (CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE})
|
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.
|
# Check if we have some standard functions.
|
||||||
include (CheckFuncs)
|
include (CheckFuncs)
|
||||||
check_function_exists_glibc (lchmod HAVE_LCHMOD)
|
check_function_exists_glibc (lchmod HAVE_LCHMOD)
|
||||||
|
@ -236,15 +236,13 @@ int FileNode::sync(bool datasync) {
|
|||||||
int fh = io->open(O_RDONLY);
|
int fh = io->open(O_RDONLY);
|
||||||
if (fh >= 0) {
|
if (fh >= 0) {
|
||||||
int res = -EIO;
|
int res = -EIO;
|
||||||
#ifdef linux
|
#ifdef FDATASYNC
|
||||||
if (datasync)
|
if (datasync)
|
||||||
res = fdatasync(fh);
|
res = fdatasync(fh);
|
||||||
else
|
else
|
||||||
res = fsync(fh);
|
res = fsync(fh);
|
||||||
#else
|
#else
|
||||||
(void)datasync;
|
(void)datasync;
|
||||||
// no fdatasync support
|
|
||||||
// TODO: use autoconfig to check for it..
|
|
||||||
res = fsync(fh);
|
res = fsync(fh);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -270,11 +270,13 @@ int RawFileIO::truncate(off_t size) {
|
|||||||
knownSize = true;
|
knownSize = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(__FreeBSD__) && !defined(__APPLE__)
|
|
||||||
if (fd >= 0 && canWrite) {
|
if (fd >= 0 && canWrite) {
|
||||||
|
#ifdef FDATASYNC
|
||||||
::fdatasync(fd);
|
::fdatasync(fd);
|
||||||
}
|
#else
|
||||||
|
::fsync(fd);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user