From 5f808dfbd71b0e40d0fd2976dceb2feaf024b6ca Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 23 Jan 2000 12:30:34 +0000 Subject: [PATCH] fix a problem with files > 2GB (thanks to T.J.Adye@rl.ac.uk) --- flist.c | 4 ++-- generator.c | 10 +++++----- match.c | 19 +++++++++---------- receiver.c | 12 ++++++------ sender.c | 8 ++++---- 5 files changed, 26 insertions(+), 27 deletions(-) diff --git a/flist.c b/flist.c index b97c919e..cc5c3113 100644 --- a/flist.c +++ b/flist.c @@ -999,12 +999,12 @@ static void clean_flist(struct file_list *flist, int strip_root) if (verbose <= 3) return; for (i=0;icount;i++) { - rprintf(FINFO,"[%d] i=%d %s %s mode=0%o len=%d\n", + rprintf(FINFO,"[%d] i=%d %s %s mode=0%o len=%.0f\n", getpid(), i, NS(flist->files[i]->dirname), NS(flist->files[i]->basename), flist->files[i]->mode, - (int)flist->files[i]->length); + (double)flist->files[i]->length); } } diff --git a/generator.c b/generator.c index cb63f72e..a374849c 100644 --- a/generator.c +++ b/generator.c @@ -136,8 +136,8 @@ static struct sum_struct *generate_sums(struct map_struct *buf,OFF_T len,int n) } if (verbose > 3) - rprintf(FINFO,"count=%d rem=%d n=%d flength=%d\n", - s->count,s->remainder,s->n,(int)s->flength); + rprintf(FINFO,"count=%d rem=%d n=%d flength=%.0f\n", + s->count,s->remainder,s->n,(double)s->flength); s->sums = (struct sum_buf *)malloc(sizeof(s->sums[0])*s->count); if (!s->sums) out_of_memory("generate_sums"); @@ -154,8 +154,8 @@ static struct sum_struct *generate_sums(struct map_struct *buf,OFF_T len,int n) s->sums[i].i = i; if (verbose > 3) - rprintf(FINFO,"chunk[%d] offset=%d len=%d sum1=%08x\n", - i,(int)s->sums[i].offset,s->sums[i].len,s->sums[i].sum1); + rprintf(FINFO,"chunk[%d] offset=%.0f len=%d sum1=%08x\n", + i,(double)s->sums[i].offset,s->sums[i].len,s->sums[i].sum1); len -= n1; offset += n1; @@ -374,7 +374,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",fnamecmp,(int)st.st_size); + rprintf(FINFO,"gen mapped %s of size %.0f\n",fnamecmp,(double)st.st_size); s = generate_sums(buf,st.st_size,adapt_block_size(file, block_size)); diff --git a/match.c b/match.c index 7f3212c8..86a04bed 100644 --- a/match.c +++ b/match.c @@ -97,8 +97,8 @@ static void matched(int f,struct sum_struct *s,struct map_struct *buf, OFF_T j; if (verbose > 2 && i >= 0) - rprintf(FINFO,"match at %d last_match=%d j=%d len=%d n=%d\n", - (int)offset,(int)last_match,i,(int)s->sums[i].len,(int)n); + rprintf(FINFO,"match at %.0f last_match=%.0f j=%d len=%d n=%.0f\n", + (double)offset,(double)last_match,i,s->sums[i].len,(double)n); send_token(f,i,buf,last_match,n,i<0?0:s->sums[i].len); data_transfer += n; @@ -129,9 +129,8 @@ static void matched(int f,struct sum_struct *s,struct map_struct *buf, static void hash_search(int f,struct sum_struct *s, struct map_struct *buf,OFF_T len) { - OFF_T offset; + OFF_T offset, end; int j,k, last_i; - int end; char sum2[SUM_LENGTH]; uint32 s1, s2, sum; schar *map; @@ -141,7 +140,7 @@ static void hash_search(int f,struct sum_struct *s, last_i = -1; if (verbose > 2) - rprintf(FINFO,"hash search b=%d len=%d\n",s->n,(int)len); + rprintf(FINFO,"hash search b=%d len=%.0f\n",s->n,(double)len); k = MIN(len, s->n); @@ -158,8 +157,8 @@ static void hash_search(int f,struct sum_struct *s, end = len + 1 - s->sums[s->count-1].len; if (verbose > 3) - rprintf(FINFO,"hash search s->n=%d len=%d count=%d\n", - s->n,(int)len,s->count); + rprintf(FINFO,"hash search s->n=%d len=%.0f count=%d\n", + s->n,(double)len,s->count); do { tag t = gettag2(s1,s2); @@ -167,7 +166,7 @@ static void hash_search(int f,struct sum_struct *s, j = tag_table[t]; if (verbose > 4) - rprintf(FINFO,"offset=%d sum=%08x\n",(int)offset,sum); + rprintf(FINFO,"offset=%.0f sum=%08x\n",(double)offset,sum); if (j == NULL_TAG) { goto null_tag; @@ -185,8 +184,8 @@ static void hash_search(int f,struct sum_struct *s, if (l != s->sums[i].len) continue; if (verbose > 3) - rprintf(FINFO,"potential match at %d target=%d %d sum=%08x\n", - (int)offset,j,i,sum); + rprintf(FINFO,"potential match at %.0f target=%d %d sum=%08x\n", + (double)offset,j,i,sum); if (!done_csum2) { map = (schar *)map_ptr(buf,offset,l); diff --git a/receiver.c b/receiver.c index 7cc9a81d..e0c99d10 100644 --- a/receiver.c +++ b/receiver.c @@ -225,8 +225,8 @@ static int receive_data(int f_in,struct map_struct *buf,int fd,char *fname, extern int cleanup_got_literal; if (verbose > 3) { - rprintf(FINFO,"data recv %d at %d\n", - i,(int)offset); + rprintf(FINFO,"data recv %d at %.0f\n", + i,(double)offset); } stats.literal_data += i; @@ -243,7 +243,7 @@ static int receive_data(int f_in,struct map_struct *buf,int fd,char *fname, } i = -(i+1); - offset2 = i*n; + offset2 = i*(OFF_T)n; len = n; if (i == count-1 && remainder != 0) len = remainder; @@ -251,8 +251,8 @@ static int receive_data(int f_in,struct map_struct *buf,int fd,char *fname, stats.matched_data += len; if (verbose > 3) - rprintf(FINFO,"chunk[%d] of size %d at %d offset=%d\n", - i,len,(int)offset2,(int)offset); + rprintf(FINFO,"chunk[%d] of size %d at %.0f offset=%.0f\n", + i,len,(double)offset2,(double)offset); map = map_ptr(buf,offset2,len); @@ -400,7 +400,7 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen) if (fd1 != -1 && st.st_size > 0) { buf = map_file(fd1,st.st_size); if (verbose > 2) - rprintf(FINFO,"recv mapped %s of size %d\n",fnamecmp,(int)st.st_size); + rprintf(FINFO,"recv mapped %s of size %.0f\n",fnamecmp,(double)st.st_size); } else { buf = NULL; } diff --git a/sender.c b/sender.c index 3a443468..dc7da4dc 100644 --- a/sender.c +++ b/sender.c @@ -70,8 +70,8 @@ static struct sum_struct *receive_sums(int f) offset += s->sums[i].len; if (verbose > 3) - rprintf(FINFO,"chunk[%d] len=%d offset=%d sum1=%08x\n", - i,s->sums[i].len,(int)s->sums[i].offset,s->sums[i].sum1); + rprintf(FINFO,"chunk[%d] len=%d offset=%.0f sum1=%08x\n", + i,s->sums[i].len,(double)s->sums[i].offset,s->sums[i].sum1); } s->flength = offset; @@ -185,8 +185,8 @@ void send_files(struct file_list *flist,int f_out,int f_in) } if (verbose > 2) - rprintf(FINFO,"send_files mapped %s of size %d\n", - fname,(int)st.st_size); + rprintf(FINFO,"send_files mapped %s of size %.0f\n", + fname,(double)st.st_size); write_int(f_out,i); -- 2.34.1