X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/96d910c770b9443e204e183d3f3a8720c346a79c..82471e68a8bb3da8ca95f2b6564c330c52ce891e:/sender.c diff --git a/sender.c b/sender.c index 1436eb6c..741a8d24 100644 --- a/sender.c +++ b/sender.c @@ -27,6 +27,9 @@ extern int dry_run; extern int am_server; extern int am_daemon; extern int protocol_version; +extern int updating_basis_file; +extern int make_backups; +extern int inplace; extern struct stats stats; @@ -37,22 +40,6 @@ extern struct stats stats; * and transmits them to the receiver. The sender process runs on the * machine holding the source files. **/ -void read_sum_head(int f, struct sum_struct *sum) -{ - sum->count = read_int(f); - sum->blength = read_int(f); - if (protocol_version < 27) { - sum->s2length = csum_length; - } else { - sum->s2length = read_int(f); - if (sum->s2length > MD4_SUM_LENGTH) { - rprintf(FERROR, "Invalid checksum length %ld\n", - (long)sum->s2length); - exit_cleanup(RERR_PROTOCOL); - } - } - sum->remainder = read_int(f); -} /** * Receive the checksums for a buffer @@ -71,8 +58,8 @@ static struct sum_struct *receive_sums(int f) s->sums = NULL; if (verbose > 3) { - rprintf(FINFO, "count=%ld n=%u rem=%u\n", - (long)s->count, s->blength, s->remainder); + rprintf(FINFO, "count=%.0f n=%ld rem=%ld\n", + (double)s->count, (long)s->blength, (long)s->remainder); } if (s->count == 0) @@ -120,6 +107,7 @@ void send_files(struct file_list *flist, int f_out, int f_in) struct file_struct *file; int phase = 0; struct stats initial_stats; + int save_make_backups = make_backups; int j; if (verbose > 2) @@ -136,6 +124,9 @@ void send_files(struct file_list *flist, int f_out, int f_in) write_int(f_out, -1); if (verbose > 2) rprintf(FINFO, "send_files phase=%d\n", phase); + /* For inplace: redo phase turns off the backup + * flag so that we do a regular inplace send. */ + make_backups = 0; continue; } break; @@ -161,6 +152,11 @@ void send_files(struct file_list *flist, int f_out, int f_in) } else offset = 0; fname2 = f_name_to(file, fname + offset); + if (inplace && protocol_version >= 29) { + uchar fnamecmp_type = read_byte(f_in); + updating_basis_file = fnamecmp_type == FNAMECMP_FNAME; + } else + updating_basis_file = inplace && !make_backups; if (verbose > 2) rprintf(FINFO, "send_files(%d, %s)\n", i, fname); @@ -209,8 +205,8 @@ void send_files(struct file_list *flist, int f_out, int f_in) } if (st.st_size) { - OFF_T map_size = MAX(s->blength * 3, MAX_MAP_SIZE); - mbuf = map_file(fd, st.st_size, map_size, s->blength); + int32 read_size = MAX(s->blength * 3, MAX_MAP_SIZE); + mbuf = map_file(fd, st.st_size, read_size, s->blength); } else mbuf = NULL; @@ -253,6 +249,7 @@ void send_files(struct file_list *flist, int f_out, int f_in) safe_fname(fname)); } } + make_backups = save_make_backups; if (verbose > 2) rprintf(FINFO, "send files finished\n");