From 517cc92f23f39e7d2fd233bb43980daf2e04876f Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Thu, 26 Oct 2006 01:53:32 +0000 Subject: [PATCH] The OS X version now transmits a unique prefix ("user.0S%.") for attrs that don't begin with "user." or "system.". It also strips this prefix when it is received. --- xattrs.diff | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/xattrs.diff b/xattrs.diff index d4cfcf7..2b8412d 100644 --- a/xattrs.diff +++ b/xattrs.diff @@ -15,9 +15,6 @@ TODO: - We need to affect the --link-dest option to avoid hard-linking two files that differ in their xattrs (when --xattrs was specified). - - Mac OS X support should probably escape names that don't begin with "user." - or "system." so that the xattr names can be stored on non-macs. - --- old/Makefile.in +++ new/Makefile.in @@ -28,13 +28,13 @@ VERSION=@VERSION@ @@ -526,7 +523,7 @@ TODO: transfer. The resulting value is treated as though it was the permissions --- old/xattr.c +++ new/xattr.c -@@ -0,0 +1,346 @@ +@@ -0,0 +1,367 @@ +/* + * Extended Attribute support for rsync. + * Written by Jay Fenlason, vaguely based on the ACLs patch. @@ -573,6 +570,11 @@ TODO: +static item_list empty_xattr = EMPTY_ITEM_LIST; +static item_list rsync_xal_l = EMPTY_ITEM_LIST; + ++#ifdef HAVE_OSX_XATTRS ++static char unique_prefix[] = "user.0S%."; /* OSX */ ++static int upre_len = sizeof unique_prefix - 1; ++#endif ++ +/* ------------------------------------------------------------------------- */ + +static void rsync_xal_free(item_list *xalp) @@ -763,8 +765,18 @@ TODO: + write_byte(f, 'X'); + write_int(f, count); + for (rxa = sxp->xattr->items; count--; rxa++) { -+ write_int(f, rxa->name_len); -+ write_int(f, rxa->datum_len); ++#ifdef HAVE_OSX_XATTRS ++ if (strncmp(rxa->name, "user.", 5) != 0 ++ && strncmp(rxa->name, "system.", 7) != 0) { ++ write_int(f, rxa->name_len + upre_len); ++ write_int(f, rxa->datum_len); ++ write_buf(f, unique_prefix, upre_len); ++ } else ++#endif ++ { ++ write_int(f, rxa->name_len); ++ write_int(f, rxa->datum_len); ++ } + write_buf(f, rxa->name, rxa->name_len); + write_buf(f, rxa->datum, rxa->datum_len); + } @@ -802,6 +814,12 @@ TODO: + rxa->datum_len = datum_len; + rxa->name = ptr; + rxa->datum = ptr + name_len; ++#ifdef HAVE_OSX_XATTRS ++ if (strncmp(rxa->name, unique_prefix, upre_len) == 0) { ++ rxa->name_len -= upre_len; ++ memmove(rxa->name, rxa->name + upre_len, rxa->name_len); ++ } ++#endif + } + ndx = rsync_xal_l.count; /* pre-incremented count */ + rsync_xal_store(&temp_xattr); /* adds item to rsync_xal_l */ -- 2.34.1