From: "Erich E. Hoover" erich.e.hoover@gmail.com
Co-authored-by: Joel Holdsworth joel@airwebreathe.org.uk Signed-off-by: Joel Holdsworth joel@airwebreathe.org.uk --- configure | 28 ++++++++++++++++++++++++++++ configure.ac | 3 +++ dlls/ntdll/unix/file.c | 19 +++++++++++++++---- include/config.h.in | 6 ++++++ 4 files changed, 52 insertions(+), 4 deletions(-)
diff --git a/configure b/configure index 9c6fb443e1f..46f576c3b14 100755 --- a/configure +++ b/configure @@ -9114,6 +9114,34 @@ then : HAVE_XATTR=1 fi
+done + for ac_header in sys/xattr.h +do : + ac_fn_c_check_header_compile "$LINENO" "sys/xattr.h" "ac_cv_header_sys_xattr_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_xattr_h" = xyes +then : + printf "%s\n" "#define HAVE_SYS_XATTR_H 1" >>confdefs.h + HAVE_XATTR=1 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <sys/xattr.h> +int +main (void) +{ +getxattr("", "", "", 0, 0, 0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + +printf "%s\n" "#define XATTR_ADDITIONAL_OPTIONS 1" >>confdefs.h + +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + done
diff --git a/configure.ac b/configure.ac index fd59bd6948d..2bd616d4e02 100644 --- a/configure.ac +++ b/configure.ac @@ -636,6 +636,9 @@ AC_CHECK_HEADERS([libprocstat.h],,, #endif])
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 <sys/xattr.h>]], [[getxattr("", "", "", 0, 0, 0);]])], + [AC_DEFINE(XATTR_ADDITIONAL_OPTIONS, 1, [Define if xattr functions take additional arguments (Mac OS X)])])])
dnl **** Check for working dll ****
diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c index b20d5d1818f..759b51d4de7 100644 --- a/dlls/ntdll/unix/file.c +++ b/dlls/ntdll/unix/file.c @@ -99,7 +99,10 @@ #include <sys/statfs.h> #endif #ifdef HAVE_ATTR_XATTR_H +#undef XATTR_ADDITIONAL_OPTIONS #include <attr/xattr.h> +#elif defined(HAVE_SYS_XATTR_H) +#include <sys/xattr.h> #endif #include <time.h> #include <unistd.h> @@ -364,7 +367,9 @@ NTSTATUS errno_to_status( int err )
static 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; @@ -375,7 +380,9 @@ static int xattr_fremove( int filedes, const char *name )
static 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; @@ -386,7 +393,9 @@ static int xattr_fset( int filedes, const char *name, void *value, size_t size )
static 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; @@ -397,7 +406,9 @@ static int xattr_get( const char *path, const char *name, void *value, size_t si
static 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; diff --git a/include/config.h.in b/include/config.h.in index 25f09636b3a..f6988317641 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -682,6 +682,9 @@ /* Define to 1 if you have the <sys/vnode.h> header file. */ #undef HAVE_SYS_VNODE_H
+/* Define to 1 if you have the <sys/xattr.h> header file. */ +#undef HAVE_SYS_XATTR_H + /* Define to 1 if you have the `tcdrain' function. */ #undef HAVE_TCDRAIN
@@ -891,6 +894,9 @@ backward compatibility; new code need not use it. */ #undef STDC_HEADERS
+/* Define if xattr functions take additional arguments (Mac OS X) */ +#undef XATTR_ADDITIONAL_OPTIONS + /* Define to 1 if the X Window System is missing or not being used. */ #undef X_DISPLAY_MISSING