Use "use warnings" rather than -w on the #! line.
[rsync/rsync-patches.git] / checksum-xattr.diff
index 24c4de4..bd6d3de 100644 (file)
@@ -8,10 +8,11 @@ To use this patch, run these commands for a successful build:
     ./configure                               (optional if already run)
     make
 
---- old/flist.c
-+++ new/flist.c
-@@ -1193,7 +1193,8 @@ struct file_struct *make_file(const char
-       }
+diff --git a/flist.c b/flist.c
+--- a/flist.c
++++ b/flist.c
+@@ -1286,7 +1286,8 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+               memcpy(bp + basename_len, linkname, linkname_len);
  #endif
  
 -      if (always_checksum && am_sender && S_ISREG(st.st_mode))
@@ -19,10 +20,11 @@ To use this patch, run these commands for a successful build:
 +       && !get_sum_xattr(thisname, &st, tmp_sum))
                file_checksum(thisname, tmp_sum, st.st_size);
  
-       F_PATHNAME(file) = pathname;
---- old/generator.c
-+++ new/generator.c
-@@ -627,7 +627,8 @@ int unchanged_file(char *fn, struct file
+       if (am_sender)
+diff --git a/generator.c b/generator.c
+--- a/generator.c
++++ b/generator.c
+@@ -724,7 +724,8 @@ int unchanged_file(char *fn, struct file_struct *file, STRUCT_STAT *st)
           of the file time to determine whether to sync */
        if (always_checksum > 0 && S_ISREG(st->st_mode)) {
                char sum[MAX_DIGEST_LEN];
@@ -32,11 +34,14 @@ To use this patch, run these commands for a successful build:
                return memcmp(sum, F_SUM(file), checksum_len) == 0;
        }
  
---- old/support/xsums
-+++ new/support/xsums
-@@ -0,0 +1,118 @@
-+#!/usr/bin/perl -w
+diff --git a/support/xsums b/support/xsums
+new file mode 100644
+--- /dev/null
++++ b/support/xsums
+@@ -0,0 +1,119 @@
++#!/usr/bin/perl
 +use strict;
++use warnings;
 +
 +use Getopt::Long;
 +use Cwd qw(abs_path cwd);
@@ -153,52 +158,43 @@ To use this patch, run these commands for a successful build:
 + -h, --help        Display this help message.
 +EOT
 +}
---- old/xattrs.c
-+++ new/xattrs.c
-@@ -31,6 +31,8 @@ extern int am_generator;
- extern int read_only;
+diff --git a/xattrs.c b/xattrs.c
+--- a/xattrs.c
++++ b/xattrs.c
+@@ -33,6 +33,8 @@ extern int read_only;
  extern int list_only;
+ extern int preserve_xattrs;
  extern int checksum_seed;
 +extern int checksum_len;
 +extern int protocol_version;
  
  #define RSYNC_XAL_INITIAL 5
  #define RSYNC_XAL_LIST_INITIAL 100
-@@ -62,7 +64,8 @@ extern int checksum_seed;
- #define RPRE_LEN ((int)sizeof RSYNC_PREFIX - 1)
- #define XSTAT_ATTR RSYNC_PREFIX "%stat"
--#define XSTAT_LEN ((int)sizeof XSTAT_ATTR - 1)
-+#define MD4_ATTR RSYNC_PREFIX "%md4"
-+#define MD5_ATTR RSYNC_PREFIX "%md5"
+@@ -68,6 +70,10 @@ extern int checksum_seed;
+ #define XACC_ACL_ATTR RSYNC_PREFIX "%" XACC_ACL_SUFFIX
+ #define XDEF_ACL_SUFFIX "dacl"
+ #define XDEF_ACL_ATTR RSYNC_PREFIX "%" XDEF_ACL_SUFFIX
++#define MD4_SUFFIX "md4"
++#define MD4_ATTR RSYNC_PREFIX "%" MD4_SUFFIX
++#define MD5_SUFFIX "md5"
++#define MD5_ATTR RSYNC_PREFIX "%" MD5_SUFFIX
  
  typedef struct {
        char *datum, *name;
-@@ -223,8 +226,8 @@ static int rsync_xal_get(const char *fna
-                       continue;
- #endif
--              if (am_root < 0 && name_len == XSTAT_LEN + 1
--               && name[RPRE_LEN] == '%' && strcmp(name, XSTAT_ATTR) == 0)
-+              if (name_len > RPRE_LEN && name[RPRE_LEN] == '%'
-+               && HAS_PREFIX(name, RSYNC_PREFIX))
-                       continue;
-               datum_len = name_len; /* Pass extra size to get_xattr_data() */
-@@ -636,8 +639,8 @@ void receive_xattr(struct file_struct *f
-                       continue;
+@@ -238,7 +244,9 @@ static int rsync_xal_get(const char *fname, item_list *xalp)
+                        || (am_root < 0
+                         && (strcmp(name+RPRE_LEN+1, XSTAT_SUFFIX) == 0
+                          || strcmp(name+RPRE_LEN+1, XACC_ACL_SUFFIX) == 0
+-                         || strcmp(name+RPRE_LEN+1, XDEF_ACL_SUFFIX) == 0)))
++                         || strcmp(name+RPRE_LEN+1, XDEF_ACL_SUFFIX) == 0
++                         || strcmp(name+RPRE_LEN+1, MD4_SUFFIX) == 0
++                         || strcmp(name+RPRE_LEN+1, MD5_SUFFIX) == 0)))
+                               continue;
                }
- #endif
--              if (am_root < 0 && name_len == XSTAT_LEN + 1
--               && name[RPRE_LEN] == '%' && strcmp(name, XSTAT_ATTR) == 0) {
-+              if (name_len > RPRE_LEN && name[RPRE_LEN] == '%'
-+               && HAS_PREFIX(name, RSYNC_PREFIX)) {
-                       free(ptr);
-                       continue;
-               }
-@@ -795,6 +798,39 @@ int set_xattr(const char *fname, const s
-       return rsync_xal_set(fname, lst + ndx, fnamecmp, sxp);
+@@ -894,6 +902,39 @@ int del_def_xattr_acl(const char *fname)
  }
+ #endif
  
 +int get_sum_xattr(const char *fname, STRUCT_STAT *stp, char *sum)
 +{
@@ -207,12 +203,12 @@ To use this patch, run these commands for a successful build:
 +      char buf[256];
 +      uint32 file_length, mtime;
 +      int len;
-+      
++
 +      len = sys_lgetxattr(fname, mdattr, buf, sizeof buf);
 +      if (len < 0) {
 +              if (errno == ENOTSUP || errno == ENOATTR)
 +                      return 0;
-+              rsyserr(FERROR, errno, "failed to read xattr %s for %s",
++              rsyserr(FERROR_XFER, errno, "failed to read xattr %s for %s",
 +                      mdattr, full_fname(fname));
 +              return 0;
 +      }