You must run "make proto" after applying this patch.
--- orig/cleanup.c 2004-07-20 21:36:07
-+++ cleanup.c 2004-07-23 19:19:47
-@@ -24,6 +24,7 @@
- extern int io_error;
- extern int keep_partial;
- extern int log_got_error;
-+extern char *partial_dir;
-
- /**
- * Close all open sockets and files, allowing a (somewhat) graceful
-@@ -111,7 +112,8 @@ void _exit_cleanup(int code, const char
++++ cleanup.c 2004-07-27 23:32:17
+@@ -111,7 +111,8 @@ void _exit_cleanup(int code, const char
}
}
- if (cleanup_got_literal && cleanup_fname && keep_partial) {
+ if (cleanup_got_literal && cleanup_fname && keep_partial
-+ && (!partial_dir || handle_partial_dir(cleanup_new_fname, 1))) {
++ && handle_partial_dir(cleanup_new_fname, PDIR_CREATE)) {
char *fname = cleanup_fname;
cleanup_fname = NULL;
if (cleanup_fd_r != -1)
---- orig/generator.c 2004-07-23 17:16:12
-+++ generator.c 2004-07-23 19:19:47
+--- orig/generator.c 2004-07-26 16:24:55
++++ generator.c 2004-07-27 03:58:55
@@ -42,6 +42,7 @@ extern int size_only;
extern int io_timeout;
extern int protocol_version;
extern char *compare_dest;
extern int link_dest;
extern int whole_file;
-@@ -411,7 +412,18 @@ static void recv_generator(char *fname,
+@@ -418,7 +419,18 @@ static void recv_generator(char *fname,
return;
}
- fnamecmp = fname;
+ if (partial_dir) {
+ STRUCT_STAT st2;
-+ if (!(fnamecmp = fname_in_partial_dir(fname)))
++ if (!(fnamecmp = partial_dir_fname(fname)))
+ fnamecmp = fname;
+ else if (link_stat(fnamecmp, &st2, 0) == 0
+ && S_ISREG(st2.st_mode)) {
if (statret == -1 && compare_dest != NULL) {
/* try the file at compare_dest instead */
--- orig/options.c 2004-07-23 17:16:13
-+++ options.c 2004-07-23 19:19:48
++++ options.c 2004-07-26 16:43:48
@@ -118,6 +118,7 @@ unsigned int backup_dir_remainder;
char *backup_suffix = NULL;
args[ac++] = "--partial";
if (force_delete)
---- orig/receiver.c 2004-07-23 17:16:13
-+++ receiver.c 2004-07-23 19:19:48
+--- orig/receiver.c 2004-07-26 16:20:00
++++ receiver.c 2004-07-27 23:26:20
@@ -38,6 +38,7 @@ extern int preserve_perms;
extern int cvs_exclude;
extern int io_error;
extern char *compare_dest;
extern int make_backups;
extern int do_progress;
-@@ -338,7 +339,7 @@ int recv_files(int f_in, struct file_lis
+@@ -342,7 +343,7 @@ int recv_files(int f_in, struct file_lis
char *fname, fbuf[MAXPATHLEN];
char template[MAXPATHLEN];
char fnametmp[MAXPATHLEN];
char fnamecmpbuf[MAXPATHLEN];
struct file_struct *file;
struct stats initial_stats;
-@@ -406,8 +407,6 @@ int recv_files(int f_in, struct file_lis
+@@ -410,8 +411,6 @@ int recv_files(int f_in, struct file_lis
if (verbose > 2)
- rprintf(FINFO,"recv_files(%s)\n",fname);
+ rprintf(FINFO, "recv_files(%s)\n", safe_fname(fname));
- fnamecmp = fname;
-
if (read_batch) {
while (i > next_gen_i) {
next_gen_i = read_int(batch_gen_fd);
-@@ -434,9 +433,22 @@ int recv_files(int f_in, struct file_lis
+@@ -438,9 +437,22 @@ int recv_files(int f_in, struct file_lis
continue;
}
+ if (partial_dir) {
-+ if ((partialptr = fname_in_partial_dir(fname)) != NULL)
++ if ((partialptr = partial_dir_fname(fname)) != NULL)
+ fnamecmp = partialptr;
+ else
+ fnamecmp = fname;
if (fd1 == -1 && compare_dest != NULL) {
/* try the file at compare_dest instead */
pathjoin(fnamecmpbuf, sizeof fnamecmpbuf,
-@@ -524,7 +536,8 @@ int recv_files(int f_in, struct file_lis
+@@ -528,7 +540,8 @@ int recv_files(int f_in, struct file_lis
continue;
}
+ cleanup_set(fnametmp, partialptr, file, fd1, fd2);
}
- if (!am_server && verbose)
-@@ -544,10 +557,20 @@ int recv_files(int f_in, struct file_lis
+ if (!am_server && verbose) /* log the transfer */
+@@ -548,10 +561,20 @@ int recv_files(int f_in, struct file_lis
exit_cleanup(RERR_FILEIO);
}
finish_transfer(fname, fnametmp, file, recv_ok);
- else
+ else if (keep_partial && partialptr
-+ && (!partial_dir || handle_partial_dir(partialptr, 1)))
++ && handle_partial_dir(partialptr, PDIR_CREATE))
+ finish_transfer(partialptr, fnametmp, file, 0);
+ else {
+ partialptr = NULL;
+
+ if (partialptr != fname && fnamecmp == partialptr && recv_ok) {
+ do_unlink(partialptr);
-+ handle_partial_dir(partialptr, 0);
++ handle_partial_dir(partialptr, PDIR_DELETE);
+ }
cleanup_disable();
-@@ -555,9 +578,13 @@ int recv_files(int f_in, struct file_lis
+@@ -559,9 +582,13 @@ int recv_files(int f_in, struct file_lis
int msgtype = csum_length == SUM_LENGTH || read_batch ?
FERROR : FINFO;
if (msgtype == FERROR || verbose) {
if (msgtype == FERROR) {
errstr = "ERROR";
redostr = "";
-@@ -566,7 +593,7 @@ int recv_files(int f_in, struct file_lis
+@@ -570,7 +597,7 @@ int recv_files(int f_in, struct file_lis
redostr = " (will try again)";
}
rprintf(msgtype,
- "%s: %s failed verification -- update %sed%s.\n",
+ "%s: %s failed verification -- update %s%s.\n",
- errstr, fname, keptstr, redostr);
+ errstr, safe_fname(fname),
+ keptstr, redostr);
}
- if (csum_length != SUM_LENGTH) {
+--- orig/rsync.h 2004-07-23 17:16:13
++++ rsync.h 2004-07-27 23:23:54
+@@ -115,6 +115,9 @@
+ #define FULL_FLUSH 1
+ #define NORMAL_FLUSH 0
+
++#define PDIR_CREATE 1
++#define PDIR_DELETE 0
++
+
+ /* Log-message categories. FLOG is only used on the daemon side to
+ * output messages to the log file. */
--- orig/rsync.yo 2004-07-24 16:52:10
-+++ rsync.yo 2004-07-23 19:36:41
++++ rsync.yo 2004-07-27 23:48:13
@@ -317,6 +317,7 @@ verb(
--ignore-errors delete even if there are I/O errors
--max-delete=NUM don't delete more than NUM files
--force force deletion of dirs even if not empty
--numeric-ids don't map uid/gid values by user/group name
--timeout=TIME set I/O timeout in seconds
-@@ -865,6 +866,25 @@ it is more desirable to keep partially t
+@@ -865,6 +866,26 @@ it is more desirable to keep partially t
--partial option tells rsync to keep the partial file which should
make a subsequent transfer of the rest of the file much faster.
+dit(bf(--partial-dir=DIR)) Turns on --partial mode, but tells rsync to
+put a partially transferred file into DIR instead of writing out the
+file to the destination dir. Rsync will also use a file found in this
-+dir as data to speed up a subsequent transfer.
++dir as data to speed up the transfer (i.e. when you redo the send after
++rsync creates a partial file).
+
+Rsync will create the dir if it is missing, so feel free to use a
-+relative path (such as quote(--partial-dir=.rsync-partial)) if you
-+want the file put into a directory relative to the current directory
-+in the tree (rsync will also try to remove the DIR if a partial file
-+was found and the DIR was specified as a relative path).
++relative path (such as "--partial-dir=.rsync-partial") if you want the
++file put into a directory created in the destination file's directory
++(rsync will also try to remove the DIR if a partial file was found to
++already exist and the DIR was specified as a relative path).
+
-+If you want to delete files on the destination and your partial-dir is
++If you are deleting files on the destination and your partial-dir is
+inside the destination hierarchy, you should use --delete-after or add an
-+--exclude to prevent the partial file from being deleted before it can be
-+used.
++exclude to prevent the partial file from being deleted before it can be
++used (e.g. "--exclude=.rsync-partial/").
+
-+IMPORTANT: do NOT use a directory that is writable by anyone for the
-+--partial-dir (such as /tmp) -- it is insecure!
++IMPORTANT: do NOT use a directory for the --partial-dir that is writable
++by other users (such as /tmp) -- it is insecure!
+
dit(bf(--progress)) This option tells rsync to print information
showing the progress of the transfer. This gives a bored user
struct exclude_list_struct server_exclude_list;
void rprintf(UNUSED(enum logcode code), const char *format, ...)
---- orig/util.c 2004-06-09 21:54:47
-+++ util.c 2004-07-23 21:43:44
+--- orig/util.c 2004-07-26 16:33:24
++++ util.c 2004-07-27 23:25:20
@@ -31,6 +31,7 @@ extern int verbose;
extern int dry_run;
extern int module_id;
extern struct exclude_list_struct server_exclude_list;
int sanitize_paths = 0;
-@@ -945,6 +946,74 @@ char *full_fname(const char *fn)
+@@ -970,6 +971,66 @@ char *full_fname(const char *fn)
return result;
}
+static char partial_fname[MAXPATHLEN];
+
-+char *fname_in_partial_dir(const char *fname)
++char *partial_dir_fname(const char *fname)
+{
+ char *t = partial_fname;
+ int sz = sizeof partial_fname;
+ }
+ } else
+ fn = fname;
-+ if ((int)pathjoin(t, sz, partial_dir, fn) >= sz) {
-+ *partial_fname = '\0';
++ if ((int)pathjoin(t, sz, partial_dir, fn) >= sz)
+ return NULL;
-+ }
+
+ return partial_fname;
+}
+
++/* If no --partial-dir option was specified, we don't need to do anything
++ * (the partial-dir is essentially '.'), so just return success. */
+int handle_partial_dir(const char *fname, int create)
+{
-+ char *fn, *dir = partial_fname;
++ char *fn, *dir;
+
+ if (fname != partial_fname)
+ return 1;
+ return 1;
+
+ *fn = '\0';
++ dir = partial_fname;
+ if (create) {
+ STRUCT_STAT st;
+#if SUPPORT_LINKS
+ return 0;
+ statret = -1;
+ }
-+ if (statret < 0) {
-+ if (do_mkdir(dir, 0700) < 0)
-+ return 0;
-+#if SUPPORT_LINKS
-+ statret = do_lstat(dir, &st);
-+#else
-+ statret = do_stat(dir, &st);
-+#endif
-+ if (statret < 0 || !S_ISDIR(st.st_mode))
-+ return 0;
-+ }
++ if (statret < 0 && do_mkdir(dir, 0700) < 0)
++ return 0;
+ } else
+ do_rmdir(dir);
+ *fn = '/';