- on systems (such as intel linux) where off_t is 32 bits but "long long"
authorAndrew Tridgell <tridge@samba.org>
Wed, 25 Mar 1998 11:08:32 +0000 (11:08 +0000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 25 Mar 1998 11:08:32 +0000 (11:08 +0000)
  is 64 bits use long long to get the totals right when transferring
  more than 2^32 bytes of data.

- use inline on flist_up if the compiler supports it

flist.c
io.c
main.c
match.c
rsync.c
rsync.h

diff --git a/flist.c b/flist.c
index a4ae248..0aa1eea 100644 (file)
--- a/flist.c
+++ b/flist.c
@@ -26,7 +26,7 @@ extern int csum_length;
 extern int verbose;
 extern int am_server;
 extern int always_checksum;
-extern off_t total_size;
+extern int64 total_size;
 
 extern int cvs_exclude;
 
diff --git a/io.c b/io.c
index 75127f0..aae64b7 100644 (file)
--- a/io.c
+++ b/io.c
   */
 #include "rsync.h"
 
-static off_t total_written;
-static off_t total_read;
+static int64 total_written;
+static int64 total_read;
 
 extern int verbose;
 extern int sparse_files;
 
-off_t write_total(void)
+int64 write_total(void)
 {
   return total_written;
 }
 
-off_t read_total(void)
+int64 read_total(void)
 {
   return total_read;
 }
@@ -145,17 +145,20 @@ int read_int(int f)
   return IVAL(b,0);
 }
 
-off_t read_longint(int f)
+int64 read_longint(int f)
 {
        extern int remote_version;
-       off_t ret;
+       int64 ret;
        char b[8];
        ret = read_int(f);
-       if (ret == -1 && remote_version >= 16) {
-               if (sizeof(off_t) <= 4) {
-                       fprintf(FERROR,"Integer overflow - attempted 64 bit offset\n");
-                       exit_cleanup(1);
-               }
+
+       if (ret != -1) return ret;
+
+#ifndef HAVE_LONGLONG
+       fprintf(FERROR,"Integer overflow - attempted 64 bit offset\n");
+       exit_cleanup(1);
+#else
+       if (remote_version >= 16) {
                if ((ret=readfd(f,b,8)) != 8) {
                        if (verbose > 1) 
                                fprintf(FERROR,"(%d) Error reading %d bytes : %s\n",
@@ -163,8 +166,10 @@ off_t read_longint(int f)
                        exit_cleanup(1);
                }
                total_read += 8;
-               ret = IVAL(b,0) | (((off_t)IVAL(b,4))<<32);
+               ret = IVAL(b,0) | (((int64)IVAL(b,4))<<32);
        }
+#endif
+
        return ret;
 }
 
@@ -318,7 +323,7 @@ void write_int(int f,int x)
   total_written += 4;
 }
 
-void write_longint(int f, off_t x)
+void write_longint(int f, int64 x)
 {
        extern int remote_version;
        char b[8];
diff --git a/main.c b/main.c
index d476e21..206a24c 100644 (file)
--- a/main.c
+++ b/main.c
@@ -22,7 +22,7 @@
 int verbose = 0;
 int always_checksum = 0;
 time_t starttime;
-off_t total_size = 0;
+int64 total_size = 0;
 int block_size=BLOCK_SIZE;
 
 char *backup_suffix = BACKUP_SUFFIX;
@@ -66,7 +66,7 @@ static void usage(FILE *f);
 
 static void report(int f)
 {
-  off_t in,out,tsize;
+  int64 in,out,tsize;
   time_t t = time(NULL);
   
   if (!verbose) return;
@@ -196,7 +196,7 @@ static int do_cmd(char *cmd,char *machine,char *user,char *path,int *f_in,int *f
 {
   char *args[100];
   int i,argc=0, ret;
-  char *tok,*p,*dir=NULL;
+  char *tok,*dir=NULL;
 
   if (!local_server) {
     if (!cmd)
diff --git a/match.c b/match.c
index 1677900..dd289e1 100644 (file)
--- a/match.c
+++ b/match.c
@@ -39,7 +39,7 @@ static int data_transfer;
 static int total_false_alarms;
 static int total_tag_hits;
 static int total_matches;
-static off_t total_data_transfer;
+static int64 total_data_transfer;
 
 
 struct target {
diff --git a/rsync.c b/rsync.c
index 34c85f4..2ef416d 100644 (file)
--- a/rsync.c
+++ b/rsync.c
@@ -929,14 +929,13 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
 
 
 
-off_t send_files(struct file_list *flist,int f_out,int f_in)
+void send_files(struct file_list *flist,int f_out,int f_in)
 { 
   int fd;
   struct sum_struct *s;
   struct map_struct *buf;
   struct stat st;
   char fname[MAXPATHLEN];  
-  off_t total=0;
   int i;
   struct file_struct *file;
   int phase = 0;
@@ -971,7 +970,7 @@ off_t send_files(struct file_list *flist,int f_out,int f_in)
                  if (strlen(fname) == MAXPATHLEN-1) {
                          fprintf(FERROR, "send_files failed on long-named directory %s\n",
                                  fname);
-                         return -1;
+                         return;
                  }
                  strcat(fname,"/");
                  offset = strlen(file->basedir)+1;
@@ -991,7 +990,7 @@ off_t send_files(struct file_list *flist,int f_out,int f_in)
          s = receive_sums(f_in);
          if (!s) {
                  fprintf(FERROR,"receive_sums failed\n");
-                 return -1;
+                 return;
          }
          
          fd = open(fname,O_RDONLY);
@@ -1007,7 +1006,7 @@ off_t send_files(struct file_list *flist,int f_out,int f_in)
                  fprintf(FERROR,"fstat failed : %s\n",strerror(errno));
                  free_sums(s);
                  close(fd);
-                 return -1;
+                 return;
          }
          
          if (st.st_size > 0) {
@@ -1042,8 +1041,6 @@ off_t send_files(struct file_list *flist,int f_out,int f_in)
          
          if (verbose > 2)
                  fprintf(FERROR,"sender finished %s\n",fname);
-         
-         total += st.st_size;
   }
 
   if (verbose > 2)
@@ -1053,8 +1050,6 @@ off_t send_files(struct file_list *flist,int f_out,int f_in)
 
   write_int(f_out,-1);
   write_flush(f_out);
-
-  return total;
 }
 
 
diff --git a/rsync.h b/rsync.h
index 9c0e24c..8de94ce 100644 (file)
--- a/rsync.h
+++ b/rsync.h
 #define uint32 unsigned int32
 #endif
 
+#ifdef HAVE_LONGLONG
+#define int64 long long
+#else
+#define int64 off_t
+#endif
 
 #ifndef MIN
 #define MIN(a,b) ((a)<(b)?(a):(b))
@@ -257,7 +262,7 @@ struct map_struct {
 /* we need this function because of the silly way in which duplicate
    entries are handled in the file lists - we can't change this
    without breaking existing versions */
-static int flist_up(struct file_list *flist, int i)
+static inline int flist_up(struct file_list *flist, int i)
 {
        while (!flist->files[i]->basename) i++;
        return i;