From f083b503de5dd5ae1805e633e191532a10896eab Mon Sep 17 00:00:00 2001 From: "Erich E. Hoover" Date: Mon, 6 Oct 2014 14:21:11 -0600 Subject: libport: Add support for Mac OS X style extended attributes. --- configure.ac | 3 +++ libs/port/xattr.c | 27 +++++++++++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 3c91af3..68dca0a 100644 --- a/configure.ac +++ b/configure.ac @@ -671,6 +671,9 @@ AC_CHECK_HEADERS([libprocstat.h],,, if test "x$with_xattr" != "xno" then AC_CHECK_HEADERS(attr/xattr.h, [HAVE_XATTR=1]) + AC_CHECK_HEADERS(sys/xattr.h, [HAVE_XATTR=1] + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[getxattr("", "", "", 0, 0, 0);]])], + [AC_DEFINE(XATTR_ADDITIONAL_OPTIONS, 1, [Define if xattr functions take additional arguments (Mac OS X)])])]) fi if test "x$with_xattr" = "xyes" then diff --git a/libs/port/xattr.c b/libs/port/xattr.c index 683e7a6..efc65c5 100644 --- a/libs/port/xattr.c +++ b/libs/port/xattr.c @@ -22,7 +22,10 @@ #include "wine/port.h" #if defined(HAVE_ATTR_XATTR_H) +# undef XATTR_ADDITIONAL_OPTIONS # include +#elif defined(HAVE_SYS_XATTR_H) +# include #endif #include @@ -30,7 +33,9 @@ int xattr_fget( int filedes, const char *name, void *value, size_t size ) { -#if defined(HAVE_ATTR_XATTR_H) +#if defined(XATTR_ADDITIONAL_OPTIONS) + return fgetxattr( filedes, name, value, size, 0, 0 ); +#elif defined(HAVE_SYS_XATTR_H) || defined(HAVE_ATTR_XATTR_H) return fgetxattr( filedes, name, value, size ); #else errno = ENOSYS; @@ -40,7 +45,9 @@ int xattr_fget( int filedes, const char *name, void *value, size_t size ) int xattr_fremove( int filedes, const char *name ) { -#if defined(HAVE_ATTR_XATTR_H) +#if defined(XATTR_ADDITIONAL_OPTIONS) + return fremovexattr( filedes, name, 0 ); +#elif defined(HAVE_SYS_XATTR_H) || defined(HAVE_ATTR_XATTR_H) return fremovexattr( filedes, name ); #else errno = ENOSYS; @@ -50,7 +57,9 @@ int xattr_fremove( int filedes, const char *name ) int xattr_fset( int filedes, const char *name, void *value, size_t size ) { -#if defined(HAVE_ATTR_XATTR_H) +#if defined(XATTR_ADDITIONAL_OPTIONS) + return fsetxattr( filedes, name, value, size, 0, 0 ); +#elif defined(HAVE_SYS_XATTR_H) || defined(HAVE_ATTR_XATTR_H) return fsetxattr( filedes, name, value, size, 0 ); #else errno = ENOSYS; @@ -60,7 +69,9 @@ int xattr_fset( int filedes, const char *name, void *value, size_t size ) int xattr_get( const char *path, const char *name, void *value, size_t size ) { -#if defined(HAVE_ATTR_XATTR_H) +#if defined(XATTR_ADDITIONAL_OPTIONS) + return getxattr( path, name, value, size, 0, 0 ); +#elif defined(HAVE_SYS_XATTR_H) || defined(HAVE_ATTR_XATTR_H) return getxattr( path, name, value, size ); #else errno = ENOSYS; @@ -70,7 +81,9 @@ int xattr_get( const char *path, const char *name, void *value, size_t size ) int xattr_remove( const char *path, const char *name ) { -#if defined(HAVE_ATTR_XATTR_H) +#if defined(XATTR_ADDITIONAL_OPTIONS) + return removexattr( path, name, 0 ); +#elif defined(HAVE_SYS_XATTR_H) || defined(HAVE_ATTR_XATTR_H) return removexattr( path, name ); #else errno = ENOSYS; @@ -80,7 +93,9 @@ int xattr_remove( const char *path, const char *name ) int xattr_set( const char *path, const char *name, void *value, size_t size ) { -#if defined(HAVE_ATTR_XATTR_H) +#if defined(XATTR_ADDITIONAL_OPTIONS) + return setxattr( path, name, value, size, 0, 0 ); +#elif defined(HAVE_SYS_XATTR_H) || defined(HAVE_ATTR_XATTR_H) return setxattr( path, name, value, size, 0 ); #else errno = ENOSYS; -- 1.9.1