Skip to content

Commit

Permalink
Check that llistxattr exists (#307)
Browse files Browse the repository at this point in the history
This PR solves
#305 "llistxattr breaks compilation on Mac OS X"
checking whether llistxattr exists or not.
  • Loading branch information
Ben RUBSON authored and rfjakob committed Apr 1, 2017
1 parent 7cc6efa commit 7295b33
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
18 changes: 14 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 if xattr functions take extra arguments, as they do on OSX.
# Output error is misleading, so do this test quietly.
include (CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET})
set (CMAKE_REQUIRED_QUIET True)
check_cxx_source_compiles ("#include <sys/types.h>
#include <sys/xattr.h>
int main() { getxattr(0,0,0,0,0,0); return 1; }
" 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.
include (CheckFuncs)
Expand Down
1 change: 1 addition & 0 deletions config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#cmakedefine HAVE_ATTR_XATTR_H
#cmakedefine HAVE_SYS_XATTR_H
#cmakedefine XATTR_ADD_OPT
#cmakedefine XATTR_LLIST

#cmakedefine HAVE_LCHMOD

Expand Down
3 changes: 3 additions & 0 deletions encfs/encfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
size_t size) {
#ifndef XATTR_LLIST
#define llistxattr listxattr
#endif
#ifdef XATTR_ADD_OPT
int options = 0;
int res = ::llistxattr(cyName.c_str(), list, size, options);
Expand Down

0 comments on commit 7295b33

Please sign in to comment.