if (!(file = make_file(rel, NULL, NULL, 0, NO_FILTERS)))
continue;
#ifdef SUPPORT_ACLS
-@@ -142,6 +146,12 @@ static int make_bak_dir(char *fullpath)
- cache_acl(file, &sx);
+@@ -143,6 +147,12 @@ static int make_bak_dir(char *fullpath)
+ free_acl(&sx);
}
#endif
+#ifdef SUPPORT_XATTRS
set_file_attrs(fullpath, file, NULL, 0);
free(file);
}
-@@ -193,6 +203,9 @@ static int keep_backup(const char *fname
+@@ -194,6 +204,9 @@ static int keep_backup(const char *fname
#ifdef SUPPORT_ACLS
sx.acc_acl = sx.def_acl = NULL;
#endif
if (!(file = make_file(fname, NULL, NULL, 0, NO_FILTERS)))
return 1; /* the file could have disappeared */
-@@ -208,6 +221,12 @@ static int keep_backup(const char *fname
- cache_acl(file, &sx);
+@@ -210,6 +223,12 @@ static int keep_backup(const char *fname
+ free_acl(&sx);
}
#endif
+#ifdef SUPPORT_XATTRS
if (!read_batch)
--- old/configure.in
+++ new/configure.in
-@@ -883,6 +883,40 @@ samba_cv_HAVE_ACL_GET_PERM_NP=yes,samba_
- AC_MSG_RESULT(no)
- )
+@@ -881,6 +881,40 @@ samba_cv_HAVE_ACL_GET_PERM_NP=yes,samba_
+ esac
+ fi
+AC_CHECK_HEADERS(attr/xattr.h)
+AC_CHECK_HEADERS(sys/xattr.h)
extern int preserve_hard_links;
extern int preserve_devices;
@@ -864,6 +865,10 @@ static struct file_struct *recv_file_ent
- if (preserve_acls)
+ if (preserve_acls && !S_ISLNK(mode))
receive_acl(file, f);
#endif
+#ifdef SUPPORT_XATTRS
maybe_emit_filelist_progress(flist->count + flist_count_offset);
-@@ -1166,6 +1178,10 @@ static struct file_struct *send_file_nam
- if (preserve_acls)
- send_acl(&sx, f);
+@@ -1168,6 +1180,10 @@ static struct file_struct *send_file_nam
+ free_acl(&sx);
+ }
#endif
+#ifdef SUPPORT_XATTRS
+ if (preserve_xattrs)
* will enable owner-writability using chmod, if necessary.
--- old/rsync.h
+++ new/rsync.h
-@@ -555,6 +555,10 @@ struct idev_node {
+@@ -551,6 +551,10 @@ struct idev_node {
#define ACLS_NEED_MASK 1
#endif
#define GID_NONE ((gid_t)-1)
union file_extras {
-@@ -575,6 +579,7 @@ extern int file_extra_cnt;
+@@ -571,6 +575,7 @@ extern int file_extra_cnt;
extern int preserve_uid;
extern int preserve_gid;
extern int preserve_acls;
#define FILE_STRUCT_LEN (offsetof(struct file_struct, basename))
#define EXTRA_LEN (sizeof (union file_extras))
-@@ -608,6 +613,7 @@ extern int preserve_acls;
+@@ -604,6 +609,7 @@ extern int preserve_acls;
#define F_OWNER(f) REQ_EXTRA(f, preserve_uid)->unum
#define F_GROUP(f) REQ_EXTRA(f, preserve_gid)->unum
#define F_ACL(f) REQ_EXTRA(f, preserve_acls)->unum
/* These items are per-entry optional and mutally exclusive: */
#define F_HL_GNUM(f) OPT_EXTRA(f, LEN64_BUMP(f))->num
-@@ -799,6 +805,9 @@ typedef struct {
+@@ -795,6 +801,9 @@ typedef struct {
struct rsync_acl *acc_acl; /* access ACL */
struct rsync_acl *def_acl; /* default ACL */
#endif
@@ -324,6 +324,7 @@ to the detailed description below for a
-E, --executability preserve executability
--chmod=CHMOD affect file and/or directory permissions
- -A, --acls preserve ACLs (implies -p) [non-standard]
-+ -X, --xattrs preserve extended attrs (implies -p) [n.s.]
+ -A, --acls preserve ACLs (implies -p)
++ -X, --xattrs preserve extended attrs (implies -p)
-o, --owner preserve owner (super-user only)
-g, --group preserve group
--devices preserve device files (super-user only)
-@@ -835,6 +836,11 @@ The ACL-sending protocol used by this ve
- the patch that was shipped with 2.6.8. Sending ACLs to an older version
- of the ACL patch is not supported.
+@@ -831,6 +832,11 @@ dit(bf(-A, --acls)) This option causes r
+ ACLs to be the same as the source ACLs. This nonstandard option only
+ works if the remote rsync also supports it. bf(--acls) implies bf(--perms).
+dit(bf(-X, --xattrs)) This option causes rsync to update the remote
+extended attributes to be the same as the local ones. This will work
transfer. The resulting value is treated as though it was the permissions
--- old/xattr.c
+++ new/xattr.c
-@@ -0,0 +1,451 @@
+@@ -0,0 +1,459 @@
+/*
+ * Extended Attribute support for rsync.
+ * Written by Jay Fenlason, vaguely based on the ACLs patch.
+ name_len = strlen(name) + 1;
+ list_len -= name_len;
+
++#ifdef HAVE_LINUX_XATTRS
++ /* We always ignore the system namespace, and non-root
++ * ignores everything but the user namespace. */
++ if (am_root ? HAS_PREFIX(name, SYSTEM_PREFIX)
++ : !HAS_PREFIX(name, USER_PREFIX))
++ continue;
++#endif
++
+ for (i = 0; i < xalp->count; i++) {
+ if (strcmp(name, rxas[i].name) == 0)
+ break;