mirror of
https://github.com/vgough/encfs.git
synced 2024-11-25 09:23:13 +01:00
replace most compile-time platform checks with build-time checks
This commit is contained in:
parent
dcc7ff83ed
commit
6c7ad3e534
@ -60,6 +60,12 @@ if (APPLE)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (WIN32 OR APPLE)
|
||||||
|
set(DEFAULT_CASE_INSENSITIVE TRUE)
|
||||||
|
else()
|
||||||
|
set(DEFAULT_CASE_INSENSITIVE FALSE)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Check for FUSE.
|
# Check for FUSE.
|
||||||
find_package (FUSE REQUIRED)
|
find_package (FUSE REQUIRED)
|
||||||
include_directories (${FUSE_INCLUDE_DIR})
|
include_directories (${FUSE_INCLUDE_DIR})
|
||||||
@ -76,6 +82,9 @@ include (CheckIncludeFileCXX)
|
|||||||
check_include_file_cxx (attr/xattr.h HAVE_ATTR_XATTR_H)
|
check_include_file_cxx (attr/xattr.h HAVE_ATTR_XATTR_H)
|
||||||
check_include_file_cxx (sys/xattr.h HAVE_SYS_XATTR_H)
|
check_include_file_cxx (sys/xattr.h HAVE_SYS_XATTR_H)
|
||||||
|
|
||||||
|
include(CheckStructHasMember)
|
||||||
|
check_struct_has_member(dirent d_type dirent.h HAVE_DIRENT_D_TYPE LANGUAGE CXX)
|
||||||
|
|
||||||
# Check if xattr functions take extra arguments, as they do on OSX.
|
# Check if xattr functions take extra arguments, as they do on OSX.
|
||||||
include (CheckCXXSourceCompiles)
|
include (CheckCXXSourceCompiles)
|
||||||
check_cxx_source_compiles ("#include <sys/types.h>
|
check_cxx_source_compiles ("#include <sys/types.h>
|
||||||
@ -87,6 +96,7 @@ check_cxx_source_compiles ("#include <sys/types.h>
|
|||||||
include (CheckFuncs)
|
include (CheckFuncs)
|
||||||
check_function_exists_glibc (lchmod HAVE_LCHMOD)
|
check_function_exists_glibc (lchmod HAVE_LCHMOD)
|
||||||
check_function_exists_glibc (utimensat HAVE_UTIMENSAT)
|
check_function_exists_glibc (utimensat HAVE_UTIMENSAT)
|
||||||
|
check_function_exists_glibc (fdatasync HAVE_FDATASYNC)
|
||||||
|
|
||||||
set (CMAKE_THREAD_PREFER_PTHREAD)
|
set (CMAKE_THREAD_PREFER_PTHREAD)
|
||||||
find_package (Threads REQUIRED)
|
find_package (Threads REQUIRED)
|
||||||
|
@ -6,6 +6,11 @@
|
|||||||
#cmakedefine XATTR_LLIST
|
#cmakedefine XATTR_LLIST
|
||||||
|
|
||||||
#cmakedefine HAVE_LCHMOD
|
#cmakedefine HAVE_LCHMOD
|
||||||
|
#cmakedefine HAVE_FDATASYNC
|
||||||
|
|
||||||
|
#cmakedefine HAVE_DIRENT_D_TYPE
|
||||||
|
|
||||||
|
#cmakedefine DEFAULT_CASE_INSENSITIVE
|
||||||
|
|
||||||
/* TODO: add other thread library support. */
|
/* TODO: add other thread library support. */
|
||||||
#cmakedefine CMAKE_USE_PTHREADS_INIT
|
#cmakedefine CMAKE_USE_PTHREADS_INIT
|
||||||
|
@ -72,7 +72,7 @@ static bool _nextName(struct dirent *&de, const std::shared_ptr<DIR> &dir,
|
|||||||
|
|
||||||
if (de != nullptr) {
|
if (de != nullptr) {
|
||||||
if (fileType != nullptr) {
|
if (fileType != nullptr) {
|
||||||
#if defined(_DIRENT_HAVE_D_TYPE) || defined(__FreeBSD__) || defined(__APPLE__)
|
#if defined(HAVE_DIRENT_D_TYPE)
|
||||||
*fileType = de->d_type;
|
*fileType = de->d_type;
|
||||||
#else
|
#else
|
||||||
#warning "struct dirent.d_type not supported"
|
#warning "struct dirent.d_type not supported"
|
||||||
@ -430,7 +430,7 @@ bool DirNode::genRenameList(list<RenameEl> &renameList, const char *fromP,
|
|||||||
ren.newPName = string(toP) + '/' + plainName;
|
ren.newPName = string(toP) + '/' + plainName;
|
||||||
|
|
||||||
bool isDir;
|
bool isDir;
|
||||||
#if defined(_DIRENT_HAVE_D_TYPE)
|
#if defined(HAVE_DIRENT_D_TYPE)
|
||||||
if (de->d_type != DT_UNKNOWN) {
|
if (de->d_type != DT_UNKNOWN) {
|
||||||
isDir = (de->d_type == DT_DIR);
|
isDir = (de->d_type == DT_DIR);
|
||||||
} else
|
} else
|
||||||
|
@ -1035,7 +1035,7 @@ RootPtr createV6Config(EncFS_Context *ctx,
|
|||||||
alg = findCipherAlgorithm("AES", keySize);
|
alg = findCipherAlgorithm("AES", keySize);
|
||||||
|
|
||||||
// If case-insensitive system, opt for Block32 filename encoding
|
// If case-insensitive system, opt for Block32 filename encoding
|
||||||
#if defined(__APPLE__) || defined(WIN32)
|
#if DEFAULT_CASE_INSENSITIVE
|
||||||
nameIOIface = BlockNameIO::CurrentInterface(true);
|
nameIOIface = BlockNameIO::CurrentInterface(true);
|
||||||
#else
|
#else
|
||||||
nameIOIface = BlockNameIO::CurrentInterface();
|
nameIOIface = BlockNameIO::CurrentInterface();
|
||||||
|
@ -257,9 +257,6 @@ int RawFileIO::truncate(off_t size) {
|
|||||||
|
|
||||||
if (fd >= 0 && canWrite) {
|
if (fd >= 0 && canWrite) {
|
||||||
res = ::ftruncate(fd, size);
|
res = ::ftruncate(fd, size);
|
||||||
#if !defined(__FreeBSD__) && !defined(__APPLE__)
|
|
||||||
::fdatasync(fd);
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
res = ::truncate(name.c_str(), size);
|
res = ::truncate(name.c_str(), size);
|
||||||
}
|
}
|
||||||
@ -276,6 +273,14 @@ int RawFileIO::truncate(off_t size) {
|
|||||||
knownSize = true;
|
knownSize = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fd >= 0 && canWrite) {
|
||||||
|
#if defined(HAVE_FDATASYNC)
|
||||||
|
::fdatasync(fd);
|
||||||
|
#else
|
||||||
|
::fsync(fd);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user