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)
/* 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(INO64_T) +
- (2 * sizeof(DEV64_T)) + sizeof(uid_t) + sizeof(gid_t);
+ sizeof(DEV64_T) +
+ sizeof(DEV64_T) +
+ sizeof(uid_t) +
+ sizeof(gid_t);
fdb_open = 1;
fdb_close = 0;
}
}
-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;
buff[0] = '\0';
/* Write argvs info to batch file */
- for (i = argc - orig_argc; i < argc; i++) {
- /* FIXME: This apparently crashes if rsync is run with
- * just "rsync -F". I think directly manipulating
- * argv[] is probably bogus -- what if -F is part of a
- * run of several short options? */
- 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));
read_batch_flist_file((char *) &file->mode, sizeof(mode_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(dev_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));
}
}
-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;
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;