Fixed failing hunks.
[rsync/rsync-patches.git] / xattrs.diff
index a6def17..eba634b 100644 (file)
@@ -257,7 +257,7 @@ TODO:
        }
  #endif
 +#ifdef SUPPORT_XATTRS
-+      if (preserve_xattrs) {
++      if (preserve_xattrs && f >= 0) {
 +              sx.xattr = NULL;
 +              if (get_xattr(fname, &sx) < 0)
 +                      return NULL;
@@ -267,20 +267,20 @@ TODO:
        maybe_emit_filelist_progress(flist->count + flist_count_offset);
  
 @@ -1006,11 +1024,19 @@ static struct file_struct *send_file_nam
-               if (preserve_acls)
+               if (preserve_acls && f >= 0)
                        send_acl(&sx, f);
  #endif
 +#ifdef SUPPORT_XATTRS
-+              if (preserve_xattrs)
++              if (preserve_xattrs && f >= 0)
 +                      send_xattr(&sx, f);
 +#endif
        } else {
  #ifdef SUPPORT_ACLS
-               if (preserve_acls)
+               if (preserve_acls && f >= 0)
                        free_acl(&sx);
  #endif
 +#ifdef SUPPORT_XATTRS
-+              if (preserve_xattrs)
++              if (preserve_xattrs && f >= 0)
 +                      free_xattr(&sx);
 +#endif
        }
@@ -288,7 +288,7 @@ TODO:
  }
 --- old/lib/sysxattr.c
 +++ new/lib/sysxattr.c
-@@ -0,0 +1,136 @@
+@@ -0,0 +1,135 @@
 +/*
 + * Extended attribute support for rsync.
 + *
@@ -403,7 +403,7 @@ TODO:
 +       * terminator.  We need to change this into a series of null-terminted
 +       * strings.  Since the size is the same, we can simply transform the
 +       * output in place. */
-+      for (off = 0; off < len; ) {
++      for (off = 0; off < len; off += keylen + 1) {
 +              keylen = ((unsigned char*)list)[off];
 +              if (off + keylen >= len) {
 +                      /* Should be impossible, but kernel bugs happen! */
@@ -411,8 +411,7 @@ TODO:
 +                      return -1;
 +              }
 +              memmove(list+off, list+off+1, keylen);
-+              off += keylen;
-+              list[off++] = '\0';
++              list[off+keylen] = '\0';
 +      }
 +
 +      return len;
@@ -575,7 +574,7 @@ TODO:
         * will enable owner-writability using chmod, if necessary.
 --- old/rsync.h
 +++ new/rsync.h
-@@ -500,6 +500,10 @@ struct idev {
+@@ -501,6 +501,10 @@ struct idev {
  #define ACLS_NEED_MASK 1
  #endif
  
@@ -586,7 +585,7 @@ TODO:
  #define GID_NONE ((gid_t)-1)
  
  #define HL_CHECK_MASTER       0
-@@ -694,6 +698,9 @@ typedef struct {
+@@ -692,6 +696,9 @@ typedef struct {
      struct rsync_acl *acc_acl; /* access ACL */
      struct rsync_acl *def_acl; /* default ACL */
  #endif
@@ -629,7 +628,7 @@ TODO:
  transfer.  The resulting value is treated as though it was the permissions
 --- old/xattr.c
 +++ new/xattr.c
-@@ -0,0 +1,414 @@
+@@ -0,0 +1,417 @@
 +/*
 + * Extended Attribute support for rsync.
 + * Written by Jay Fenlason, vaguely based on the ACLs patch.
@@ -895,7 +894,8 @@ TODO:
 +#else
 +                      /* We strip the rsync prefix from disguised namespaces
 +                       * and put everything else in the user namespace. */
-+                      if (HAS_PREFIX(rxa->name, RSYNC_PREFIX)) {
++                      if (HAS_PREFIX(rxa->name, RSYNC_PREFIX)
++                       && rxa->name[RPRE_LEN] != '%') {
 +                              write_int(f, rxa->name_len - RPRE_LEN);
 +                              write_int(f, rxa->datum_len);
 +                              write_buf(f, rxa->name + RPRE_LEN, rxa->name_len - RPRE_LEN);
@@ -929,8 +929,10 @@ TODO:
 +                      rsync_xa *rxa;
 +                      size_t name_len = read_int(f);
 +                      size_t datum_len = read_int(f);
-+                      size_t extra_len = am_root < 0 ? RPRE_LEN : 0;
-+#ifndef HAVE_LINUX_XATTRS
++#ifdef HAVE_LINUX_XATTRS
++                      size_t extra_len = 0;
++#else
++                      size_t extra_len = am_root ? RPRE_LEN : 0;
 +                      if (datum_len + extra_len < datum_len)
 +                              out_of_memory("receive_xattr"); /* overflow */
 +#endif