--- rsync.c.orig 2006-01-09 12:35:38.000000000 -0600 +++ rsync.c 2006-01-09 12:35:51.000000000 -0600 @@ -22,6 +22,10 @@ #include "rsync.h" +#ifdef HAVE_COPYFILE +#include +#endif + extern int verbose; extern int dry_run; extern int daemon_log_format_has_i; @@ -39,6 +43,10 @@ extern int make_backups; extern struct stats stats; +#ifdef EA_SUPPORT +extern int extended_attributes; +#endif + /* free a sums struct @@ -170,6 +178,9 @@ int ok_to_set_time, int overwriting_basis) { int ret; +#ifdef HAVE_COPYFILE + char fnamereal[MAXPATHLEN]; +#endif if (inplace) { if (verbose > 2) @@ -198,10 +209,33 @@ } if (ret == 0) { /* The file was moved into place (not copied), so it's done. */ - return; + goto do_fix_extfile_mtime; } do_set_perms: set_perms(fname, file, NULL, ok_to_set_time ? 0 : PERMS_SKIP_MTIME); + + do_fix_extfile_mtime: +#ifdef EA_SUPPORT + /* JDB: When rsync'ing data with extended attributes TO a machine + supporting copyfile, moving the synthetic file into place will + change the mtime of the 'real' file. Since the code in generator.c + guarantees that the synthetic file will be transferred after the + real file, it is sufficient (although kludgy) to re-adjust + the mtime of the real file here. */ +#ifdef HAVE_COPYFILE + if (extended_attributes) { + if (!strncmp(basename(fname), "._", 2) && ok_to_set_time) { + snprintf(fnamereal, MAXPATHLEN, "%s/%s", + dirname(fname), basename(fname) + 2); + if (set_modtime(fnamereal, file->modtime) != 0) { + rsyserr(FERROR, errno, "failed to set times for real file of %s", + full_fname(fname)); + } + } + } +#endif +#endif + return; } const char *who_am_i(void)