started to add some 64 bit file offset support - not complete yet
authorAndrew Tridgell <tridge@samba.org>
Mon, 23 Mar 1998 08:49:48 +0000 (08:49 +0000)
committerAndrew Tridgell <tridge@samba.org>
Mon, 23 Mar 1998 08:49:48 +0000 (08:49 +0000)
checksum.c
flist.c
match.c
rsync.c
rsync.h
util.c

index 7b8035cc95489227130288f1be8ac8119587fb9f..a7ee07074cebcab7493c52d30d1c038b692bb2a1 100644 (file)
@@ -95,11 +95,11 @@ void get_checksum2(char *buf,int len,char *sum)
 
 void file_checksum(char *fname,char *sum,off_t size)
 {
 
 void file_checksum(char *fname,char *sum,off_t size)
 {
-  int i;
+  off_t i;
   MDstruct MD;
   struct map_struct *buf;
   int fd;
   MDstruct MD;
   struct map_struct *buf;
   int fd;
-  int len = size;
+  off_t len = size;
   char tmpchunk[CSUM_CHUNK];
 
   bzero(sum,csum_length);
   char tmpchunk[CSUM_CHUNK];
 
   bzero(sum,csum_length);
diff --git a/flist.c b/flist.c
index 8226b21a1b20873089e620f142cf8058f19a0e04..d53c815f98ba190982e37e2da4a2a3f764d785bf 100644 (file)
--- a/flist.c
+++ b/flist.c
@@ -728,6 +728,7 @@ static void free_file(struct file_struct *file)
        if (!file) return;
        if (file->basename) free(file->basename);
        if (file->link) free(file->link);
        if (!file) return;
        if (file->basename) free(file->basename);
        if (file->link) free(file->link);
+       if (file->sum) free(file->sum);
        bzero((char *)file, sizeof(*file));
        free(file);
 }
        bzero((char *)file, sizeof(*file));
        free(file);
 }
