From: Sergey Poznyakoff Date: Fri, 14 Feb 2014 08:55:26 +0000 (+0200) Subject: Use correct headers/libraries when providing xattr support X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Ftar;a=commitdiff_plain;h=48a546b02c9e2c4e72a8aa83a2e36d1b8f24536b Use correct headers/libraries when providing xattr support See https://savannah.gnu.org/patch/index.php?8252. Patch provided by Anthony G. Basile. * acinclude.m4 (TAR_HEADERS_ATTR_XATTR_H): Look for first and then for . Link against libattr.so if needed. * lib/xattr-at.h: Include sys/xattr.h or attr/xattr.h, depending on which one is detected. * src/Makefile.am [TAR_LIB_ATTR] (tar_LDADD): Link against -lattr. --- diff --git a/acinclude.m4 b/acinclude.m4 index e2dda89..3b28b3b 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -37,18 +37,40 @@ AC_DEFUN([TAR_HEADERS_ATTR_XATTR_H], [], [with_xattrs=maybe] ) - AC_CHECK_HEADERS([attr/xattr.h]) - AM_CONDITIONAL([TAR_COND_XATTR_H],[test "$ac_cv_header_attr_xattr_h" = yes]) - if test "$ac_cv_header_attr_xattr_h" = yes; then + # First check for + AC_CHECK_HEADERS([sys/xattr.h]) + AM_CONDITIONAL([TAR_COND_XATTR_H],[test "$ac_cv_header_sys_xattr_h" = yes]) + AM_CONDITIONAL([TAR_LIB_ATTR],[false]) + if test "$ac_cv_header_sys_xattr_h" = yes; then AC_CHECK_FUNCS(getxattr fgetxattr lgetxattr \ setxattr fsetxattr lsetxattr \ listxattr flistxattr llistxattr, # only when functions are present - AC_DEFINE([HAVE_ATTR_XATTR_H], [1], - [define to 1 if we have header]) + AC_DEFINE([HAVE_SYS_XATTR_H], [1], + [define to 1 if we have header]) if test "$with_xattrs" != no; then AC_DEFINE([HAVE_XATTRS],,[Define when we have working linux xattrs.]) fi ) fi + + # If is not found, then check for + if test "$ac_cv_header_sys_xattr_h" != yes; then + AC_CHECK_HEADERS([attr/xattr.h]) + AM_CONDITIONAL([TAR_COND_XATTR_H],[test "$ac_cv_header_attr_xattr_h" = yes]) + AC_CHECK_LIB([attr],[fgetxattr]) + AM_CONDITIONAL([TAR_LIB_ATTR],[test "$ac_cv_lib_attr_fgetxattr" = yes]) + if test "$ac_cv_header_attr_xattr_h" = yes; then + AC_CHECK_FUNCS(getxattr fgetxattr lgetxattr \ + setxattr fsetxattr lsetxattr \ + listxattr flistxattr llistxattr, + # only when functions are present + AC_DEFINE([HAVE_ATTR_XATTR_H], [1], + [define to 1 if we have header]) + if test "$with_xattrs" != no; then + AC_DEFINE([HAVE_XATTRS],,[Define when we have working linux xattrs.]) + fi + ) + fi + fi ]) diff --git a/lib/xattr-at.h b/lib/xattr-at.h index 1ee534d..3c6eb72 100644 --- a/lib/xattr-at.h +++ b/lib/xattr-at.h @@ -20,7 +20,15 @@ #define XATTRS_AT_H #include -#include +#if defined(HAVE_SYS_XATTR_H) +# include +#elif defined(HAVE_ATTR_XATTR_H) +# include +#endif + +#ifndef ENOATTR +# define ENOATTR ENODATA /* No such attribute */ +#endif /* These are the dir-fd-relative variants of the functions without the "at" suffix. For example, setxattrat (AT_FDCWD, path, name, value, size, diff --git a/src/Makefile.am b/src/Makefile.am index fa24b94..a9d25ef 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -51,3 +51,7 @@ AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) LDADD = ../lib/libtar.a ../gnu/libgnu.a $(LIBINTL) $(LIBICONV) tar_LDADD = $(LIBS) $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_EACCESS) $(LIB_SELINUX) + +if TAR_LIB_ATTR +tar_LDADD += -lattr +endif