ps. dryrun.test is work in progress. On Fri, Apr 05, 2002 at 01:08:22PM +0200, Mark Santcroos wrote: > On Tue, Apr 02, 2002 at 07:28:07PM +0200, Mark Santcroos wrote: > > Please let me know and I will create the appropriate patch. > > Here is the patch I have created vs. cvs. > > I have tried to change as little structural things as possible to get the > result. > > This basicly does what we want, please check and comment. There is 1 'bug' > and that is that in dryrun mode directories get reported twice. I couldn't > find an clean/short way to work around that. > Anyway, this is only proof of concept, more things can be added later :) > > While digging through the code it was sometimes unclear to me what the > particular piece of code does. I found the number of comments very low. > How about that we put some more description in the code to make it easier > for everyone? > I'm willing to come up with a patch that only has comments in it. > > Mark > > -- > Mark Santcroos RIPE Network Coordination Centre > http://www.ripe.net/home/mark/ New Projects Group/TTM
> Index: generator.c > =================================================================== > RCS file: /cvsroot/rsync/generator.c,v > retrieving revision 1.38 > diff -u -r1.38 generator.c > --- generator.c 25 Mar 2002 05:54:31 -0000 1.38 > +++ generator.c 5 Apr 2002 10:32:57 -0000 > @@ -239,6 +239,7 @@ > extern int list_only; > extern int preserve_perms; > extern int only_existing; > + int report = 0; > > if (list_only) return; > > @@ -268,8 +269,7 @@ > * file of that name and it is *not* a directory, then > * we need to delete it. If it doesn't exist, then > * recursively create it. */ > - > - if (dry_run) return; /* XXXX -- might cause inaccuracies?? -- mbp */ > + > if (statret == 0 && !S_ISDIR(st.st_mode)) { > if (robust_unlink(fname) != 0) { > rprintf(FERROR, RSYNC_NAME > @@ -286,11 +286,13 @@ > rprintf(FERROR, RSYNC_NAME ": recv_generator: mkdir >\"%s\": %s (2)\n", > fname,strerror(errno)); > } > - } > - /* f_out is set to -1 when doing final directory > - permission and modification time repair */ > - if (set_perms(fname,file,NULL,0) && verbose && (f_out != -1)) > - rprintf(FINFO,"%s/\n",fname); > + } else if (statret != 0) { > + log_transfer(file,fname,NULL); > + report = 0; > + } else > + report = 1; > + > + set_perms(fname,file,NULL,report); > return; > } > > @@ -389,7 +391,8 @@ > if (statret == -1) { > if (errno == ENOENT) { > write_int(f_out,i); > - if (!dry_run) send_sums(NULL,f_out); > + if (!dry_run) > + send_sums(NULL,f_out); > } else { > if (verbose > 1) > rprintf(FERROR, RSYNC_NAME > @@ -406,7 +409,8 @@ > > /* now pretend the file didn't exist */ > write_int(f_out,i); > - if (!dry_run) send_sums(NULL,f_out); > + if (!dry_run) > + send_sums(NULL,f_out); > return; > } > > Index: log.c > =================================================================== > RCS file: /cvsroot/rsync/log.c,v > retrieving revision 1.59 > diff -u -r1.59 log.c > --- log.c 18 Feb 2002 19:51:12 -0000 1.59 > +++ log.c 5 Apr 2002 10:32:57 -0000 > @@ -571,11 +571,14 @@ > * this will be called at the end where the client was run. > * Called when a file starts to be transferred. > */ > -void log_transfer(struct file_struct *file, const char *fname) > +void log_transfer(struct file_struct *file, const char *fname, const char *message) > { > extern int verbose; > > if (!verbose) return; > > - rprintf(FINFO, "%s\n", fname); > + if(message) > + rprintf(FINFO, "%s%s: %s\n", fname,S_ISDIR(file->mode)?"/":"",message); > + else > + rprintf(FINFO, "%s%s\n", fname,S_ISDIR(file->mode)?"/":""); > } > Index: proto.h > =================================================================== > RCS file: /cvsroot/rsync/proto.h,v > retrieving revision 1.144 > diff -u -r1.144 proto.h > --- proto.h 3 Apr 2002 02:33:42 -0000 1.144 > +++ proto.h 5 Apr 2002 10:32:58 -0000 > @@ -159,7 +159,7 @@ > void log_send(struct file_struct *file, struct stats *initial_stats); > void log_recv(struct file_struct *file, struct stats *initial_stats); > void log_exit(int code, const char *file, int line); > -void log_transfer(struct file_struct *file, const char *fname); > +void log_transfer(struct file_struct *file, const char *fname, const char *message); > void wait_process(pid_t pid, int *status); > void start_server(int f_in, int f_out, int argc, char *argv[]); > int client_run(int f_in, int f_out, pid_t pid, int argc, char *argv[]); > Index: receiver.c > =================================================================== > RCS file: /cvsroot/rsync/receiver.c,v > retrieving revision 1.38 > diff -u -r1.38 receiver.c > --- receiver.c 13 Feb 2002 18:42:20 -0000 1.38 > +++ receiver.c 5 Apr 2002 10:32:58 -0000 > @@ -356,7 +356,7 @@ > > if (dry_run) { > if (!am_server) { > - log_transfer(file, fname); > + log_transfer(file, fname, NULL); > } > continue; > } > @@ -449,7 +449,7 @@ > cleanup_set(fnametmp, fname, file, buf, fd1, fd2); > > if (!am_server) { > - log_transfer(file, fname); > + log_transfer(file, fname, NULL); > } > > /* recv file data */ > Index: rsync.c > =================================================================== > RCS file: /cvsroot/rsync/rsync.c,v > retrieving revision 1.119 > diff -u -r1.119 rsync.c > --- rsync.c 20 Dec 2001 15:33:13 -0000 1.119 > +++ rsync.c 5 Apr 2002 10:32:58 -0000 > @@ -151,10 +151,8 @@ > STRUCT_STAT st2; > int change_uid, change_gid; > > - if (dry_run) return 0; > - > if (!st) { > - if (link_stat(fname,&st2) != 0) { > + if (link_stat(fname,&st2) != 0 && !dry_run) { > rprintf(FERROR,"stat %s : %s\n",fname,strerror(errno)); > return 0; > } > @@ -199,12 +197,16 @@ > link_stat(fname, st); > } > updated = 1; > + if(verbose && report) > + log_transfer(file,fname,"owner diff"); > } > > #ifdef HAVE_CHMOD > if (!S_ISLNK(st->st_mode)) { > if (st->st_mode != file->mode) { > updated = 1; > + if(verbose && report) > + log_transfer(file,fname,"permission diff"); > if (do_chmod(fname,file->mode) != 0) { > rprintf(FERROR,"failed to set permissions on %s : >%s\n", > fname,strerror(errno)); > Index: sender.c > =================================================================== > RCS file: /cvsroot/rsync/sender.c,v > retrieving revision 1.15 > diff -u -r1.15 sender.c > --- sender.c 25 Jan 2002 23:07:33 -0000 1.15 > +++ sender.c 5 Apr 2002 10:32:58 -0000 > @@ -150,7 +150,7 @@ > > if (dry_run) { > if (!am_server) { > - log_transfer(file, fname+offset); > + log_transfer(file, fname+offset, NULL); > } > write_int(f_out,i); > continue; > @@ -212,7 +212,7 @@ > rprintf(FINFO,"calling match_sums %s\n",fname); > > if (!am_server) { > - log_transfer(file, fname+offset); > + log_transfer(file, fname+offset, NULL); > } > > set_compression(fname); -- Mark Santcroos RIPE Network Coordination Centre http://www.ripe.net/home/mark/ New Projects Group/TTM -- To unsubscribe or change options: http://lists.samba.org/mailman/listinfo/rsync Before posting, read: http://www.tuxedo.org/~esr/faqs/smart-questions.html