Hi -- I was very keen to download rsync and give it a whirl with the new --link-dest feature. However, I was terribly puzzled when I couldn't seem to get it working, even though --compare-dest with the same argument would work. It seemed like new files would be transferred even though files existed in the compare-dest/link-dest location; compare-dest would detect them but link-dest would make new files anyway. I tracked down my confusion to the new portion of skip_file() in generator.c. Because I wasn't supplying the --owner or --group options, the preserve_uid and preserve_gid flags were not set, and the source file's file->uid and file->gid values were just 0. But skip_file() was checking them against the destination file's st->st_uid and st->st_gid, and reporting the difference. Here's my stab at a patch -- I only just looked at the rsync code today, so I might very well be missing something. Thanks, Chris. diff -u generator.c.orig generator.c ===================================--- generator.c.orig 2003-03-19 15:07:29.592476000 -0500 +++ generator.c 2003-03-19 16:12:24.994685000 -0500 @@ -27,6 +27,8 @@ extern int dry_run; extern int relative_paths; extern int preserve_links; +extern int preserve_uid; +extern int preserve_gid; extern int am_root; extern int preserve_devices; extern int preserve_hard_links; @@ -55,7 +57,8 @@ if((st->st_mode & ~_S_IFMT) != (file->mode & ~_S_IFMT)) { return 0; } - if (st->st_uid != file->uid || st->st_gid != file->gid) { + if ((preserve_uid && st->st_uid != file->uid) || + (preserve_gid && st->st_gid != file->gid)) { return 0; } } =================================== -- GPG Key ID: 366A375B GPG Key Fingerprint: 485E 5041 17E1 E2BB C263 E4DE C8E3 FA36 366A 375B
On Wed, Mar 19, 2003 at 04:38:43PM -0500, Chris Darroch wrote:> Hi -- > > I was very keen to download rsync and give it a whirl with the > new --link-dest feature. However, I was terribly puzzled when I > couldn't seem to get it working, even though --compare-dest with > the same argument would work. It seemed like new files would > be transferred even though files existed in the compare-dest/link-dest > location; compare-dest would detect them but link-dest would make > new files anyway. > > I tracked down my confusion to the new portion of skip_file() > in generator.c. Because I wasn't supplying the --owner or --group > options, the preserve_uid and preserve_gid flags were not set, > and the source file's file->uid and file->gid values were just 0. > But skip_file() was checking them against the destination file's > st->st_uid and st->st_gid, and reporting the difference. > > Here's my stab at a patch -- I only just looked at the rsync > code today, so I might very well be missing something.Looks pretty good. However it once you start on this path it would be best to also check preserve_perms in the preceeding mode test.> > Thanks, > > Chris. > > > diff -u generator.c.orig generator.c > ===================================> --- generator.c.orig 2003-03-19 15:07:29.592476000 -0500 > +++ generator.c 2003-03-19 16:12:24.994685000 -0500 > @@ -27,6 +27,8 @@ > extern int dry_run; > extern int relative_paths; > extern int preserve_links; > +extern int preserve_uid; > +extern int preserve_gid; > extern int am_root; > extern int preserve_devices; > extern int preserve_hard_links; > @@ -55,7 +57,8 @@ > if((st->st_mode & ~_S_IFMT) != (file->mode & ~_S_IFMT)) { > return 0; > } > - if (st->st_uid != file->uid || st->st_gid != file->gid) { > + if ((preserve_uid && st->st_uid != file->uid) || > + (preserve_gid && st->st_gid != file->gid)) { > return 0; > } > } > ===================================> > -- > GPG Key ID: 366A375B > GPG Key Fingerprint: 485E 5041 17E1 E2BB C263 E4DE C8E3 FA36 366A 375B > > > -- > To unsubscribe or change options: http://lists.samba.org/mailman/listinfo/rsync > Before posting, read: http://www.tuxedo.org/~esr/faqs/smart-questions.html-- ________________________________________________________________ J.W. Schultz Pegasystems Technologies email address: jw@pegasys.ws Remember Cernan and Schmitt
Hi -- J. W. Schultz wrote:>> I was very keen to download rsync and give it a whirl with the >> new --link-dest feature. However, I was terribly puzzled when I >> couldn't seem to get it working, even though --compare-dest with >> the same argument would work. It seemed like new files would >> be transferred even though files existed in the compare-dest/link-dest >> location; compare-dest would detect them but link-dest would make >> new files anyway. >> >> I tracked down my confusion to the new portion of skip_file() >> in generator.c. Because I wasn't supplying the --owner or --group >> options, the preserve_uid and preserve_gid flags were not set, >> and the source file's file->uid and file->gid values were just 0. >> But skip_file() was checking them against the destination file's >> st->st_uid and st->st_gid, and reporting the difference. >> >> Here's my stab at a patch -- I only just looked at the rsync >> code today, so I might very well be missing something. > > Looks pretty good. > > However it once you start on this path it would be best to > also check preserve_perms in the preceeding mode test.OK, thanks -- here's the patch I'm using now for my own installation. If there's no desire to put it (or a better version of it) into CVS, then I'd suggest changing the man page so that the behaviour of rsync with --list-dest but without --owner, --group, and --perms is documented. Otherwise it's somewhat counter-intuitive: hard links are created, then immediately deleted, and the files transferred anyway. Thanks, Chris. diff -u generator.c.orig generator.c ===================================--- generator.c.orig 2003-03-19 15:07:29.592476000 -0500 +++ generator.c 2003-03-20 10:26:04.050060000 -0500 @@ -52,10 +52,14 @@ return 0; } if (link_dest) { - if((st->st_mode & ~_S_IFMT) != (file->mode & ~_S_IFMT)) { + extern int preserve_perms; + extern int preserve_uid; + extern int preserve_gid; + + if(preserve_perms && ((st->st_mode & ~_S_IFMT) != (file->mode & ~_S_IFMT))) { return 0; } - if (st->st_uid != file->uid || st->st_gid != file->gid) { + if((preserve_uid && st->st_uid != file->uid) || (preserve_gid && st->st_gid != file->gid)) { return 0; } } ====================================