Check that llistxattr exists (#307)

This PR solves
https://github.com/vgough/encfs/issues/305 "llistxattr breaks compilation on Mac OS X"
checking whether llistxattr exists or not.
This commit is contained in:
Ben RUBSON 2017-04-01 19:58:05 +02:00 committed by rfjakob
parent 7cc6efa60c
commit 7295b3369b
3 changed files with 18 additions and 4 deletions

View File

@ -83,15 +83,25 @@ 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)
# Check if xattr functions take extra arguments, as they do on OSX. # Check if xattr functions take extra arguments, as they do on OSX.
# Output error is misleading, so do this test quietly.
include (CheckCXXSourceCompiles) include (CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET})
set (CMAKE_REQUIRED_QUIET True)
check_cxx_source_compiles ("#include <sys/types.h> check_cxx_source_compiles ("#include <sys/types.h>
#include <sys/xattr.h> #include <sys/xattr.h>
int main() { getxattr(0,0,0,0,0,0); return 1; } int main() { getxattr(0,0,0,0,0,0); return 1; }
" XATTR_ADD_OPT) " XATTR_ADD_OPT)
set (CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE})
# Check if xattr function llistxattr exists.
include (CheckCXXSourceCompiles)
if (XATTR_ADD_OPT)
check_cxx_source_compiles ("#include <sys/types.h>
#include <sys/xattr.h>
int main() { llistxattr(0,0,0,0); return 1; }
" XATTR_LLIST)
else (XATTR_ADD_OPT)
check_cxx_source_compiles ("#include <sys/types.h>
#include <sys/xattr.h>
int main() { llistxattr(0,0,0); return 1; }
" XATTR_LLIST)
endif (XATTR_ADD_OPT)
# Check if we have some standard functions. # Check if we have some standard functions.
include (CheckFuncs) include (CheckFuncs)

View File

@ -3,6 +3,7 @@
#cmakedefine HAVE_ATTR_XATTR_H #cmakedefine HAVE_ATTR_XATTR_H
#cmakedefine HAVE_SYS_XATTR_H #cmakedefine HAVE_SYS_XATTR_H
#cmakedefine XATTR_ADD_OPT #cmakedefine XATTR_ADD_OPT
#cmakedefine XATTR_LLIST
#cmakedefine HAVE_LCHMOD #cmakedefine HAVE_LCHMOD

View File

@ -710,6 +710,9 @@ int encfs_getxattr(const char *path, const char *name, char *value,
int _do_listxattr(EncFS_Context *, const string &cyName, char *list, int _do_listxattr(EncFS_Context *, const string &cyName, char *list,
size_t size) { size_t size) {
#ifndef XATTR_LLIST
#define llistxattr listxattr
#endif
#ifdef XATTR_ADD_OPT #ifdef XATTR_ADD_OPT
int options = 0; int options = 0;
int res = ::llistxattr(cyName.c_str(), list, size, options); int res = ::llistxattr(cyName.c_str(), list, size, options);