{
int i;
MDstruct MD;
- static char *buf1 = NULL;
- static int len1 = 0;
+ static char *buf1;
+ static int len1;
if (len > len1) {
if (buf1) free(buf1);
extern int verbose;
-static char **exclude_list = NULL;
+static char **exclude_list;
static int is_regex(char *str)
{
extern int copy_links;
extern int remote_version;
-static char **local_exclude_list = NULL;
+static char **local_exclude_list;
int link_stat(const char *Path, struct stat *Buffer)
{
static void send_directory(int f,struct file_list *flist,char *dir);
-static char *flist_dir = NULL;
+static char *flist_dir;
static void clean_fname(char *name)
{
void send_file_entry(struct file_struct *file,int f)
{
unsigned char flags;
- static time_t last_time=0;
- static mode_t last_mode=0;
- static dev_t last_rdev=0;
- static uid_t last_uid=0;
- static gid_t last_gid=0;
- static char lastname[MAXPATHLEN]="";
+ static time_t last_time;
+ static mode_t last_mode;
+ static dev_t last_rdev;
+ static uid_t last_uid;
+ static gid_t last_gid;
+ static char lastname[MAXPATHLEN];
char *fname;
int l1,l2;
write_byte(f,l2);
write_buf(f,fname+l1,l2);
- write_int(f,(int)file->length);
+ write_longint(f,file->length);
if (!(flags & SAME_TIME))
write_int(f,(int)file->modtime);
if (!(flags & SAME_MODE))
#if SUPPORT_HARD_LINKS
if (preserve_hard_links && S_ISREG(file->mode)) {
- write_int(f,file->dev);
- write_int(f,file->inode);
+ write_int(f,(int)file->dev);
+ write_int(f,(int)file->inode);
}
#endif
void receive_file_entry(struct file_struct **fptr,
unsigned char flags,int f)
{
- static time_t last_time=0;
- static mode_t last_mode=0;
- static dev_t last_rdev=0;
- static uid_t last_uid=0;
- static gid_t last_gid=0;
+ static time_t last_time;
+ static mode_t last_mode;
+ static dev_t last_rdev;
+ static uid_t last_uid;
+ static gid_t last_gid;
static char lastname[MAXPATHLEN];
char thisname[MAXPATHLEN];
int l1=0,l2=0;
if (!file->basename) out_of_memory("receive_file_entry 1");
- file->length = (off_t)read_int(f);
+ file->length = read_longint(f);
file->modtime = (flags & SAME_TIME) ? last_time : (time_t)read_int(f);
file->mode = (flags & SAME_MODE) ? last_mode : (mode_t)read_int(f);
if (preserve_uid)
if (!S_ISREG(f2->mode)) return 1;
if (f1->dev != f2->dev)
- return (f1->dev - f2->dev);
+ return (int)(f1->dev - f2->dev);
if (f1->inode != f2->inode)
return (f1->inode - f2->inode);
}
-static struct file_struct *hlink_list = NULL;
-static int hlink_count=0;
+static struct file_struct *hlink_list;
+static int hlink_count;
#endif
void init_hard_links(struct file_list *flist)
*/
#include "rsync.h"
-static int total_written = 0;
-static int total_read = 0;
+static off_t total_written;
+static off_t total_read;
extern int verbose;
extern int sparse_files;
-int write_total(void)
+off_t write_total(void)
{
return total_written;
}
-int read_total(void)
+off_t read_total(void)
{
return total_read;
}
}
-static char *read_buffer = NULL;
-static char *read_buffer_p = NULL;
-static int read_buffer_len = 0;
-static int read_buffer_size = 0;
+static char *read_buffer;
+static char *read_buffer_p;
+static int read_buffer_len;
+static int read_buffer_size;
/* This function was added to overcome a deadlock problem when using
return IVAL(b,0);
}
+off_t read_longint(int f)
+{
+ extern int remote_version;
+ off_t 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=readfd(f,b,8)) != 8) {
+ if (verbose > 1)
+ fprintf(FERROR,"(%d) Error reading %d bytes : %s\n",
+ getpid(),8,ret==-1?strerror(errno):"EOF");
+ exit_cleanup(1);
+ }
+ total_read += 8;
+ ret = IVAL(b,0) | (((off_t)IVAL(b,4))<<32);
+ }
+ return ret;
+}
+
void read_buf(int f,char *buf,int len)
{
int ret;
}
-static char last_byte=0;
-static int last_sparse = 0;
+static char last_byte;
+static int last_sparse;
int sparse_end(int f)
{
total_written += 4;
}
+void write_longint(int f, off_t x)
+{
+ extern int remote_version;
+ char b[8];
+ int ret;
+
+ if (remote_version < 16 || x <= 0x7FFFFFFF) {
+ write_int(f, (int)x);
+ return;
+ }
+
+ write_int(f, -1);
+ SIVAL(b,0,(x&0xFFFFFFFF));
+ SIVAL(b,4,((x>>32)&0xFFFFFFFF));
+
+ if ((ret=writefd(f,b,8)) != 8) {
+ fprintf(FERROR,"write_longint failed : %s\n",
+ ret==-1?strerror(errno):"EOF");
+ exit_cleanup(1);
+ }
+ total_written += 8;
+}
+
void write_buf(int f,char *buf,int len)
{
int ret;
extern int csum_length;
int am_server = 0;
-static int sender = 0;
+static int sender;
int recurse = 0;
static void usage(FILE *f);
static void report(int f)
{
- int in,out,tsize;
+ off_t in,out,tsize;
time_t t = time(NULL);
if (!verbose) return;
if (am_server && sender) {
- write_int(f,read_total());
- write_int(f,write_total());
- write_int(f,total_size);
+ write_longint(f,read_total());
+ write_longint(f,write_total());
+ write_longint(f,total_size);
write_flush(f);
return;
}
if (sender) {
in = read_total();
out = write_total();
- tsize = (int)total_size;
+ tsize = total_size;
} else {
- in = read_int(f);
- out = read_int(f);
- tsize = read_int(f);
+ in = read_longint(f);
+ out = read_longint(f);
+ tsize = read_longint(f);
}
- printf("wrote %d bytes read %d bytes %g bytes/sec\n",
- out,in,(in+out)/(0.5 + (t-starttime)));
- printf("total size is %d speedup is %g\n",
- tsize,(1.0*tsize)/(in+out));
+ printf("wrote %ld bytes read %ld bytes %g bytes/sec\n",
+ (long)out,(long)in,(in+out)/(0.5 + (t-starttime)));
+ printf("total size is %ld speedup is %g\n",
+ (long)tsize,(1.0*tsize)/(in+out));
}
if ((pid=do_fork()) == 0) {
recv_files(f_in,flist,local_name,recv_pipe[1]);
if (verbose > 2)
- fprintf(FERROR,"receiver read %d\n",read_total());
+ fprintf(FERROR,"receiver read %ld\n",(long)read_total());
exit_cleanup(0);
}
/* we set a 0 umask so that correct file permissions can be
carried across */
- orig_umask = umask(0);
+ orig_umask = (int)umask(0);
while ((opt = getopt_long(argc, argv,
short_options, long_options, &option_index))
static int matches;
static int data_transfer;
-static int total_false_alarms=0;
-static int total_tag_hits=0;
-static int total_matches=0;
-static int total_data_transfer=0;
+static int total_false_alarms;
+static int total_tag_hits;
+static int total_matches;
+static off_t total_data_transfer;
struct target {
int i;
};
-static struct target *targets=NULL;
+static struct target *targets;
-static tag *tag_table = NULL;
+static tag *tag_table;
#define gettag2(s1,s2) (((s1) + (s2)) & 0xFFFF)
#define gettag(sum) gettag2((sum)&0xFFFF,(sum)>>16)
return;
fprintf(FINFO,
- "total: matches=%d tag_hits=%d false_alarms=%d data=%d\n",
+ "total: matches=%d tag_hits=%d false_alarms=%d data=%ld\n",
total_matches,total_tag_hits,
- total_false_alarms,total_data_transfer);
+ total_false_alarms,(long)total_data_transfer);
}
}
}
-static char *cleanup_fname = NULL;
+static char *cleanup_fname;
void exit_cleanup(int code)
{
if (verbose > 2)
- fprintf(FERROR,"generator wrote %d\n",write_total());
+ fprintf(FERROR,"generator wrote %ld\n",(long)write_total());
}
#define SAME_TIME (1<<7)
/* update this if you make incompatible changes */
-#define PROTOCOL_VERSION 15
+#define PROTOCOL_VERSION 16
#define MIN_PROTOCOL_VERSION 11
#define MAX_PROTOCOL_VERSION 20
/* non-compressing recv token */
static int simple_recv_token(int f,char **data)
{
- static int residue = 0;
- static char *buf = NULL;
+ static int residue;
+ static char *buf;
int n;
if (!buf) {
static z_stream tx_strm;
/* Output buffer */
-static char *obuf = NULL;
+static char *obuf;
/* Send a deflated token */
static void
recv_deflated_token(int f, char **data)
{
int n, r, flag;
- static int init_done = 0;
- static int saved_flag = 0;
+ static int init_done;
+ static int saved_flag;
for (;;) {
switch (recv_state) {