X-Git-Url: https://mattmccutchen.net/rsync/rsync-patches.git/blobdiff_plain/8a38e00aeb2dc1119a0a236a8c903e942903d08b..998e0bab068d64092214e4e923e518c599faff61:/xattrs.diff diff --git a/xattrs.diff b/xattrs.diff index d760bb6..fd731ef 100644 --- a/xattrs.diff +++ b/xattrs.diff @@ -12,10 +12,11 @@ To use this patch, run these commands for a successful build: --- old/compat.c +++ new/compat.c -@@ -115,13 +115,6 @@ void setup_protocol(int f_out,int f_in) - protocol_version); - exit_cleanup(RERR_PROTOCOL); - } +@@ -144,16 +144,6 @@ void setup_protocol(int f_out,int f_in) + exit_cleanup(RERR_PROTOCOL); + } + +- if (protocol_version < 30) { - if (preserve_xattrs && !local_server) { - rprintf(FERROR, - "--xattrs requires protocol 30 or higher" @@ -23,9 +24,11 @@ To use this patch, run these commands for a successful build: - protocol_version); - exit_cleanup(RERR_PROTOCOL); - } - } - +- } +- if (delete_mode && !(delete_before+delete_during+delete_after)) { + if (protocol_version < 30) + delete_before = 1; --- old/xattrs.c +++ new/xattrs.c @@ -20,6 +20,7 @@ @@ -36,15 +39,15 @@ To use this patch, run these commands for a successful build: #include "lib/sysxattrs.h" #ifdef SUPPORT_XATTRS -@@ -31,6 +32,7 @@ extern int am_generator; - extern int read_only; +@@ -32,6 +33,7 @@ extern int read_only; extern int list_only; + extern int preserve_xattrs; extern int checksum_seed; +extern int protocol_version; #define RSYNC_XAL_INITIAL 5 #define RSYNC_XAL_LIST_INITIAL 100 -@@ -222,7 +224,7 @@ static int rsync_xal_get(const char *fna +@@ -232,7 +234,7 @@ static int rsync_xal_get(const char *fna if (!(ptr = get_xattr_data(fname, name, &datum_len, 0))) return -1; @@ -53,7 +56,7 @@ To use this patch, run these commands for a successful build: /* For large datums, we store a flag and a checksum. */ name_offset = 1 + MAX_DIGEST_LEN; sum_init(checksum_seed); -@@ -278,7 +280,7 @@ static int find_matching_xattr(item_list +@@ -296,7 +298,7 @@ static int find_matching_xattr(item_list || rxas1[j].datum_len != rxas2[j].datum_len || strcmp(rxas1[j].name, rxas2[j].name)) break; @@ -62,12 +65,12 @@ To use this patch, run these commands for a successful build: if (memcmp(rxas1[j].datum + 1, rxas2[j].datum + 1, MAX_DIGEST_LEN) != 0) -@@ -315,34 +317,43 @@ int send_xattr(statx *sxp, int f) +@@ -333,34 +335,43 @@ int send_xattr(statx *sxp, int f) { int ndx = find_matching_xattr(sxp->xattr); - /* Send 0 (-1 + 1) to indicate that literal xattr data follows. */ -- write_abbrevint(f, ndx + 1); +- write_varint(f, ndx + 1); + if (protocol_version < 30) { + if (ndx < 0) + write_byte(f, 'X'); @@ -77,36 +80,36 @@ To use this patch, run these commands for a successful build: + } + } else { + /* Send 0 (-1 + 1) to indicate that literal xattr data follows. */ -+ write_abbrevint(f, ndx + 1); ++ write_varint(f, ndx + 1); + } if (ndx < 0) { rsync_xa *rxa; int count = sxp->xattr->count; -- write_abbrevint(f, count); -+ write_abbrevint30(f, count); +- write_varint(f, count); ++ write_varint30(f, count); for (rxa = sxp->xattr->items; count--; rxa++) { #ifdef HAVE_LINUX_XATTRS -- write_abbrevint(f, rxa->name_len); -- write_abbrevint(f, rxa->datum_len); -+ write_abbrevint30(f, rxa->name_len); -+ write_abbrevint30(f, rxa->datum_len); +- write_varint(f, rxa->name_len); +- write_varint(f, rxa->datum_len); ++ write_varint30(f, rxa->name_len); ++ write_varint30(f, rxa->datum_len); write_buf(f, rxa->name, rxa->name_len); #else /* We strip the rsync prefix from disguised namespaces * and put everything else in the user namespace. */ if (HAS_PREFIX(rxa->name, RSYNC_PREFIX) && rxa->name[RPRE_LEN] != '%') { -- write_abbrevint(f, rxa->name_len - RPRE_LEN); -- write_abbrevint(f, rxa->datum_len); -+ write_abbrevint30(f, rxa->name_len - RPRE_LEN); -+ write_abbrevint30(f, rxa->datum_len); +- write_varint(f, rxa->name_len - RPRE_LEN); +- write_varint(f, rxa->datum_len); ++ write_varint30(f, rxa->name_len - RPRE_LEN); ++ write_varint30(f, rxa->datum_len); write_buf(f, rxa->name + RPRE_LEN, rxa->name_len - RPRE_LEN); } else { -- write_abbrevint(f, rxa->name_len + UPRE_LEN); -- write_abbrevint(f, rxa->datum_len); -+ write_abbrevint30(f, rxa->name_len + UPRE_LEN); -+ write_abbrevint30(f, rxa->datum_len); +- write_varint(f, rxa->name_len + UPRE_LEN); +- write_varint(f, rxa->datum_len); ++ write_varint30(f, rxa->name_len + UPRE_LEN); ++ write_varint30(f, rxa->datum_len); write_buf(f, USER_PREFIX, UPRE_LEN); write_buf(f, rxa->name, rxa->name_len); } @@ -116,7 +119,7 @@ To use this patch, run these commands for a successful build: write_buf(f, rxa->datum + 1, MAX_DIGEST_LEN); else write_buf(f, rxa->datum, rxa->datum_len); -@@ -392,7 +403,7 @@ int xattr_diff(struct file_struct *file, +@@ -410,7 +421,7 @@ int xattr_diff(struct file_struct *file, cmp = rec_cnt ? strcmp(snd_rxa->name, rec_rxa->name) : -1; if (cmp > 0) same = 0; @@ -125,7 +128,7 @@ To use this patch, run these commands for a successful build: same = cmp == 0 && snd_rxa->datum_len == rec_rxa->datum_len && memcmp(snd_rxa->datum + 1, rec_rxa->datum + 1, MAX_DIGEST_LEN) == 0; -@@ -435,6 +446,9 @@ void send_xattr_request(const char *fnam +@@ -453,6 +464,9 @@ void send_xattr_request(const char *fnam int j, cnt, prior_req = -1; rsync_xa *rxa; @@ -135,7 +138,7 @@ To use this patch, run these commands for a successful build: lst += F_XATTR(file); cnt = lst->count; for (rxa = lst->items, j = 0; j < cnt; rxa++, j++) { -@@ -506,6 +520,9 @@ void recv_xattr_request(struct file_stru +@@ -524,6 +538,9 @@ void recv_xattr_request(struct file_stru rsync_xa *rxa; int rel_pos, cnt; @@ -145,15 +148,15 @@ To use this patch, run these commands for a successful build: if (F_XATTR(file) < 0) { rprintf(FERROR, "recv_xattr_request: internal data error!\n"); exit_cleanup(RERR_STREAMIO); -@@ -552,7 +569,22 @@ void receive_xattr(struct file_struct *f +@@ -570,7 +587,22 @@ void receive_xattr(struct file_struct *f { static item_list temp_xattr = EMPTY_ITEM_LIST; int count; -- int ndx = read_abbrevint(f); +- int ndx = read_varint(f); + int ndx; + + if (protocol_version >= 30) -+ ndx = read_abbrevint(f); ++ ndx = read_varint(f); + else { + int tag = read_byte(f); + if (tag == 'x') @@ -169,26 +172,26 @@ To use this patch, run these commands for a successful build: if (ndx < 0 || (size_t)ndx > rsync_xal_l.count) { rprintf(FERROR, "receive_xattr: xa index %d out of" -@@ -565,7 +597,7 @@ void receive_xattr(struct file_struct *f +@@ -583,7 +615,7 @@ void receive_xattr(struct file_struct *f return; } -- if ((count = read_abbrevint(f)) != 0) { -+ if ((count = read_abbrevint30(f)) != 0) { +- if ((count = read_varint(f)) != 0) { ++ if ((count = read_varint30(f)) != 0) { (void)EXPAND_ITEM_LIST(&temp_xattr, rsync_xa, count); temp_xattr.count = 0; } -@@ -573,9 +605,10 @@ void receive_xattr(struct file_struct *f +@@ -591,9 +623,10 @@ void receive_xattr(struct file_struct *f while (count--) { char *ptr, *name; rsync_xa *rxa; -- size_t name_len = read_abbrevint(f); -- size_t datum_len = read_abbrevint(f); +- size_t name_len = read_varint(f); +- size_t datum_len = read_varint(f); - size_t dget_len = datum_len > MAX_FULL_DATUM ? 1 + MAX_DIGEST_LEN : datum_len; -+ size_t name_len = read_abbrevint30(f); -+ size_t datum_len = read_abbrevint30(f); ++ size_t name_len = read_varint30(f); ++ size_t datum_len = read_varint30(f); + size_t dget_len = datum_len > MAX_FULL_DATUM && protocol_version >= 30 + ? 1 + MAX_DIGEST_LEN : datum_len; - #ifdef HAVE_LINUX_XATTRS - size_t extra_len = 0; - #else + size_t extra_len = MIGHT_NEED_RPRE ? RPRE_LEN : 0; + if (dget_len + extra_len < dget_len) + out_of_memory("receive_xattr"); /* overflow */