rsync-2.5.1pre1 with -F option
Jos Backus
josb at cncdsl.com
Tue Dec 11 12:40:33 EST 2001
Sorry for the spam. Here's an even better version of the patch. It
- uses strlcat instead of strncat
- replaces one use of sprintf with snprintf
- removes the -F/-f options, uses only the long options
- updates the documentation
Any objections to this going in?
Index: batch.c
===================================================================
RCS file: /cvsroot/rsync/batch.c,v
retrieving revision 1.6
diff -u -r1.6 batch.c
--- batch.c 2 Dec 2001 22:47:30 -0000 1.6
+++ batch.c 11 Dec 2001 01:36:37 -0000
@@ -128,7 +128,7 @@
}
}
-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,21 +149,24 @@
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) {
+ /*
+ * FIXME:
+ * I think directly manipulating argv[] is probably bogus
+ */
+ if (!strcmp(argv[i], "--write-batch")) {
+ /* safer to change it here than script */
+ /* Change to --write-batch + ext
+ * to get ready for remote
+ */
+ strlcat(buff, "--write-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));
}
}
if (!write(fdb, buff, strlen(buff))) {
Index: main.c
===================================================================
RCS file: /cvsroot/rsync/main.c,v
retrieving revision 1.134
diff -u -r1.134 main.c
--- main.c 15 Aug 2001 07:50:07 -0000 1.134
+++ main.c 11 Dec 2001 01:36:38 -0000
@@ -765,8 +765,10 @@
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);
@@ -806,7 +808,7 @@
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 */
Index: options.c
===================================================================
RCS file: /cvsroot/rsync/options.c,v
retrieving revision 1.69
diff -u -r1.69 options.c
--- options.c 5 Dec 2001 13:45:51 -0000 1.69
+++ options.c 11 Dec 2001 01:36:38 -0000
@@ -222,8 +222,8 @@
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");
@@ -313,8 +313,8 @@
{"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, 0},
+ {"write-batch", 0, POPT_ARG_NONE, &write_batch, 0},
#ifdef INET6
{0, '4', POPT_ARG_VAL, &global_opts.af_hint, AF_INET },
{0, '6', POPT_ARG_VAL, &global_opts.af_hint, AF_INET6 },
@@ -612,7 +612,7 @@
}
if (batch_ext != NULL) {
- sprintf(fext,"-f%s",batch_ext);
+ snprintf(fext,sizeof(fext),"--read-batch=%s",batch_ext);
args[ac++] = fext;
}
Index: proto.h
===================================================================
RCS file: /cvsroot/rsync/proto.h,v
retrieving revision 1.133
diff -u -r1.133 proto.h
--- proto.h 26 Nov 2001 07:18:09 -0000 1.133
+++ proto.h 11 Dec 2001 01:36:38 -0000
@@ -9,7 +9,7 @@
void write_batch_flist_file(char *buff, int bytes_to_write);
void write_batch_flist_info(int flist_count, struct file_struct **fptr);
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[]);
struct file_list *create_flist_from_batch();
int read_batch_flist_file(char *buff, int len);
unsigned char read_batch_flags();
Index: rsync.1
===================================================================
RCS file: /cvsroot/rsync/rsync.1,v
retrieving revision 1.99
diff -u -r1.99 rsync.1
--- rsync.1 5 Dec 2001 13:10:24 -0000 1.99
+++ rsync.1 11 Dec 2001 01:36:40 -0000
@@ -306,8 +306,8 @@
--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
@@ -916,7 +916,7 @@
\fBsrc_dir\fP
.PP
.RS
-$ rsync -F [other rsync options here] \e
+$ rsync --write-batch [other rsync options here] \e
.br
/somewhere/src_dir /somewhere/target_dir
.RE
Index: rsync.yo
===================================================================
RCS file: /cvsroot/rsync/rsync.yo,v
retrieving revision 1.84
diff -u -r1.84 rsync.yo
--- rsync.yo 5 Dec 2001 13:10:24 -0000 1.84
+++ rsync.yo 11 Dec 2001 01:36:41 -0000
@@ -277,8 +277,8 @@
--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
@@ -796,7 +796,7 @@
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
)
--
Jos Backus _/ _/_/_/ Santa Clara, CA
_/ _/ _/
_/ _/_/_/
_/ _/ _/ _/
josb at cncdsl.com _/_/ _/_/_/ use Std::Disclaimer;
More information about the rsync
mailing list