From 0b91056090d768c4bdc6aa83d929d09416d34e89 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 23 Mar 1998 08:49:48 +0000 Subject: [PATCH] started to add some 64 bit file offset support - not complete yet --- checksum.c | 4 ++-- flist.c | 1 + match.c | 14 +++++++------- rsync.c | 2 ++ rsync.h | 5 +++-- util.c | 7 +++++-- 6 files changed, 20 insertions(+), 13 deletions(-) diff --git a/checksum.c b/checksum.c index 7b8035cc..a7ee0707 100644 --- a/checksum.c +++ b/checksum.c @@ -95,11 +95,11 @@ void get_checksum2(char *buf,int len,char *sum) void file_checksum(char *fname,char *sum,off_t size) { - int i; + off_t i; MDstruct MD; struct map_struct *buf; int fd; - int len = size; + off_t len = size; char tmpchunk[CSUM_CHUNK]; bzero(sum,csum_length); diff --git a/flist.c b/flist.c index 8226b21a..d53c815f 100644 --- 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->sum) free(file->sum); bzero((char *)file, sizeof(*file)); free(file); } diff --git a/match.c b/match.c index 5c88ba5c..86f4b3ee 100644 --- 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, - 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)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; @@ -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) { - int offset,j,k; + off_t offset; + int j,k; 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) - 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; @@ -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", - offset,j,i,sum); + (int)offset,j,i,sum); if (!done_csum2) { int l = MIN(s->n,len-offset); diff --git a/rsync.c b/rsync.c index e9b5e3fe..52405309 100644 --- 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)); + free_sums(s); 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; } diff --git a/rsync.h b/rsync.h index d8c0d68a..cc349f1a 100644 --- a/rsync.h +++ b/rsync.h @@ -249,8 +249,9 @@ struct sum_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 diff --git a/util.c b/util.c index 6537717d..15cf2bcd 100644 --- a/util.c +++ b/util.c @@ -53,6 +53,7 @@ struct map_struct *map_file(int fd,off_t len) return ret; } + 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; - 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) { @@ -71,7 +73,8 @@ char *map_ptr(struct map_struct *map,off_t offset,int len) } 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); -- 2.34.1