fix a problem with files > 2GB
authorAndrew Tridgell <tridge@samba.org>
Sun, 23 Jan 2000 12:30:34 +0000 (12:30 +0000)
committerAndrew Tridgell <tridge@samba.org>
Sun, 23 Jan 2000 12:30:34 +0000 (12:30 +0000)
(thanks to T.J.Adye@rl.ac.uk)

flist.c
generator.c
match.c
receiver.c
sender.c

diff --git a/flist.c b/flist.c
index b97c919eefd03bf5dde3e8579d63defefb33fe26..cc5c3113b89245cf283a8e5ecba4e1b6becb10dd 100644 (file)
--- 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;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, 
                        NS(flist->files[i]->dirname),
                        NS(flist->files[i]->basename),
                        flist->files[i]->mode,
-                       (int)flist->files[i]->length);
+                       (double)flist->files[i]->length);
        }
 }
 
index cb63f72eba9737b9f9ed17aa65bbe37b4d2cde46..a374849cd38281a52776c05f9f86a01805699501 100644 (file)
@@ -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 7f3212c8a4d279200c4589edf1f7693d96f050b1..86a04bed1546964437562836b1005aad0bbe45ec 100644 (file)
--- 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);
index 7cc9a81d00a26b8b1286d8fbe389cc3fb6736db0..e0c99d10a76a27ac9e7184e408fac5f80df0265c 100644 (file)
@@ -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;
                }
index 3a443468b1a822da6890936598bbae1aaf933d2f..dc7da4dcff435c3c1f29e3bf3cb47dfc1cc990e3 100644 (file)
--- 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);