The OS X version now transmits a unique prefix ("user.0S%.") for
authorWayne Davison <wayned@samba.org>
Thu, 26 Oct 2006 01:53:32 +0000 (01:53 +0000)
committerWayne Davison <wayned@samba.org>
Thu, 26 Oct 2006 01:53:32 +0000 (01:53 +0000)
attrs that don't begin with "user." or "system.".  It also strips
this prefix when it is received.

xattrs.diff

index d4cfcf7..2b8412d 100644 (file)
@@ -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 */