Commit 5f808dfb authored by Andrew Tridgell's avatar Andrew Tridgell

fix a problem with files > 2GB

(thanks to T.J.Adye@rl.ac.uk)
parent 0b73ca12
...@@ -999,12 +999,12 @@ static void clean_flist(struct file_list *flist, int strip_root) ...@@ -999,12 +999,12 @@ static void clean_flist(struct file_list *flist, int strip_root)
if (verbose <= 3) return; if (verbose <= 3) return;
for (i=0;i<flist->count;i++) { for (i=0;i<flist->count;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, getpid(), i,
NS(flist->files[i]->dirname), NS(flist->files[i]->dirname),
NS(flist->files[i]->basename), NS(flist->files[i]->basename),
flist->files[i]->mode, flist->files[i]->mode,
(int)flist->files[i]->length); (double)flist->files[i]->length);
} }
} }
......
...@@ -136,8 +136,8 @@ static struct sum_struct *generate_sums(struct map_struct *buf,OFF_T len,int n) ...@@ -136,8 +136,8 @@ static struct sum_struct *generate_sums(struct map_struct *buf,OFF_T len,int n)
} }
if (verbose > 3) if (verbose > 3)
rprintf(FINFO,"count=%d rem=%d n=%d flength=%d\n", rprintf(FINFO,"count=%d rem=%d n=%d flength=%.0f\n",
s->count,s->remainder,s->n,(int)s->flength); s->count,s->remainder,s->n,(double)s->flength);
s->sums = (struct sum_buf *)malloc(sizeof(s->sums[0])*s->count); s->sums = (struct sum_buf *)malloc(sizeof(s->sums[0])*s->count);
if (!s->sums) out_of_memory("generate_sums"); 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) ...@@ -154,8 +154,8 @@ static struct sum_struct *generate_sums(struct map_struct *buf,OFF_T len,int n)
s->sums[i].i = i; s->sums[i].i = i;
if (verbose > 3) if (verbose > 3)
rprintf(FINFO,"chunk[%d] offset=%d len=%d sum1=%08x\n", rprintf(FINFO,"chunk[%d] offset=%.0f len=%d sum1=%08x\n",
i,(int)s->sums[i].offset,s->sums[i].len,s->sums[i].sum1); i,(double)s->sums[i].offset,s->sums[i].len,s->sums[i].sum1);
len -= n1; len -= n1;
offset += n1; offset += n1;
...@@ -374,7 +374,7 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out) ...@@ -374,7 +374,7 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
} }
if (verbose > 3) 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)); s = generate_sums(buf,st.st_size,adapt_block_size(file, block_size));
......
...@@ -97,8 +97,8 @@ static void matched(int f,struct sum_struct *s,struct map_struct *buf, ...@@ -97,8 +97,8 @@ static void matched(int f,struct sum_struct *s,struct map_struct *buf,
OFF_T j; OFF_T j;
if (verbose > 2 && i >= 0) if (verbose > 2 && i >= 0)
rprintf(FINFO,"match at %d last_match=%d j=%d len=%d n=%d\n", rprintf(FINFO,"match at %.0f last_match=%.0f j=%d len=%d n=%.0f\n",
(int)offset,(int)last_match,i,(int)s->sums[i].len,(int)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); send_token(f,i,buf,last_match,n,i<0?0:s->sums[i].len);
data_transfer += n; data_transfer += n;
...@@ -129,9 +129,8 @@ static void matched(int f,struct sum_struct *s,struct map_struct *buf, ...@@ -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, static void hash_search(int f,struct sum_struct *s,
struct map_struct *buf,OFF_T len) struct map_struct *buf,OFF_T len)
{ {
OFF_T offset; OFF_T offset, end;
int j,k, last_i; int j,k, last_i;
int end;
char sum2[SUM_LENGTH]; char sum2[SUM_LENGTH];
uint32 s1, s2, sum; uint32 s1, s2, sum;
schar *map; schar *map;
...@@ -141,7 +140,7 @@ static void hash_search(int f,struct sum_struct *s, ...@@ -141,7 +140,7 @@ static void hash_search(int f,struct sum_struct *s,
last_i = -1; last_i = -1;
if (verbose > 2) 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); k = MIN(len, s->n);
...@@ -158,8 +157,8 @@ static void hash_search(int f,struct sum_struct *s, ...@@ -158,8 +157,8 @@ static void hash_search(int f,struct sum_struct *s,
end = len + 1 - s->sums[s->count-1].len; end = len + 1 - s->sums[s->count-1].len;
if (verbose > 3) if (verbose > 3)
rprintf(FINFO,"hash search s->n=%d len=%d count=%d\n", rprintf(FINFO,"hash search s->n=%d len=%.0f count=%d\n",
s->n,(int)len,s->count); s->n,(double)len,s->count);
do { do {
tag t = gettag2(s1,s2); tag t = gettag2(s1,s2);
...@@ -167,7 +166,7 @@ static void hash_search(int f,struct sum_struct *s, ...@@ -167,7 +166,7 @@ static void hash_search(int f,struct sum_struct *s,
j = tag_table[t]; j = tag_table[t];
if (verbose > 4) 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) { if (j == NULL_TAG) {
goto null_tag; goto null_tag;
...@@ -185,8 +184,8 @@ static void hash_search(int f,struct sum_struct *s, ...@@ -185,8 +184,8 @@ static void hash_search(int f,struct sum_struct *s,
if (l != s->sums[i].len) continue; if (l != s->sums[i].len) continue;
if (verbose > 3) if (verbose > 3)
rprintf(FINFO,"potential match at %d target=%d %d sum=%08x\n", rprintf(FINFO,"potential match at %.0f target=%d %d sum=%08x\n",
(int)offset,j,i,sum); (double)offset,j,i,sum);
if (!done_csum2) { if (!done_csum2) {
map = (schar *)map_ptr(buf,offset,l); map = (schar *)map_ptr(buf,offset,l);
......
...@@ -225,8 +225,8 @@ static int receive_data(int f_in,struct map_struct *buf,int fd,char *fname, ...@@ -225,8 +225,8 @@ static int receive_data(int f_in,struct map_struct *buf,int fd,char *fname,
extern int cleanup_got_literal; extern int cleanup_got_literal;
if (verbose > 3) { if (verbose > 3) {
rprintf(FINFO,"data recv %d at %d\n", rprintf(FINFO,"data recv %d at %.0f\n",
i,(int)offset); i,(double)offset);
} }
stats.literal_data += i; stats.literal_data += i;
...@@ -243,7 +243,7 @@ static int receive_data(int f_in,struct map_struct *buf,int fd,char *fname, ...@@ -243,7 +243,7 @@ static int receive_data(int f_in,struct map_struct *buf,int fd,char *fname,
} }
i = -(i+1); i = -(i+1);
offset2 = i*n; offset2 = i*(OFF_T)n;
len = n; len = n;
if (i == count-1 && remainder != 0) if (i == count-1 && remainder != 0)
len = remainder; len = remainder;
...@@ -251,8 +251,8 @@ static int receive_data(int f_in,struct map_struct *buf,int fd,char *fname, ...@@ -251,8 +251,8 @@ static int receive_data(int f_in,struct map_struct *buf,int fd,char *fname,
stats.matched_data += len; stats.matched_data += len;
if (verbose > 3) if (verbose > 3)
rprintf(FINFO,"chunk[%d] of size %d at %d offset=%d\n", rprintf(FINFO,"chunk[%d] of size %d at %.0f offset=%.0f\n",
i,len,(int)offset2,(int)offset); i,len,(double)offset2,(double)offset);
map = map_ptr(buf,offset2,len); 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) ...@@ -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) { if (fd1 != -1 && st.st_size > 0) {
buf = map_file(fd1,st.st_size); buf = map_file(fd1,st.st_size);
if (verbose > 2) 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 { } else {
buf = NULL; buf = NULL;
} }
......
...@@ -70,8 +70,8 @@ static struct sum_struct *receive_sums(int f) ...@@ -70,8 +70,8 @@ static struct sum_struct *receive_sums(int f)
offset += s->sums[i].len; offset += s->sums[i].len;
if (verbose > 3) if (verbose > 3)
rprintf(FINFO,"chunk[%d] len=%d offset=%d sum1=%08x\n", rprintf(FINFO,"chunk[%d] len=%d offset=%.0f sum1=%08x\n",
i,s->sums[i].len,(int)s->sums[i].offset,s->sums[i].sum1); i,s->sums[i].len,(double)s->sums[i].offset,s->sums[i].sum1);
} }
s->flength = offset; s->flength = offset;
...@@ -185,8 +185,8 @@ void send_files(struct file_list *flist,int f_out,int f_in) ...@@ -185,8 +185,8 @@ void send_files(struct file_list *flist,int f_out,int f_in)
} }
if (verbose > 2) if (verbose > 2)
rprintf(FINFO,"send_files mapped %s of size %d\n", rprintf(FINFO,"send_files mapped %s of size %.0f\n",
fname,(int)st.st_size); fname,(double)st.st_size);
write_int(f_out,i); write_int(f_out,i);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment