check for additional arguments to xattr functions

git-svn-id: http://encfs.googlecode.com/svn/trunk@12 db9cf616-1c43-0410-9cb8-a902689de0d6
This commit is contained in:
Valient Gough 2008-04-11 08:36:32 +00:00
parent e8e2a6a610
commit 931dcdd2af
2 changed files with 46 additions and 0 deletions

View File

@ -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 <sys/types.h>
#if HAVE_ATTR_XATTR_H
#include <attr/xattr.h>
#elif HAVE_SYS_XATTR_H
#include <sys/xattr.h>
#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])

View File

@ -698,8 +698,15 @@ int encfs_statfs(const char *path, struct statvfs *st)
int _do_setxattr(EncFS_Context *, const string &cyName,
tuple<const char *, const char *, size_t, int> 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<const char *, void *, size_t> 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<char *, size_t> 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;
}