diff --git a/match.c b/match.c
index 5c88ba5c65e1bf003ca13060a8b0b06e81805aee..86f4b3eea63e5d3a35e14bbad409cc9f3be3847f 100644 (file)
--- a/match.c
+++ b/match.c
@@ -91,14 +91,14 @@ static off_t last_match;
 
 
 static void matched(int f,struct sum_struct *s,struct map_struct *buf,
 
 
 static void matched(int f,struct sum_struct *s,struct map_struct *buf,
-                   int offset,int i)
+                   off_t offset,int i)
 {
 {
-       int n = offset - last_match;
+       off_t n = offset - last_match;
        int j;
 
        if (verbose > 2 && i != -1)
                fprintf(FERROR,"match at %d last_match=%d j=%d len=%d n=%d\n",
        int j;
 
        if (verbose > 2 && i != -1)
                fprintf(FERROR,"match at %d last_match=%d j=%d len=%d n=%d\n",
-                       (int)offset,(int)last_match,i,(int)s->sums[i].len,n);
+                       (int)offset,(int)last_match,i,(int)s->sums[i].len,(int)n);
 
        send_token(f,i,buf,last_match,n,i==-1?0:s->sums[i].len);
        data_transfer += n;
 
        send_token(f,i,buf,last_match,n,i==-1?0:s->sums[i].len);
        data_transfer += n;
@@ -123,7 +123,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)
 {
 static void hash_search(int f,struct sum_struct *s,
                        struct map_struct *buf,off_t len)
 {
-       int offset,j,k;
+       off_t offset;
+       int j,k;
        int end;
        char sum2[SUM_LENGTH];
        uint32 s1, s2, sum; 
        int end;
        char sum2[SUM_LENGTH];
        uint32 s1, s2, sum; 
@@ -156,8 +157,7 @@ static void hash_search(int f,struct sum_struct *s,
                        
                j = tag_table[t];
                if (verbose > 4)
                        
                j = tag_table[t];
                if (verbose > 4)
-                       fprintf(FERROR,"offset=%d sum=%08x\n",
-                               offset,sum);
+                       fprintf(FERROR,"offset=%d sum=%08x\n",(int)offset,sum);
                
                if (j == NULL_TAG) {
                        goto null_tag;
                
                if (j == NULL_TAG) {
                        goto null_tag;
@@ -172,7 +172,7 @@ static void hash_search(int f,struct sum_struct *s,
                        
                        if (verbose > 3)
                                fprintf(FERROR,"potential match at %d target=%d %d sum=%08x\n",
                        
                        if (verbose > 3)
                                fprintf(FERROR,"potential match at %d target=%d %d sum=%08x\n",
-                                       offset,j,i,sum);
+                                       (int)offset,j,i,sum);
                        
                        if (!done_csum2) {
                                int l = MIN(s->n,len-offset);
                        
                        if (!done_csum2) {
                                int l = MIN(s->n,len-offset);
diff --git a/rsync.c b/rsync.c
index e9b5e3fecb83289b057be34dab07d57beb003d38..524053097842f43cd799ae9aeff24e52f39e3f0b 100644 (file)
--- a/rsync.c
+++ b/rsync.c
@@ -936,12 +936,14 @@ off_t send_files(struct file_list *flist,int f_out,int f_in)
          if (fd == -1) {
                  fprintf(FERROR,"send_files failed to open %s: %s\n",
                          fname,strerror(errno));
          if (fd == -1) {
                  fprintf(FERROR,"send_files failed to open %s: %s\n",
                          fname,strerror(errno));
+                 free_sums(s);
                  continue;
          }
          
          /* map the local file */
          if (fstat(fd,&st) != 0) {
                  fprintf(FERROR,"fstat failed : %s\n",strerror(errno));
                  continue;
          }
          
          /* map the local file */
          if (fstat(fd,&st) != 0) {
                  fprintf(FERROR,"fstat failed : %s\n",strerror(errno));
+                 free_sums(s);
                  close(fd);
                  return -1;
          }
                  close(fd);
                  return -1;
          }
diff --git a/rsync.h b/rsync.h
index d8c0d68a323aa033ecb652839587a578a4dd8dc5..cc349f1af6756a3add060b9b6b1e11d18ab29aac 100644 (file)
--- a/rsync.h
+++ b/rsync.h
@@ -249,8 +249,9 @@ struct sum_struct {
 };
 
 struct map_struct {
 };
 
 struct map_struct {
-  char *map,*p;
-  int fd,size,p_size,p_offset,p_len;
+       char *map,*p;
+       int fd,p_size,p_len;
+       off_t size, p_offset;
 };
 
 /* we need this function because of the silly way in which duplicate
 };
 
 /* we need this function because of the silly way in which duplicate
diff --git a/util.c b/util.c
index 6537717db8a32d8ff1d840c3407b625459fedac4..15cf2bcd1d3a05e53ac75ee5adafc83ea96fb8f2 100644 (file)
--- a/util.c
+++ b/util.c
@@ -53,6 +53,7 @@ struct map_struct *map_file(int fd,off_t len)
   return ret;
 }
 
   return ret;
 }
 
+
 char *map_ptr(struct map_struct *map,off_t offset,int len)
 {
   int nread = -2;
 char *map_ptr(struct map_struct *map,off_t offset,int len)
 {
   int nread = -2;
@@ -63,7 +64,8 @@ char *map_ptr(struct map_struct *map,off_t offset,int len)
   if (len == 0) 
     return NULL;
 
   if (len == 0) 
     return NULL;
 
-  len = MIN(len,map->size-offset);
+  if (len > (map->size-offset))
+      len = map->size-offset;
 
   if (offset >= map->p_offset && 
       offset+len <= map->p_offset+map->p_len) {
 
   if (offset >= map->p_offset && 
       offset+len <= map->p_offset+map->p_len) {
@@ -71,7 +73,8 @@ char *map_ptr(struct map_struct *map,off_t offset,int len)
   }
 
   len = MAX(len,CHUNK_SIZE);
   }
 
   len = MAX(len,CHUNK_SIZE);
-  len = MIN(len,map->size - offset);  
+  if (len > (map->size-offset))
+      len = map->size-offset;
 
   if (len > map->p_size) {
     if (map->p) free(map->p);
 
   if (len > map->p_size) {
     if (map->p) free(map->p);