diff --git a/configure.ac b/configure.ac index 5db210f..76f03ee 100644 --- a/configure.ac +++ b/configure.ac @@ -92,6 +92,28 @@ dnl fuse_operations.setxattr was added 2004-03-31 dnl only enable it if setxattr function is found.. AC_CHECK_HEADERS([attr/xattr.h sys/xattr.h]) +# Do xattr functions take additional options like on Darwin? +AC_CACHE_CHECK([whether xattr interface takes additional options], + smb_attr_cv_xattr_add_opt, [ + old_LIBS=$LIBS + LIBS="$LIBS $ACL_LIBS" + AC_TRY_COMPILE([ + #include + #if HAVE_ATTR_XATTR_H + #include + #elif HAVE_SYS_XATTR_H + #include + #endif + ],[ + getxattr(0, 0, 0, 0, 0, 0); + ], + [smb_attr_cv_xattr_add_opt=yes], + [smb_attr_cv_xattr_add_opt=no;LIBS=$old_LIBS]) +]) +if test x"$smb_attr_cv_xattr_add_opt" = x"yes"; then + AC_DEFINE(XATTR_ADD_OPT, 1, [xattr functions have additional options]) +fi + dnl Check for valgrind headers.. AC_CHECK_HEADERS([valgrind/valgrind.h valgrind/memcheck.h]) diff --git a/encfs/encfs.cpp b/encfs/encfs.cpp index 26c6fa9..bd16f6f 100644 --- a/encfs/encfs.cpp +++ b/encfs/encfs.cpp @@ -698,8 +698,15 @@ int encfs_statfs(const char *path, struct statvfs *st) int _do_setxattr(EncFS_Context *, const string &cyName, tuple data) { +#ifdef XATTR_ADD_OPT + int options = 0; + // flags argument is ignored.. + int res = ::setxattr( cyName.c_str(), data.get<0>(), data.get<1>(), + data.get<2>(), 0, options ); +#else int res = ::setxattr( cyName.c_str(), data.get<0>(), data.get<1>(), data.get<2>(), data.get<3>() ); +#endif return (res == -1) ? -errno : res; } @@ -713,8 +720,14 @@ int encfs_setxattr( const char *path, const char *name, int _do_getxattr(EncFS_Context *, const string &cyName, tuple data) { +#ifdef XATTR_ADD_OPT + int options = 0; + int res = ::getxattr( cyName.c_str(), data.get<0>(), + data.get<1>(), data.get<2>(), 0, options); +#else int res = ::getxattr( cyName.c_str(), data.get<0>(), data.get<1>(), data.get<2>()); +#endif return (res == -1) ? -errno : res; } @@ -728,7 +741,13 @@ int encfs_getxattr( const char *path, const char *name, int _do_listxattr(EncFS_Context *, const string &cyName, tuple data) { +#ifdef XATTR_ADD_OPT + int options = 0; + int res = ::listxattr( cyName.c_str(), data.get<0>(), data.get<1>(), + options ); +#else int res = ::listxattr( cyName.c_str(), data.get<0>(), data.get<1>() ); +#endif return (res == -1) ? -errno : res; } @@ -740,7 +759,12 @@ int encfs_listxattr( const char *path, char *list, size_t size ) int _do_removexattr(EncFS_Context *, const string &cyName, const char *name) { +#ifdef XATTR_ADD_OPT + int options = 0; + int res = ::removexattr( cyName.c_str(), name, options ); +#else int res = ::removexattr( cyName.c_str(), name ); +#endif return (res == -1) ? -errno : res; }