From: Wayne Davison Date: Mon, 9 Jun 2008 03:26:22 +0000 (-0700) Subject: Fixed an "Internal abbrev error" when dealing with an xattr value X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/commitdiff_plain/7462c6ac39d86cb8252ec47246569e3ddda35b6a?hp=f31850966f7f60b8c58fa44d6948044571c060f6 Fixed an "Internal abbrev error" when dealing with an xattr value that is unchanged on an early file, and changed on a later file. Added 2 new test cases to ensure this stays fixed. --- diff --git a/generator.c b/generator.c index 0ac86426..2ae88dbe 100644 --- a/generator.c +++ b/generator.c @@ -697,8 +697,11 @@ void itemize(const char *fnamecmp, struct file_struct *file, int ndx, int statre if (iflags & ITEM_XNAME_FOLLOWS) write_vstring(sock_f_out, xname, strlen(xname)); #ifdef SUPPORT_XATTRS - if (iflags & ITEM_REPORT_XATTR && !dry_run) - send_xattr_request(NULL, file, sock_f_out); + if (preserve_xattrs && !dry_run + && iflags & (ITEM_REPORT_XATTR|ITEM_TRANSFER)) { + send_xattr_request(NULL, file, + iflags & ITEM_REPORT_XATTR ? sock_f_out : -1); + } #endif } else if (ndx >= 0) { enum logcode code = logfile_format_has_i ? FINFO : FCLIENT; diff --git a/testsuite/xattrs.test b/testsuite/xattrs.test index 4f2c6cb3..11b53c52 100644 --- a/testsuite/xattrs.test +++ b/testsuite/xattrs.test @@ -91,12 +91,12 @@ cd "$todir" xls $files | diff $diffopt "$scratchdir/xattrs.txt" - cd "$fromdir" +rm -rf "$todir" + xset user.nice 'this is nice, but different' file1 xls $files >"$scratchdir/xattrs.txt" -rm -rf "$todir" - checkit "$RSYNC -aiX --fake-super --link-dest=../chk . ../to" "$chkdir" "$todir" cd "$todir" @@ -109,5 +109,31 @@ if [ -s "$scratchdir/ls-diff" ]; then exit 1 fi +cd "$fromdir" +rm -rf "$todir" "$chkdir" + +rsync -aX file1 file2 +rsync -aX file1 file2 ../chk/ +rsync -aX --del ../chk/ . +rsync -aX file1 ../lnk/ + +xls file1 file2 >"$scratchdir/xattrs.txt" + +checkit "$RSYNC -aiiX --copy-dest=../lnk . ../to" "$chkdir" "$todir" + +cd "$todir" +xls file1 file2 | diff $diffopt "$scratchdir/xattrs.txt" - + +cd "$fromdir" +rm "$todir/file2" + +echo extra >file1 +rsync -aX file1 ../chk/ + +checkit "$RSYNC -aiiX . ../to" "$chkdir" "$todir" + +cd "$todir" +xls file1 file2 | diff $diffopt "$scratchdir/xattrs.txt" - + # The script would have aborted on error, so getting here means we've won. exit 0 diff --git a/xattrs.c b/xattrs.c index b6a82e42..349fbf49 100644 --- a/xattrs.c +++ b/xattrs.c @@ -503,9 +503,11 @@ int xattr_diff(struct file_struct *file, stat_x *sxp, int find_all) return !xattrs_equal; } -/* When called by the generator with a NULL fname, this tells the sender - * which abbreviated xattr values we need. When called by the sender - * (with a non-NULL fname), we send all the extra xattr data it needs. */ +/* When called by the generator (with a NULL fname), this tells the sender + * all the abbreviated xattr values we need. When called by the sender + * (with a non-NULL fname), we send all the extra xattr data it needs. + * The generator may also call with f_out < 0 to just change all the + * XSTATE_ABBREV states into XSTATE_DONE. */ void send_xattr_request(const char *fname, struct file_struct *file, int f_out) { item_list *lst = rsync_xal_l.items; @@ -524,6 +526,7 @@ void send_xattr_request(const char *fname, struct file_struct *file, int f_out) rxa->datum[0] = XSTATE_DONE; continue; case XSTATE_TODO: + assert(f_out >= 0); break; default: continue; @@ -552,7 +555,8 @@ void send_xattr_request(const char *fname, struct file_struct *file, int f_out) } } - write_byte(f_out, 0); /* end the list */ + if (f_out >= 0) + write_byte(f_out, 0); /* end the list */ } /* When called by the sender, read the request from the generator and mark