-+#endif
-
- maybe_emit_filelist_progress(flist->count + flist_count_offset);
-
-@@ -1006,11 +1024,19 @@ static struct file_struct *send_file_nam
- if (preserve_acls)
- send_acl(&sx, f);
- #endif
-+#ifdef SUPPORT_XATTRS
-+ if (preserve_xattrs)
-+ send_xattr(&sx, f);
-+#endif
- } else {
- #ifdef SUPPORT_ACLS
- if (preserve_acls)
- free_acl(&sx);
- #endif
-+#ifdef SUPPORT_XATTRS
-+ if (preserve_xattrs)
-+ free_xattr(&sx);
-+#endif
- }
- return file;
- }
---- old/lib/sysxattr.c
-+++ new/lib/sysxattr.c
-@@ -0,0 +1,61 @@
-+/*
-+ * Extended attribute support for rsync.
-+ *
-+ * Copyright (C) 2004 Red Hat, Inc.
-+ * Written by Jay Fenlason.
-+ *
-+ * This program is free software; you can redistribute it and/or modify
-+ * it under the terms of the GNU General Public License as published by
-+ * the Free Software Foundation; either version 2 of the License, or
-+ * (at your option) any later version.
-+ *
-+ * This program is distributed in the hope that it will be useful,
-+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-+ * GNU General Public License for more details.
-+ *
-+ * You should have received a copy of the GNU General Public License along
-+ * with this program; if not, write to the Free Software Foundation, Inc.,
-+ * 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
-+ */
-+
-+#include "rsync.h"
-+#include "sysxattr.h"
-+
-+#if defined HAVE_LINUX_XATTRS
-+
-+ssize_t sys_lgetxattr(const char *path, const char *name, void *value, size_t size)
-+{
-+ return lgetxattr(path, name, value, size);
-+}
-+
-+int sys_lsetxattr(const char *path, const char *name, const void *value, size_t size, int flags)
-+{
-+ return lsetxattr(path, name, value, size, flags);
-+}
-+
-+ssize_t sys_llistxattr(const char *path, char *list, size_t size)
-+{
-+ return llistxattr(path, list, size);
-+}
-+
-+#elif HAVE_OSX_XATTRS
-+
-+ssize_t sys_lgetxattr(const char *path, const char *name, void *value, size_t size)
-+{
-+ return getxattr(path, name, value, size, 0, XATTR_NOFOLLOW);
-+}
-+
-+int sys_lsetxattr(const char *path, const char *name, const void *value, size_t size, int flags)
-+{
-+ return setxattr(path, name, value, size, 0, XATTR_NOFOLLOW | flags);
-+}
-+
-+ssize_t sys_llistxattr(const char *path, char *list, size_t size)
-+{
-+ return listxattr(path, list, size, XATTR_NOFOLLOW);
-+}
-+
-+#else
-+
-+#endif /* No xattrs */
---- old/lib/sysxattr.h
-+++ new/lib/sysxattr.h
-@@ -0,0 +1,19 @@
-+#ifdef SUPPORT_XATTRS
-+#if defined HAVE_ATTR_XATTR_H
-+#include <attr/xattr.h>
-+#elif defined HAVE_SYS_XATTR_H
-+#include <sys/xattr.h>
-+#endif
-+#endif
-+
-+#if defined HAVE_LINUX_XATTRS || defined HAVE_OSX_XATTRS
-+
-+ssize_t sys_lgetxattr(const char *path, const char *name, void *value, size_t size);
-+int sys_lsetxattr(const char *path, const char *name, const void *value, size_t size, int flags);
-+ssize_t sys_llistxattr(const char *path, char *list, size_t size);
-+
-+#else
-+
-+/* No xattrs */
-+
-+#endif
---- old/options.c
-+++ new/options.c
-@@ -48,6 +48,7 @@ int copy_links = 0;
- int preserve_links = 0;
- int preserve_hard_links = 0;
- int preserve_acls = 0;
-+int preserve_xattrs = 0;
- int preserve_perms = 0;
- int preserve_executability = 0;
- int preserve_devices = 0;
-@@ -201,6 +202,7 @@ static void print_rsync_version(enum log
- char const *have_inplace = "no ";
- char const *hardlinks = "no ";
- char const *acls = "no ";
-+ char const *xattrs = "no ";
- char const *links = "no ";
- char const *ipv6 = "no ";
- STRUCT_STAT *dumstat;
-@@ -220,7 +222,9 @@ static void print_rsync_version(enum log
- #ifdef SUPPORT_ACLS
- acls = "";
- #endif
--
-+#ifdef SUPPORT_XATTRS
-+ xattrs = "";
-+#endif
- #ifdef SUPPORT_LINKS
- links = "";
- #endif
-@@ -234,9 +238,9 @@ static void print_rsync_version(enum log
- rprintf(f, "Copyright (C) 1996-2006 by Andrew Tridgell, Wayne Davison, and others.\n");
- rprintf(f, "<http://rsync.samba.org/>\n");
- rprintf(f, "Capabilities: %d-bit files, %ssocketpairs, "
-- "%shard links, %sACLs, %ssymlinks, batchfiles,\n",
-+ "%shard links, %sACLs, %sxattrs, %ssymlinks, batchfiles,\n",
- (int) (sizeof (OFF_T) * 8),
-- got_socketpair, hardlinks, acls, links);
-+ got_socketpair, hardlinks, acls, xattrs, links);
-
- /* Note that this field may not have type ino_t. It depends
- * on the complicated interaction between largefile feature
-@@ -290,7 +294,7 @@ void usage(enum logcode F)
- rprintf(F," -q, --quiet suppress non-error messages\n");
- rprintf(F," --no-motd suppress daemon-mode MOTD (see manpage caveat)\n");
- rprintf(F," -c, --checksum skip based on checksum, not mod-time & size\n");
-- rprintf(F," -a, --archive archive mode; same as -rlptgoD (no -H, -A)\n");
-+ rprintf(F," -a, --archive archive mode; equals -rlptgoD (no -H,-A,-X)\n");
- rprintf(F," --no-OPTION turn off an implied OPTION (e.g. --no-D)\n");
- rprintf(F," -r, --recursive recurse into directories\n");
- rprintf(F," -R, --relative use relative path names\n");
-@@ -315,6 +319,9 @@ void usage(enum logcode F)
- #ifdef SUPPORT_ACLS
- rprintf(F," -A, --acls preserve ACLs (implies --perms)\n");
- #endif
-+#ifdef SUPPORT_XATTRS
-+ rprintf(F," -X, --xattrs preserve extended attributes (implies --perms)\n");
-+#endif
- rprintf(F," -o, --owner preserve owner (super-user only)\n");
- rprintf(F," -g, --group preserve group\n");
- rprintf(F," --devices preserve device files (super-user only)\n");
-@@ -437,6 +444,9 @@ static struct poptOption long_options[]
- {"acls", 'A', POPT_ARG_NONE, 0, 'A', 0, 0 },
- {"no-acls", 0, POPT_ARG_VAL, &preserve_acls, 0, 0, 0 },
- {"no-A", 0, POPT_ARG_VAL, &preserve_acls, 0, 0, 0 },
-+ {"xattrs", 'X', POPT_ARG_NONE, 0, 'X', 0, 0 },
-+ {"no-xattrs", 0, POPT_ARG_VAL, &preserve_xattrs, 0, 0, 0 },
-+ {"no-X", 0, POPT_ARG_VAL, &preserve_xattrs, 0, 0, 0 },
- {"times", 't', POPT_ARG_VAL, &preserve_times, 1, 0, 0 },
- {"no-times", 0, POPT_ARG_VAL, &preserve_times, 0, 0, 0 },
- {"no-t", 0, POPT_ARG_VAL, &preserve_times, 0, 0, 0 },
-@@ -1118,6 +1128,17 @@ int parse_arguments(int *argc, const cha
- return 0;
- #endif