mode.
Also, drop -f and -F for batch mode: these should be reserved for
options that are more commonly used.
It also appends a newline to the argvs file and skips adding the
source directory to the command line.
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));
extern int write_batch; /* dw */
extern char *batch_ext; /* dw */
int orig_argc; /* dw */
+ char **orig_argv;
orig_argc = argc; /* dw */
+ orig_argv = argv;
signal(SIGUSR1, sigusr1_handler);
signal(SIGUSR2, sigusr2_handler);
if (write_batch) { /* dw */
create_batch_file_ext();
- write_batch_argvs_file(orig_argc, argc, argv);
+ write_batch_argvs_file(orig_argc, orig_argv);
}
if (read_batch) { /* dw */
rprintf(F," --log-format=FORMAT log file transfers using specified format\n");
rprintf(F," --password-file=FILE get password from FILE\n");
rprintf(F," --bwlimit=KBPS limit I/O bandwidth, KBytes per second\n");
- rprintf(F," -f --read-batch=EXT read batch file\n");
- rprintf(F," -F --write-batch write batch file\n");
+ rprintf(F," --read-batch=EXT read batch file\n");
+ rprintf(F," --write-batch write batch file\n");
rprintf(F," -h, --help show this help screen\n");
#ifdef INET6
rprintf(F," -4 prefer IPv4\n");
OPT_LOG_FORMAT, OPT_PASSWORD_FILE, OPT_SIZE_ONLY, OPT_ADDRESS,
OPT_DELETE_AFTER, OPT_EXISTING, OPT_MAX_DELETE, OPT_BACKUP_DIR,
OPT_IGNORE_ERRORS, OPT_BWLIMIT, OPT_BLOCKING_IO,
- OPT_MODIFY_WINDOW};
+ OPT_MODIFY_WINDOW, OPT_READ_BATCH, OPT_WRITE_BATCH};
static struct poptOption long_options[] = {
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
{"address", 0, POPT_ARG_STRING, &bind_address, 0},
{"backup-dir", 0, POPT_ARG_STRING, &backup_dir},
{"hard-links", 'H', POPT_ARG_NONE, &preserve_hard_links},
- {"read-batch", 'f', POPT_ARG_STRING, &batch_ext, 'f'},
- {"write-batch", 'F', POPT_ARG_NONE, &write_batch, 0},
+ {"read-batch", 0, POPT_ARG_STRING, &batch_ext, OPT_READ_BATCH},
+ {"write-batch", 0, POPT_ARG_NONE, &write_batch},
#ifdef INET6
{0, '4', POPT_ARG_VAL, &default_af_hint, AF_INET },
{0, '6', POPT_ARG_VAL, &default_af_hint, AF_INET6 },
keep_partial = 1;
break;
-
- case 'f':
- /* The filename is stored for us by popt */
+ case OPT_READ_BATCH:
+ /* The filename is stored in batch_ext for us by popt */
read_batch = 1;
break;
static char mdelete[30];
static char mwindow[30];
static char bw[50];
- static char fext[20]; /* dw */
+ static char fext[20];
+ static char wbatch[14];
int i, x;
argstr[x++] = 'S';
if (do_compression)
argstr[x++] = 'z';
- if (write_batch)
- argstr[x++] = 'F'; /* dw */
/* this is a complete hack - blame Rusty
args[ac++] = mdelete;
}
+ if (write_batch) {
+ snprintf(wbatch,sizeof(wbatch),"--write-batch");
+ args[ac++] = wbatch;
+ }
+
if (batch_ext != NULL) {
- sprintf(fext,"-f%s",batch_ext);
+ snprintf(fext,sizeof(fext),"--read-batch=%s",batch_ext);
args[ac++] = fext;
}
--log-format=FORMAT log file transfers using specified format
--password-file=FILE get password from FILE
--bwlimit=KBPS limit I/O bandwidth, KBytes per second
- -f, --read-batch=FILE read batch file
- -F, --write-batch write batch file
+ --read-batch=FILE read batch file
+ --write-batch write batch file
-h, --help show this help screen
bf(src_dir)
quote(
-$ rsync -F [other rsync options here] \nl()
+$ rsync --write-batch [other rsync options here] \nl()
/somewhere/src_dir /somewhere/target_dir
)
initial_stats = stats;
s = receive_sums(f_in);
- if (write_batch) /* dw */
- write_batch_csum_info(&i,flist->count,s);
if (!s) {
io_error = 1;
rprintf(FERROR,"receive_sums failed\n");
return;
}
+
+ if (write_batch)
+ write_batch_csum_info(&i,flist->count,s);
if (!read_batch) {
fd = do_open(fname, O_RDONLY, 0);
extern int am_sender;
extern int am_server;
- if (read_batch)
- am_sender = 0;
- else
- am_sender = !am_sender;
+ am_sender = read_batch ? 0 : !am_sender;
am_server = 1;
if (dup2(to_child_pipe[0], STDIN_FILENO) < 0 ||