From: Björn Jacke Date: Fri, 18 Feb 2011 02:05:13 +0000 (-0500) Subject: add AIX extended attribute support X-Git-Tag: v3.0.0a~683 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d621852cf4a614f986e151d67b39efcf09ae37f;p=thirdparty%2Flibarchive.git add AIX extended attribute support SVN-Revision: 2985 --- diff --git a/libarchive/archive_read_disk_entry_from_file.c b/libarchive/archive_read_disk_entry_from_file.c index bd0db430f..f7dcca183 100644 --- a/libarchive/archive_read_disk_entry_from_file.c +++ b/libarchive/archive_read_disk_entry_from_file.c @@ -49,6 +49,9 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_read_disk_entry_from_file.c 2010 #ifdef HAVE_SYS_XATTR_H #include #endif +#ifdef HAVE_SYS_XATTR_H +#include +#endif #ifdef HAVE_ACL_LIBACL_H #include #endif @@ -484,11 +487,12 @@ setup_acls_posix1e(struct archive_read_disk *a, } #endif -#if HAVE_FGETXATTR && HAVE_FLISTXATTR && HAVE_LISTXATTR && \ - HAVE_LLISTXATTR && HAVE_GETXATTR && HAVE_LGETXATTR +#if (HAVE_FGETXATTR && HAVE_FLISTXATTR && HAVE_LISTXATTR && \ + HAVE_LLISTXATTR && HAVE_GETXATTR && HAVE_LGETXATTR) || \ + (HAVE_FGETEA && HAVE_FLISTEA && HAVE_LISTEA) /* - * Linux extended attribute support. + * Linux and AIX extended attribute support. * * TODO: By using a stack-allocated buffer for the first * call to getxattr(), we might be able to avoid the second @@ -511,12 +515,21 @@ setup_xattr(struct archive_read_disk *a, if (accpath == NULL) accpath = archive_entry_pathname(entry); +#if HAVE_FGETXATTR if (fd >= 0) size = fgetxattr(fd, name, NULL, 0); else if (!a->follow_symlinks) size = lgetxattr(accpath, name, NULL, 0); else size = getxattr(accpath, name, NULL, 0); +#elif HAVE_FGETEA + if (fd >= 0) + size = fgetea(fd, name, NULL, 0); + else if (!a->follow_symlinks) + size = lgetea(accpath, name, NULL, 0); + else + size = getea(accpath, name, NULL, 0); +#endif if (size == -1) { archive_set_error(&a->archive, errno, @@ -529,12 +542,21 @@ setup_xattr(struct archive_read_disk *a, return (ARCHIVE_FATAL); } +#if HAVE_FGETXATTR if (fd >= 0) size = fgetxattr(fd, name, value, size); else if (!a->follow_symlinks) size = lgetxattr(accpath, name, value, size); else size = getxattr(accpath, name, value, size); +#elif HAVE_FGETEA + if (fd >= 0) + size = fgetea(fd, name, value, size); + else if (!a->follow_symlinks) + size = lgetea(accpath, name, value, size); + else + size = getea(accpath, name, value, size); +#endif if (size == -1) { archive_set_error(&a->archive, errno, @@ -560,12 +582,21 @@ setup_xattrs(struct archive_read_disk *a, if (path == NULL) path = archive_entry_pathname(entry); +#if HAVE_FLISTXATTR if (fd >= 0) list_size = flistxattr(fd, NULL, 0); else if (!a->follow_symlinks) list_size = llistxattr(path, NULL, 0); else list_size = listxattr(path, NULL, 0); +#elif HAVE_FLISTEA + if (fd >= 0) + list_size = flistea(fd, NULL, 0); + else if (!a->follow_symlinks) + list_size = llistea(path, NULL, 0); + else + list_size = listea(path, NULL, 0); +#endif if (list_size == -1) { if (errno == ENOTSUP || errno == ENOSYS) @@ -583,12 +614,21 @@ setup_xattrs(struct archive_read_disk *a, return (ARCHIVE_FATAL); } +#if HAVE_FLISTXATTR if (fd >= 0) list_size = flistxattr(fd, list, list_size); else if (!a->follow_symlinks) list_size = llistxattr(path, list, list_size); else list_size = listxattr(path, list, list_size); +#elif HAVE_FLISTEA + if (fd >= 0) + list_size = flistea(fd, list, list_size); + else if (!a->follow_symlinks) + list_size = llistea(path, list, list_size); + else + list_size = listea(path, list, list_size); +#endif if (list_size == -1) { archive_set_error(&a->archive, errno, diff --git a/libarchive/archive_write_disk.c b/libarchive/archive_write_disk.c index eb413ba52..af42b250e 100644 --- a/libarchive/archive_write_disk.c +++ b/libarchive/archive_write_disk.c @@ -39,6 +39,9 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_write_disk.c 201159 2009-12-29 0 #ifdef HAVE_SYS_XATTR_H #include #endif +#ifdef HAVE_SYS_XATTR_H +#include +#endif #ifdef HAVE_ATTR_XATTR_H #include #endif @@ -2743,9 +2746,10 @@ set_acl(struct archive_write_disk *a, int fd, const char *name, } #endif -#if HAVE_LSETXATTR +#if HAVE_LSETXATTR || HAVE_LSETEA /* - * Restore extended attributes - Linux implementation + * Restore extended attributes - Linux and AIX implementations: + * AIX' ea interface is syntaxwise identical to the Linux xattr interface. */ static int set_xattrs(struct archive_write_disk *a) @@ -2768,10 +2772,19 @@ set_xattrs(struct archive_write_disk *a) if (a->fd >= 0) e = fsetxattr(a->fd, name, value, size, 0); else +#elif HAVE_FSETEA + if (a->fd >= 0) + e = fsetea(a->fd, name, value, size, 0); + else #endif { +#if HAVE_LSETXATTR e = lsetxattr(archive_entry_pathname(entry), name, value, size, 0); +#elif HAVE_LSETEA + e = lsetea(archive_entry_pathname(entry), + name, value, size, 0); +#endif } if (e == -1) { if (errno == ENOTSUP || errno == ENOSYS) {