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 b97c919..cc5c311 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 cb63f72..a374849 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 7f3212c..86a04be 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 7cc9a81..e0c99d1 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 3a44346..dc7da4d 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);