X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/d9bea2ddd44fdcfbaf6f153f72d944603560036c..7bec6a5cd6cabe93163707b901482a6692ca78cf:/rsync.c diff --git a/rsync.c b/rsync.c index 8046b705..cdf7c3ec 100644 --- a/rsync.c +++ b/rsync.c @@ -19,6 +19,8 @@ #include "rsync.h" +extern int csum_length; + extern int verbose; extern int am_server; extern int always_checksum; @@ -67,7 +69,7 @@ static void send_sums(struct sum_struct *s,int f_out) if (s) for (i=0;icount;i++) { write_int(f_out,s->sums[i].sum1); - write_buf(f_out,s->sums[i].sum2,SUM_LENGTH); + write_buf(f_out,s->sums[i].sum2,csum_length); } write_flush(f_out); } @@ -164,7 +166,7 @@ static struct sum_struct *receive_sums(int f) for (i=0;icount;i++) { s->sums[i].sum1 = read_int(f); - read_buf(f,s->sums[i].sum2,SUM_LENGTH); + read_buf(f,s->sums[i].sum2,csum_length); s->sums[i].offset = offset; s->sums[i].i = i; @@ -203,7 +205,8 @@ static void set_perms(char *fname,struct file_struct *file,struct stat *st, st = &st2; } - if (preserve_times && st->st_mtime != file->modtime) { + if (preserve_times && !S_ISLNK(st->st_mode) && + st->st_mtime != file->modtime) { updated = 1; if (set_modtime(fname,file->modtime) != 0) { fprintf(stderr,"failed to set times on %s : %s\n", @@ -213,7 +216,8 @@ static void set_perms(char *fname,struct file_struct *file,struct stat *st, } #ifdef HAVE_CHMOD - if (preserve_perms && st->st_mode != file->mode) { + if (preserve_perms && !S_ISLNK(st->st_mode) && + st->st_mode != file->mode) { updated = 1; if (chmod(fname,file->mode) != 0) { fprintf(stderr,"failed to set permissions on %s : %s\n", @@ -267,8 +271,7 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out) if (l > 0) { lnk[l] = 0; if (strcmp(lnk,flist->files[i].link) == 0) { - if (verbose > 1) - fprintf(am_server?stderr:stdout,"%s is uptodate\n",fname); + set_perms(fname,&flist->files[i],&st,1); return; } } @@ -278,8 +281,10 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out) fprintf(stderr,"link %s -> %s : %s\n", fname,flist->files[i].link,strerror(errno)); } else { + set_perms(fname,&flist->files[i],NULL,0); if (verbose) - fprintf(am_server?stderr:stdout,"%s -> %s\n",fname,flist->files[i].link); + fprintf(am_server?stderr:stdout,"%s -> %s\n", + fname,flist->files[i].link); } return; } @@ -343,7 +348,7 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out) if (st.st_size == flist->files[i].length && ((!ignore_times && st.st_mtime == flist->files[i].modtime) || (always_checksum && S_ISREG(st.st_mode) && - memcmp(sum,flist->files[i].sum,SUM_LENGTH) == 0))) { + memcmp(sum,flist->files[i].sum,csum_length) == 0))) { set_perms(fname,&flist->files[i],&st,1); return; } @@ -415,13 +420,18 @@ static void receive_data(int f_in,char *buf,int fd,char *fname) fprintf(stderr,"chunk[%d] of size %d at %d offset=%d\n", i,len,(int)offset2,(int)offset); - if (write(fd,map_ptr(buf,offset2,len),len) != len) { + if (write_sparse(fd,map_ptr(buf,offset2,len),len) != len) { fprintf(stderr,"write failed on %s : %s\n",fname,strerror(errno)); exit(1); } offset += len; } } + + if (offset > 0 && sparse_end(fd) != 0) { + fprintf(stderr,"write failed on %s : %s\n",fname,strerror(errno)); + exit(1); + } } @@ -450,6 +460,9 @@ static void delete_files(struct file_list *flist) char *dot="."; int i; + if (cvs_exclude) + add_cvs_excludes(); + if (!(local_file_list = send_file_list(-1,recurse,1,&dot))) return;