On Fri, May 07, 2004 at 11:18:46AM -0400, Brian Childs wrote: > As a response to my original post, here's a patch that implements my > proposed solution. > > I've tested it, and it fixes the problem, but I'm afraid there may be > some hidden consequences of doing this. >
I've refined my patch to eliminate the extra 'lstat'. It makes it a larger patch, but I believe it's correct and more efficient. I kept the check for IS_SDIR in the set_modtime function because I didn't want to push that responsibility to the caller of the function. That's a sure way for this bug to return. The 'backup dir' code sets the modtime on newly created directories only. I've opted to keep that in the code. A new dir can't be in anyones dentry cache. Anyway, here's the new patch. Thanks, Brian diff -x '*~' -x '*.o' -ur rsync-2.6.2/backup.c rsync-2.6.2-rentec/backup.c --- rsync-2.6.2/backup.c 2004-03-13 15:18:03.000000000 -0500 +++ rsync-2.6.2-rentec/backup.c 2004-05-11 09:03:15.000000000 -0400 @@ -101,7 +101,7 @@ "make_bak_dir stat %s failed: %s\n", full_fname(rel), strerror(errno)); } else { - set_modtime(fullpath, st.st_mtime); + set_modtime(fullpath, st.st_mtime, st.st_mode); do_lchown(fullpath, st.st_uid, st.st_gid); do_chmod(fullpath, st.st_mode); } diff -x '*~' -x '*.o' -ur rsync-2.6.2/proto.h rsync-2.6.2-rentec/proto.h --- rsync-2.6.2/proto.h 2004-04-22 05:58:09.000000000 -0400 +++ rsync-2.6.2-rentec/proto.h 2004-05-11 09:01:28.000000000 -0400 @@ -242,7 +242,7 @@ void print_child_argv(char **cmd); void out_of_memory(char *str); void overflow(char *str); -int set_modtime(char *fname, time_t modtime); +int set_modtime(char *fname, time_t modtime, mode_t mode); int create_directory_path(char *fname, int base_umask); int copy_file(char *source, char *dest, mode_t mode); int robust_unlink(char *fname); diff -x '*~' -x '*.o' -ur rsync-2.6.2/rsync.c rsync-2.6.2-rentec/rsync.c --- rsync-2.6.2/rsync.c 2004-03-23 11:16:15.000000000 -0500 +++ rsync-2.6.2-rentec/rsync.c 2004-05-11 09:03:38.000000000 -0400 @@ -144,7 +144,7 @@ cmp_modtime(st->st_mtime, file->modtime) != 0) { /* don't complain about not setting times on directories * because some filesystems can't do it */ - if (set_modtime(fname,file->modtime) != 0 && + if (set_modtime(fname,file->modtime,file->mode) != 0 && !S_ISDIR(st->st_mode)) { rprintf(FERROR, "failed to set times on %s: %s\n", full_fname(fname), strerror(errno)); diff -x '*~' -x '*.o' -ur rsync-2.6.2/util.c rsync-2.6.2-rentec/util.c --- rsync-2.6.2/util.c 2004-04-27 15:59:37.000000000 -0400 +++ rsync-2.6.2-rentec/util.c 2004-05-11 09:00:45.000000000 -0400 @@ -124,12 +124,18 @@ -int set_modtime(char *fname, time_t modtime) +int set_modtime(char *fname, time_t modtime, mode_t mode) { extern int dry_run; + extern int make_backups; + if (dry_run) return 0; + if(make_backups && S_ISDIR(mode)) { + return 0; + } + if (verbose > 2) { rprintf(FINFO, "set modtime of %s to (%ld) %s", fname, (long) modtime, -- To unsubscribe or change options: http://lists.samba.org/mailman/listinfo/rsync Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html