X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/1cd5beeb06e9df035aa36c89cdb9c3173a8e0bd6..81c652d5d28efcc9bd9c69173305dc237b85c9d4:/batch.c diff --git a/batch.c b/batch.c index e45d3642..a470710d 100644 --- a/batch.c +++ b/batch.c @@ -35,6 +35,7 @@ void create_batch_file_ext() timeptr->tm_year + 1900, timeptr->tm_mon + 1, timeptr->tm_mday, timeptr->tm_hour, timeptr->tm_min, timeptr->tm_sec); + rprintf(FINFO,"batch file extension: %s\n", batch_file_ext); } void set_batch_file_ext(char *ext) @@ -84,12 +85,16 @@ void write_batch_flist_info(int flist_count, struct file_struct **fptr) /* Write flist info to batch file */ - bytes_to_write = sizeof(unsigned) + + bytes_to_write = + sizeof(unsigned) + sizeof(time_t) + sizeof(OFF_T) + sizeof(mode_t) + - sizeof(INO_T) + - (2 * sizeof(dev_t)) + sizeof(uid_t) + sizeof(gid_t); + sizeof(INO64_T) + + sizeof(DEV64_T) + + sizeof(DEV64_T) + + sizeof(uid_t) + + sizeof(gid_t); fdb_open = 1; fdb_close = 0; @@ -128,7 +133,7 @@ void write_char_bufs(char *buf) } } -void write_batch_argvs_file(int orig_argc, int argc, char **argv) +void write_batch_argvs_file(int argc, char *argv[]) { int fdb; int i; @@ -149,19 +154,27 @@ void write_batch_argvs_file(int orig_argc, int argc, char **argv) buff[0] = '\0'; /* Write argvs info to batch file */ - for (i = argc - orig_argc; i < argc; i++) { - if (!strcmp(argv[i], "-F")) { /* safer to change it here than script */ - strncat(buff, "-f ", 3); /* chg to -f + ext to get ready for remote */ - strncat(buff, batch_file_ext, - strlen(batch_file_ext)); + for (i = 0; i < argc; ++i) { + if (i == argc - 2) + continue; + /* + * FIXME: + * I think directly manipulating argv[] is probably bogus + */ + if (!strcmp(argv[i], "--write-batch")) { + /* Safer to change it here than script */ + /* Change to --read-batch + ext * to get ready for remote */ + strlcat(buff, "--read-batch ", sizeof(buff)); + strlcat(buff, batch_file_ext, sizeof(buff)); } else { - strncat(buff, argv[i], strlen(argv[i])); + strlcat(buff, argv[i], sizeof(buff)); } if (i < (argc - 1)) { - strncat(buff, " ", 1); + strlcat(buff, " ", sizeof(buff)); } } + strlcat(buff, "\n", sizeof(buff)); if (!write(fdb, buff, strlen(buff))) { rprintf(FERROR, "Batch file %s write error: %s\n", rsync_argvs_file, strerror(errno)); @@ -285,9 +298,9 @@ void read_batch_flist_info(struct file_struct **fptr) read_batch_flist_file((char *) &file->modtime, sizeof(time_t)); read_batch_flist_file((char *) &file->length, sizeof(OFF_T)); read_batch_flist_file((char *) &file->mode, sizeof(mode_t)); - read_batch_flist_file((char *) &file->inode, sizeof(INO_T)); - read_batch_flist_file((char *) &file->dev, sizeof(dev_t)); - read_batch_flist_file((char *) &file->rdev, sizeof(dev_t)); + read_batch_flist_file((char *) &file->inode, sizeof(INO64_T)); + read_batch_flist_file((char *) &file->dev, sizeof(DEV64_T)); + read_batch_flist_file((char *) &file->rdev, sizeof(DEV64_T)); read_batch_flist_file((char *) &file->uid, sizeof(uid_t)); read_batch_flist_file((char *) &file->gid, sizeof(gid_t)); read_batch_flist_file(char_str_len, sizeof(char_str_len)); @@ -341,7 +354,7 @@ void read_batch_flist_info(struct file_struct **fptr) } } -void write_batch_csums_file(char *buff, int bytes_to_write) +void write_batch_csums_file(void *buff, int bytes_to_write) { static int fdb_open = 1; @@ -382,21 +395,24 @@ void close_batch_csums_file() void write_batch_csum_info(int *flist_entry, int flist_count, struct sum_struct *s) { - int i; - int int_zero = 0; + size_t i; + unsigned int int_zero = 0; extern int csum_length; fdb_open = 1; /* Write csum info to batch file */ - write_batch_csums_file((char *) flist_entry, sizeof(int)); - write_batch_csums_file((char *) (s ? &s->count : &int_zero), - sizeof(int)); + /* FIXME: This will break if s->count is ever not exactly an int. */ + write_batch_csums_file(flist_entry, sizeof(int)); + if (s) + write_batch_csums_file(&s->count, sizeof(int)); + else + write_batch_csums_file(&int_zero, sizeof (int)); + if (s) { for (i = 0; i < s->count; i++) { - write_batch_csums_file((char *) &s->sums[i].sum1, - sizeof(uint32)); + write_batch_csums_file(&s->sums[i].sum1, sizeof(uint32)); if ((*flist_entry == flist_count - 1) && (i == s->count - 1)) { fdb_close = 1;