summaryrefslogtreecommitdiff
path: root/generator.c
diff options
context:
space:
mode:
authorDavid Dykstra <dwd@samba.org>1998-10-26 21:42:38 +0000
committerDavid Dykstra <dwd@samba.org>1998-10-26 21:42:38 +0000
commit375a4556c7a1ffb9a4e7117f33fc42ed2bc4c026 (patch)
tree8eed21c09eff5475c9b9be2c639d9b6f189865e1 /generator.c
parentb41c3f92738709adf79a1d77f8e7e75752bd1adf (diff)
downloadrsync-375a4556c7a1ffb9a4e7117f33fc42ed2bc4c026.tar.gz
rsync-375a4556c7a1ffb9a4e7117f33fc42ed2bc4c026.tar.bz2
rsync-375a4556c7a1ffb9a4e7117f33fc42ed2bc4c026.zip
Add --compare-dest option which enables specifying an additional destination
for comparisons when syncing. Useful for syncing into a scratch area and doing a flash-cutover when it is completed.
Diffstat (limited to 'generator.c')
-rw-r--r--generator.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/generator.c b/generator.c
index ffde4444..99052220 100644
--- a/generator.c
+++ b/generator.c
@@ -162,6 +162,9 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
struct sum_struct *s;
int statret;
struct file_struct *file = flist->files[i];
+ char *fnamecmp;
+ char fnamecmpbuf[MAXPATHLEN];
+ extern char *compare_dest;
if (verbose > 2)
rprintf(FINFO,"recv_generator(%s,%d)\n",fname,i);
@@ -262,6 +265,21 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
return;
}
+ fnamecmp = fname;
+
+ if ((statret == -1) && (compare_dest != NULL)) {
+ /* try the file at compare_dest instead */
+ int saveerrno = errno;
+ slprintf(fnamecmpbuf,MAXPATHLEN-1,"%s/%s",compare_dest,fname);
+ statret = link_stat(fnamecmpbuf,&st);
+ if (!S_ISREG(st.st_mode))
+ statret = -1;
+ if (statret == -1)
+ errno = saveerrno;
+ else
+ fnamecmp = fnamecmpbuf;
+ }
+
if (statret == -1) {
if (errno == ENOENT) {
write_int(f_out,i);
@@ -284,7 +302,7 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
return;
}
- if (update_only && st.st_mtime > file->modtime) {
+ if (update_only && st.st_mtime > file->modtime && fnamecmp == fname) {
if (verbose > 1)
rprintf(FINFO,"%s is newer\n",fname);
return;
@@ -307,10 +325,10 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
}
/* open the file */
- fd = open(fname,O_RDONLY);
+ fd = open(fnamecmp,O_RDONLY);
if (fd == -1) {
- rprintf(FERROR,"failed to open %s : %s\n",fname,strerror(errno));
+ rprintf(FERROR,"failed to open %s : %s\n",fnamecmp,strerror(errno));
rprintf(FERROR,"skipping %s\n",fname);
return;
}
@@ -322,7 +340,7 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
}
if (verbose > 3)
- rprintf(FINFO,"gen mapped %s of size %d\n",fname,(int)st.st_size);
+ rprintf(FINFO,"gen mapped %s of size %d\n",fnamecmp,(int)st.st_size);
s = generate_sums(buf,st.st_size,adapt_block_size(file, block_size));