extern int relative_paths;
extern int implied_dirs;
extern int file_extra_cnt;
-@@ -344,6 +345,7 @@ int push_pathname(const char *dir, int len)
+@@ -343,6 +344,7 @@ int push_pathname(const char *dir, int len)
static void send_file_entry(int f, struct file_struct *file, int ndx, int first_ndx)
{
static time_t modtime;
#ifdef SUPPORT_HARD_LINKS
if (tmp_dev != 0) {
-@@ -523,6 +532,8 @@ static void send_file_entry(int f, struct file_struct *file, int ndx, int first_
+@@ -522,6 +531,8 @@ static void send_file_entry(int f, struct file_struct *file, int ndx, int first_
}
if (!(xflags & XMIT_SAME_MODE))
write_int(f, to_wire_mode(mode));
if (uid_ndx && !(xflags & XMIT_SAME_UID)) {
if (protocol_version < 30)
write_int(f, uid);
-@@ -609,7 +620,7 @@ static void send_file_entry(int f, struct file_struct *file, int ndx, int first_
+@@ -608,7 +619,7 @@ static void send_file_entry(int f, struct file_struct *file, int ndx, int first_
static struct file_struct *recv_file_entry(struct file_list *flist,
int xflags, int f)
{
static mode_t mode;
#ifdef SUPPORT_HARD_LINKS
static int64 dev;
-@@ -742,6 +753,16 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
+@@ -741,6 +752,16 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
}
if (!(xflags & XMIT_SAME_MODE))
mode = from_wire_mode(read_int(f));
if (chmod_modes && !S_ISLNK(mode))
mode = tweak_mode(mode, chmod_modes);
-@@ -872,6 +893,8 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
+@@ -871,6 +892,8 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
F_GROUP(file) = gid;
file->flags |= gid_flags;
}
if (unsort_ndx)
F_NDX(file) = flist->used + flist->ndx_start;
-@@ -1200,6 +1223,8 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1197,6 +1220,8 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
F_OWNER(file) = st.st_uid;
if (gid_ndx)
F_GROUP(file) = st.st_gid;
diff --git a/options.c b/options.c
--- a/options.c
+++ b/options.c
-@@ -57,6 +57,7 @@ int preserve_specials = 0;
+@@ -58,6 +58,7 @@ int preserve_specials = 0;
int preserve_uid = 0;
int preserve_gid = 0;
int preserve_times = 0;
int update_only = 0;
int cvs_exclude = 0;
int dry_run = 0;
-@@ -347,6 +348,7 @@ void usage(enum logcode F)
+@@ -348,6 +349,7 @@ void usage(enum logcode F)
rprintf(F," -D same as --devices --specials\n");
rprintf(F," -t, --times preserve modification times\n");
rprintf(F," -O, --omit-dir-times omit directories from --times\n");
rprintf(F," --super receiver attempts super-user activities\n");
#ifdef SUPPORT_XATTRS
rprintf(F," --fake-super store/recover privileged attrs using xattrs\n");
-@@ -482,6 +484,9 @@ static struct poptOption long_options[] = {
+@@ -483,6 +485,9 @@ static struct poptOption long_options[] = {
{"times", 't', POPT_ARG_VAL, &preserve_times, 2, 0, 0 },
{"no-times", 0, POPT_ARG_VAL, &preserve_times, 0, 0, 0 },
{"no-t", 0, POPT_ARG_VAL, &preserve_times, 0, 0, 0 },
{"omit-dir-times", 'O', POPT_ARG_VAL, &omit_dir_times, 1, 0, 0 },
{"no-omit-dir-times",0, POPT_ARG_VAL, &omit_dir_times, 0, 0, 0 },
{"no-O", 0, POPT_ARG_VAL, &omit_dir_times, 0, 0, 0 },
-@@ -1716,6 +1721,8 @@ void server_options(char **args, int *argc_p)
+@@ -1724,6 +1729,8 @@ void server_options(char **args, int *argc_p)
argstr[x++] = 'D';
if (preserve_times)
argstr[x++] = 't';
extern int preserve_times;
extern int am_root;
extern int am_server;
-@@ -343,6 +344,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
+@@ -344,6 +345,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
int updated = 0;
stat_x sx2;
int change_uid, change_gid;
mode_t new_mode = file->mode;
int inherit;
-@@ -386,18 +388,36 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
+@@ -387,18 +389,36 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
set_xattr(fname, file, fnamecmp, sxp);
#endif
diff --git a/options.c b/options.c
--- a/options.c
+++ b/options.c
-@@ -148,10 +148,14 @@ int no_detach
+@@ -149,10 +149,14 @@ int no_detach
int write_batch = 0;
int read_batch = 0;
int backup_dir_len = 0;
char *tmpdir = NULL;
char *partial_dir = NULL;
char *basis_dir[MAX_BASIS_DIRS+1];
-@@ -163,7 +167,9 @@ char *stdout_format = NULL;
+@@ -164,7 +168,9 @@ char *stdout_format = NULL;
char *password_file = NULL;
char *rsync_path = RSYNC_PATH;
char *backup_dir = NULL;
char *sockopts = NULL;
int rsync_port = 0;
int compare_dest = 0;
-@@ -319,6 +325,8 @@ void usage(enum logcode F)
+@@ -320,6 +326,8 @@ void usage(enum logcode F)
rprintf(F," -b, --backup make backups (see --suffix & --backup-dir)\n");
rprintf(F," --backup-dir=DIR make backups into hierarchy based in DIR\n");
rprintf(F," --suffix=SUFFIX set backup suffix (default %s w/o --backup-dir)\n",BACKUP_SUFFIX);
rprintf(F," -u, --update skip files that are newer on the receiver\n");
rprintf(F," --inplace update destination files in-place (SEE MAN PAGE)\n");
rprintf(F," --append append data onto shorter files\n");
-@@ -590,7 +598,9 @@ static struct poptOption long_options[] = {
+@@ -591,7 +599,9 @@ static struct poptOption long_options[] = {
{"backup", 'b', POPT_ARG_VAL, &make_backups, 1, 0, 0 },
{"no-backup", 0, POPT_ARG_VAL, &make_backups, 0, 0, 0 },
{"backup-dir", 0, POPT_ARG_STRING, &backup_dir, 0, 0, 0 },
{"list-only", 0, POPT_ARG_VAL, &list_only, 2, 0, 0 },
{"read-batch", 0, POPT_ARG_STRING, &batch_name, OPT_READ_BATCH, 0, 0 },
{"write-batch", 0, POPT_ARG_STRING, &batch_name, OPT_WRITE_BATCH, 0, 0 },
-@@ -1402,6 +1412,8 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
+@@ -1404,6 +1414,8 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
tmpdir = sanitize_path(NULL, tmpdir, NULL, 0);
if (backup_dir)
backup_dir = sanitize_path(NULL, backup_dir, NULL, 0);
}
if (server_filter_list.head && !am_sender) {
struct filter_list_struct *elp = &server_filter_list;
-@@ -1419,6 +1431,14 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
- if (check_filter(elp, backup_dir, 1) < 0)
+@@ -1425,6 +1437,14 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
+ if (check_filter(elp, dir, 1) < 0)
goto options_rejected;
}
+ /* Clean backup_dir_dels same as for backup_dir */
}
if (!backup_suffix)
-@@ -1430,6 +1450,16 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
+@@ -1436,6 +1456,16 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
backup_suffix);
return 0;
}
if (backup_dir) {
backup_dir_len = strlcpy(backup_dir_buf, backup_dir, sizeof backup_dir_buf);
backup_dir_remainder = sizeof backup_dir_buf - backup_dir_len;
-@@ -1453,6 +1483,31 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
+@@ -1459,6 +1489,31 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
"P *%s", backup_suffix);
parse_rule(&filter_list, backup_dir_buf, 0, 0);
}
if (make_backups && !backup_dir) {
omit_dir_times = 0; /* Implied, so avoid -O to sender. */
-@@ -1844,6 +1899,10 @@ void server_options(char **args, int *argc_p)
+@@ -1852,6 +1907,10 @@ void server_options(char **args, int *argc_p)
args[ac++] = "--backup-dir";
args[ac++] = backup_dir;
}
/* Only send --suffix if it specifies a non-default value. */
if (strcmp(backup_suffix, backup_dir ? "" : BACKUP_SUFFIX) != 0) {
-@@ -1852,7 +1911,13 @@ void server_options(char **args, int *argc_p)
+@@ -1860,7 +1919,13 @@ void server_options(char **args, int *argc_p)
goto oom;
args[ac++] = arg;
}
diff --git a/main.c b/main.c
--- a/main.c
+++ b/main.c
-@@ -162,8 +162,11 @@ static void wait_process_with_flush(pid_t pid, int *exit_code_ptr)
+@@ -164,8 +164,11 @@ static void wait_process_with_flush(pid_t pid, int *exit_code_ptr)
*exit_code_ptr = RERR_TERMINATED;
else
*exit_code_ptr = RERR_WAITCHILD;
}
/* This function gets called from all 3 processes. We want the client side
-@@ -1341,6 +1344,14 @@ RETSIGTYPE remember_children(UNUSED(int val))
+@@ -1344,6 +1347,14 @@ RETSIGTYPE remember_children(UNUSED(int val))
break;
}
}
}
#endif
#ifndef HAVE_SIGACTION
-@@ -1399,6 +1410,12 @@ static RETSIGTYPE rsync_panic_handler(UNUSED(int whatsig))
+@@ -1402,6 +1413,12 @@ static RETSIGTYPE rsync_panic_handler(UNUSED(int whatsig))
}
#endif
int main(int argc,char *argv[])
{
-@@ -1421,6 +1438,11 @@ int main(int argc,char *argv[])
+@@ -1424,6 +1441,11 @@ int main(int argc,char *argv[])
SIGACTMASK(SIGFPE, rsync_panic_handler);
SIGACTMASK(SIGABRT, rsync_panic_handler);
SIGACTMASK(SIGBUS, rsync_panic_handler);
diff --git a/flist.c b/flist.c
--- a/flist.c
+++ b/flist.c
-@@ -122,6 +122,7 @@ static char empty_sum[MAX_DIGEST_LEN];
+@@ -121,6 +121,7 @@ static char tmp_sum[MAX_DIGEST_LEN];
+ static char empty_sum[MAX_DIGEST_LEN];
static int flist_count_offset; /* for --delete --progress */
static int dir_count = 0;
- static int high_hlink_ndx;
+static struct file_list *checksum_flist = NULL;
- static void clean_flist(struct file_list *flist, int strip_root);
+ static void flist_sort_and_clean(struct file_list *flist, int strip_root);
static void output_flist(struct file_list *flist);
-@@ -314,6 +315,186 @@ static void flist_done_allocating(struct file_list *flist)
+@@ -313,6 +314,186 @@ static void flist_done_allocating(struct file_list *flist)
flist->pool_boundary = ptr;
}
int push_pathname(const char *dir, int len)
{
if (dir == pathname)
-@@ -1005,7 +1186,7 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1003,7 +1184,7 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
STRUCT_STAT *stp, int flags, int filter_level)
{
static char *lastdir;
struct file_struct *file;
char thisname[MAXPATHLEN];
char linkname[MAXPATHLEN];
-@@ -1133,9 +1314,16 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1130,9 +1311,16 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
memcpy(lastdir, thisname, len);
lastdir[len] = '\0';
lastdir_len = len;
basename_len = strlen(basename) + 1; /* count the '\0' */
#ifdef SUPPORT_LINKS
-@@ -1211,11 +1399,21 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1208,11 +1396,21 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
}
#endif
/* This code is only used by the receiver when it is building
* a list of files for a delete pass. */
if (keep_dirlinks && linkname_len && flist) {
-@@ -2079,7 +2277,11 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
+@@ -2063,7 +2261,11 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
* file-list to check if this is a 1-file xfer. */
send_extra_file_list(f, 1);
}
int io_error;
int checksum_len;
dev_t filesystem_dev; /* used to implement -x */
-@@ -122,6 +127,9 @@ static char empty_sum[MAX_DIGEST_LEN];
+@@ -121,6 +126,9 @@ static char tmp_sum[MAX_DIGEST_LEN];
+ static char empty_sum[MAX_DIGEST_LEN];
static int flist_count_offset; /* for --delete --progress */
static int dir_count = 0;
- static int high_hlink_ndx;
+static int checksum_matches = 0;
+static int checksum_updates = 0;
+static int regular_skipped = 0;
static struct file_list *checksum_flist = NULL;
- static void clean_flist(struct file_list *flist, int strip_root);
-@@ -317,7 +325,8 @@ static void flist_done_allocating(struct file_list *flist)
+ static void flist_sort_and_clean(struct file_list *flist, int strip_root);
+@@ -316,7 +324,8 @@ static void flist_done_allocating(struct file_list *flist)
/* The len count is the length of the basename + 1 for the null. */
static int add_checksum(const char *dirname, const char *basename, int len,
{
struct file_struct *file;
int alloc_len, extra_len;
-@@ -328,13 +337,14 @@ static int add_checksum(const char *dirname, const char *basename, int len,
+@@ -327,13 +336,14 @@ static int add_checksum(const char *dirname, const char *basename, int len,
if (file_length == 0)
return 0;
bp = pool_alloc(checksum_flist->file_pool, alloc_len, "add_checksum");
memset(bp, 0, extra_len + FILE_STRUCT_LEN);
-@@ -343,7 +353,14 @@ static int add_checksum(const char *dirname, const char *basename, int len,
+@@ -342,7 +352,14 @@ static int add_checksum(const char *dirname, const char *basename, int len,
bp += FILE_STRUCT_LEN;
memcpy(bp, basename, len);
file->mode = S_IFREG;
file->modtime = mtime;
file->len32 = (uint32)file_length;
-@@ -354,6 +371,8 @@ static int add_checksum(const char *dirname, const char *basename, int len,
+@@ -353,6 +370,8 @@ static int add_checksum(const char *dirname, const char *basename, int len,
file->dirname = dirname;
bp = F_SUM(file);
memcpy(bp, sum, checksum_len);
flist_expand(checksum_flist, 1);
checksum_flist->files[checksum_flist->used++] = file;
-@@ -363,17 +382,104 @@ static int add_checksum(const char *dirname, const char *basename, int len,
+@@ -362,17 +381,104 @@ static int add_checksum(const char *dirname, const char *basename, int len,
return 1;
}
if (checksum_flist) {
/* Reset the pool memory and empty the file-list array. */
pool_free_old(checksum_flist->file_pool,
-@@ -384,6 +490,9 @@ static void read_checksums(const char *dirname)
+@@ -383,6 +489,9 @@ static void read_checksums(const char *dirname)
checksum_flist->low = 0;
checksum_flist->high = -1;
if (!dirname)
return;
-@@ -402,7 +511,7 @@ static void read_checksums(const char *dirname)
+@@ -401,7 +510,7 @@ static void read_checksums(const char *dirname)
while (fgets(line, sizeof line, fp)) {
cp = line;
if (protocol_version >= 30) {
if (*cp == '=')
while (*++cp == '=') {}
else
-@@ -413,7 +522,14 @@ static void read_checksums(const char *dirname)
+@@ -412,7 +521,14 @@ static void read_checksums(const char *dirname)
}
if (*cp == '=') {
} else {
for (i = 0; i < checksum_len*2; i++, cp++) {
int x;
-@@ -431,13 +547,14 @@ static void read_checksums(const char *dirname)
+@@ -430,13 +546,14 @@ static void read_checksums(const char *dirname)
else
sum[i/2] = x << 4;
}
if (*cp == '=')
while (*++cp == '=') {}
else
-@@ -461,16 +578,16 @@ static void read_checksums(const char *dirname)
+@@ -460,16 +577,16 @@ static void read_checksums(const char *dirname)
break;
while (*++cp == ' ') {}
if (*cp != ' ')
break;
while (*++cp == ' ') {}
-@@ -487,8 +604,13 @@ static void read_checksums(const char *dirname)
+@@ -486,8 +603,13 @@ static void read_checksums(const char *dirname)
continue;
strlcpy(fbuf+dlen, cp, sizeof fbuf - dlen);
}
fclose(fp);
-@@ -1274,6 +1396,8 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1272,6 +1394,8 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
if (is_excluded(thisname, S_ISDIR(st.st_mode) != 0, filter_level)) {
if (ignore_perishable)
non_perishable_cnt++;
return NULL;
}
-@@ -1405,13 +1529,36 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1402,13 +1526,36 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
int j;
if (flist && (j = flist_find(checksum_flist, file)) >= 0) {
struct file_struct *fp = checksum_flist->sorted[j];
if (f >= 0 && recurse && !divert_dirs) {
int i, end = flist->used - 1;
/* send_if_directory() bumps flist->used, so use "end". */
-@@ -2281,7 +2431,7 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
+@@ -2265,7 +2415,7 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
flist_eof = 1;
if (checksum_updating && always_checksum && flist_eof)
diff --git a/options.c b/options.c
--- a/options.c
+++ b/options.c
-@@ -111,6 +111,7 @@ size_t bwlimit_writemax = 0;
+@@ -112,6 +112,7 @@ size_t bwlimit_writemax = 0;
int ignore_existing = 0;
int ignore_non_existing = 0;
int need_messages_from_generator = 0;
int max_delete = INT_MIN;
OFF_T max_size = 0;
OFF_T min_size = 0;
-@@ -311,6 +312,7 @@ void usage(enum logcode F)
+@@ -312,6 +313,7 @@ void usage(enum logcode F)
rprintf(F," -q, --quiet suppress non-error messages\n");
rprintf(F," --no-motd suppress daemon-mode MOTD (see manpage caveat)\n");
rprintf(F," -c, --checksum skip based on checksum, not mod-time & size\n");
rprintf(F," -a, --archive archive mode; equals -rlptgoD (no -H,-A,-X)\n");
rprintf(F," --no-OPTION turn off an implied OPTION (e.g. --no-D)\n");
rprintf(F," -r, --recursive recurse into directories\n");
-@@ -559,6 +561,7 @@ static struct poptOption long_options[] = {
+@@ -560,6 +562,7 @@ static struct poptOption long_options[] = {
{"checksum", 'c', POPT_ARG_VAL, &always_checksum, 1, 0, 0 },
{"no-checksum", 0, POPT_ARG_VAL, &always_checksum, 0, 0, 0 },
{"no-c", 0, POPT_ARG_VAL, &always_checksum, 0, 0, 0 },
{"block-size", 'B', POPT_ARG_LONG, &block_size, 0, 0, 0 },
{"compare-dest", 0, POPT_ARG_STRING, 0, OPT_COMPARE_DEST, 0, 0 },
{"copy-dest", 0, POPT_ARG_STRING, 0, OPT_COPY_DEST, 0, 0 },
-@@ -1957,7 +1960,9 @@ void server_options(char **args, int *argc_p)
+@@ -1965,7 +1968,9 @@ void server_options(char **args, int *argc_p)
args[ac++] = basis_dir[i];
}
}
diff --git a/flist.c b/flist.c
--- a/flist.c
+++ b/flist.c
-@@ -1211,7 +1211,8 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1208,7 +1208,8 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
}
#endif
diff --git a/options.c b/options.c
--- a/options.c
+++ b/options.c
-@@ -46,6 +46,7 @@ int append_mode = 0;
+@@ -47,6 +47,7 @@ int append_mode = 0;
int keep_dirlinks = 0;
int copy_dirlinks = 0;
int copy_links = 0;
int preserve_links = 0;
int preserve_hard_links = 0;
int preserve_acls = 0;
-@@ -343,6 +344,7 @@ void usage(enum logcode F)
+@@ -344,6 +345,7 @@ void usage(enum logcode F)
rprintf(F," -o, --owner preserve owner (super-user only)\n");
rprintf(F," -g, --group preserve group\n");
rprintf(F," --devices preserve device files (super-user only)\n");
rprintf(F," --specials preserve special files\n");
rprintf(F," -D same as --devices --specials\n");
rprintf(F," -t, --times preserve modification times\n");
-@@ -499,6 +501,7 @@ static struct poptOption long_options[] = {
+@@ -500,6 +502,7 @@ static struct poptOption long_options[] = {
{"no-D", 0, POPT_ARG_NONE, 0, OPT_NO_D, 0, 0 },
{"devices", 0, POPT_ARG_VAL, &preserve_devices, 1, 0, 0 },
{"no-devices", 0, POPT_ARG_VAL, &preserve_devices, 0, 0, 0 },
{"specials", 0, POPT_ARG_VAL, &preserve_specials, 1, 0, 0 },
{"no-specials", 0, POPT_ARG_VAL, &preserve_specials, 0, 0, 0 },
{"links", 'l', POPT_ARG_VAL, &preserve_links, 1, 0, 0 },
-@@ -1991,6 +1994,9 @@ void server_options(char **args, int *argc_p)
+@@ -1999,6 +2002,9 @@ void server_options(char **args, int *argc_p)
else if (remove_source_files)
args[ac++] = "--remove-sent-files";
extern int am_root;
extern int am_server;
extern int am_sender;
-@@ -289,7 +290,8 @@ int read_ndx_and_attrs(int f_in, int *iflag_ptr, uchar *type_ptr,
+@@ -290,7 +291,8 @@ int read_ndx_and_attrs(int f_in, int *iflag_ptr, uchar *type_ptr,
if (iflags & ITEM_TRANSFER) {
int i = ndx - cur_flist->ndx_start;
diff --git a/sender.c b/sender.c
--- a/sender.c
+++ b/sender.c
-@@ -314,6 +314,20 @@ void send_files(int f_in, int f_out)
+@@ -315,6 +315,20 @@ void send_files(int f_in, int f_out)
exit_cleanup(RERR_PROTOCOL);
}
--- /dev/null
+This patch adds a forward lookup of any hostnames listed in the
+"hosts allow" or "hosts deny" daemon config options. Based on
+a patch by Paul Williamson.
+
+To use this patch, run these commands for a successful build:
+
+ patch -p1 <patches/daemon-forward-lookup.diff
+ ./configure (optional if already run)
+ make
+
+diff --git a/access.c b/access.c
+--- a/access.c
++++ b/access.c
+@@ -210,6 +210,43 @@ static int match_address(char *addr, char *tok)
+ return ret;
+ }
+
++static int match_hostlookup(char *addr, char *tok)
++{
++ struct hostent *hp;
++ unsigned int i, len;
++ int failed;
++ char *p;
++
++ if ((p = strchr(tok,'/')) != NULL) {
++ *p = '\0';
++ len = p - tok;
++ } else
++ len = strlen(tok);
++
++ /* Fail quietly if tok is an address (not a hostname) */
++ failed = strspn(tok, ".0123456789") == len;
++#ifdef INET6
++ failed ||= strchr(tok, ':') != NULL;
++#endif
++
++ if (!failed && (hp = gethostbyname(tok)) == NULL)
++ failed = 1;
++
++ if (p)
++ *p = '/';
++
++ if (failed)
++ return 0;
++
++ for (i = 0; hp->h_addr_list[i] != NULL; i++) {
++ tok = inet_ntoa(*(struct in_addr*)(hp->h_addr_list[i]));
++ if (match_address(addr, tok))
++ return 1;
++ }
++
++ return 0;
++}
++
+ static int access_match(char *list, char *addr, char *host)
+ {
+ char *tok;
+@@ -223,7 +260,7 @@ static int access_match(char *list, char *addr, char *host)
+ strlower(host);
+
+ for (tok = strtok(list2, " ,\t"); tok; tok = strtok(NULL, " ,\t")) {
+- if (match_hostname(host, tok) || match_address(addr, tok)) {
++ if (match_hostname(host, tok) || match_address(addr, tok) || match_hostlookup(addr, tok)) {
+ free(list2);
+ return 1;
+ }
diff --git a/options.c b/options.c
--- a/options.c
+++ b/options.c
-@@ -104,6 +104,7 @@ int keep_partial = 0;
+@@ -105,6 +105,7 @@ int keep_partial = 0;
int safe_symlinks = 0;
int copy_unsafe_links = 0;
int size_only = 0;
int daemon_bwlimit = 0;
int bwlimit = 0;
int fuzzy_basis = 0;
-@@ -382,6 +383,7 @@ void usage(enum logcode F)
+@@ -383,6 +384,7 @@ void usage(enum logcode F)
rprintf(F," --contimeout=SECONDS set daemon connection timeout in seconds\n");
rprintf(F," -I, --ignore-times don't skip files that match in size and mod-time\n");
rprintf(F," --size-only skip files that match in size\n");
rprintf(F," --modify-window=NUM compare mod-times with reduced accuracy\n");
rprintf(F," -T, --temp-dir=DIR create temporary files in directory DIR\n");
rprintf(F," -y, --fuzzy find similar file for basis if no dest file\n");
-@@ -522,6 +524,7 @@ static struct poptOption long_options[] = {
+@@ -523,6 +525,7 @@ static struct poptOption long_options[] = {
{"chmod", 0, POPT_ARG_STRING, 0, OPT_CHMOD, 0, 0 },
{"ignore-times", 'I', POPT_ARG_NONE, &ignore_times, 0, 0, 0 },
{"size-only", 0, POPT_ARG_NONE, &size_only, 0, 0, 0 },
{"one-file-system", 'x', POPT_ARG_NONE, 0, 'x', 0, 0 },
{"update", 'u', POPT_ARG_NONE, &update_only, 0, 0, 0 },
{"existing", 0, POPT_ARG_NONE, &ignore_non_existing, 0, 0, 0 },
-@@ -1896,6 +1899,9 @@ void server_options(char **args, int *argc_p)
+@@ -1904,6 +1907,9 @@ void server_options(char **args, int *argc_p)
}
}
diff --git a/options.c b/options.c
--- a/options.c
+++ b/options.c
-@@ -387,6 +387,8 @@ void usage(enum logcode F)
+@@ -388,6 +388,8 @@ void usage(enum logcode F)
rprintf(F," -T, --temp-dir=DIR create temporary files in directory DIR\n");
rprintf(F," -y, --fuzzy find similar file for basis if no dest file\n");
rprintf(F," --detect-renamed try to find renamed files to speed up the transfer\n");
rprintf(F," --compare-dest=DIR also compare destination files relative to DIR\n");
rprintf(F," --copy-dest=DIR ... and include copies of unchanged files\n");
rprintf(F," --link-dest=DIR hardlink to files in DIR when unchanged\n");
-@@ -565,7 +567,9 @@ static struct poptOption long_options[] = {
+@@ -566,7 +568,9 @@ static struct poptOption long_options[] = {
{"compare-dest", 0, POPT_ARG_STRING, 0, OPT_COMPARE_DEST, 0, 0 },
{"copy-dest", 0, POPT_ARG_STRING, 0, OPT_COPY_DEST, 0, 0 },
{"link-dest", 0, POPT_ARG_STRING, 0, OPT_LINK_DEST, 0, 0 },
{"fuzzy", 'y', POPT_ARG_NONE, &fuzzy_basis, 0, 0, 0 },
{"compress", 'z', POPT_ARG_NONE, 0, 'z', 0, 0 },
{"no-compress", 0, POPT_ARG_VAL, &do_compression, 0, 0, 0 },
-@@ -1892,8 +1896,14 @@ void server_options(char **args, int *argc_p)
+@@ -1900,8 +1904,14 @@ void server_options(char **args, int *argc_p)
args[ac++] = "--super";
if (size_only)
args[ac++] = "--size-only";
static char empty_sum[MAX_DIGEST_LEN];
static int flist_count_offset; /* for --delete --progress */
static int dir_count = 0;
-@@ -262,6 +265,45 @@ static int is_excluded(char *fname, int is_dir, int filter_level)
+@@ -261,6 +264,45 @@ static int is_excluded(char *fname, int is_dir, int filter_level)
return 0;
}
static void send_directory(int f, struct file_list *flist,
char *fbuf, int len, int flags);
-@@ -2183,6 +2225,25 @@ struct file_list *recv_file_list(int f)
+@@ -2167,6 +2209,25 @@ struct file_list *recv_file_list(int f)
- clean_flist(flist, relative_paths);
+ flist_sort_and_clean(flist, relative_paths);
+ if (detect_renamed) {
+ int j = flist->used;
diff --git a/options.c b/options.c
--- a/options.c
+++ b/options.c
-@@ -80,6 +80,7 @@ int am_generator = 0;
+@@ -81,6 +81,7 @@ int am_generator = 0;
int am_starting_up = 1;
int relative_paths = -1;
int implied_dirs = 1;
int numeric_ids = 0;
int allow_8bit_chars = 0;
int force_delete = 0;
-@@ -385,6 +386,7 @@ void usage(enum logcode F)
+@@ -386,6 +387,7 @@ void usage(enum logcode F)
rprintf(F," --modify-window=NUM compare mod-times with reduced accuracy\n");
rprintf(F," -T, --temp-dir=DIR create temporary files in directory DIR\n");
rprintf(F," -y, --fuzzy find similar file for basis if no dest file\n");
rprintf(F," --compare-dest=DIR also compare destination files relative to DIR\n");
rprintf(F," --copy-dest=DIR ... and include copies of unchanged files\n");
rprintf(F," --link-dest=DIR hardlink to files in DIR when unchanged\n");
-@@ -563,6 +565,7 @@ static struct poptOption long_options[] = {
+@@ -564,6 +566,7 @@ static struct poptOption long_options[] = {
{"compare-dest", 0, POPT_ARG_STRING, 0, OPT_COMPARE_DEST, 0, 0 },
{"copy-dest", 0, POPT_ARG_STRING, 0, OPT_COPY_DEST, 0, 0 },
{"link-dest", 0, POPT_ARG_STRING, 0, OPT_LINK_DEST, 0, 0 },
{"fuzzy", 'y', POPT_ARG_NONE, &fuzzy_basis, 0, 0, 0 },
{"compress", 'z', POPT_ARG_NONE, 0, 'z', 0, 0 },
{"no-compress", 0, POPT_ARG_VAL, &do_compression, 0, 0, 0 },
-@@ -1535,7 +1538,7 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
+@@ -1541,7 +1544,7 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
inplace = 1;
}
partial_dir = tmp_partialdir;
if (inplace) {
-@@ -1544,6 +1547,7 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
+@@ -1550,6 +1553,7 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
snprintf(err_buf, sizeof err_buf,
"--%s cannot be used with --%s\n",
append_mode ? "append" : "inplace",
delay_updates ? "delay-updates" : "partial-dir");
return 0;
}
-@@ -1888,6 +1892,8 @@ void server_options(char **args, int *argc_p)
+@@ -1896,6 +1900,8 @@ void server_options(char **args, int *argc_p)
args[ac++] = "--super";
if (size_only)
args[ac++] = "--size-only";
diff --git a/util.c b/util.c
--- a/util.c
+++ b/util.c
-@@ -1019,6 +1019,32 @@ int handle_partial_dir(const char *fname, int create)
+@@ -1022,6 +1022,32 @@ int handle_partial_dir(const char *fname, int create)
return 1;
}
diff --git a/options.c b/options.c
--- a/options.c
+++ b/options.c
-@@ -58,6 +58,7 @@ int preserve_uid = 0;
+@@ -59,6 +59,7 @@ int preserve_uid = 0;
int preserve_gid = 0;
int preserve_times = 0;
int update_only = 0;
int cvs_exclude = 0;
int dry_run = 0;
int do_xfers = 1;
-@@ -320,6 +321,7 @@ void usage(enum logcode F)
+@@ -321,6 +322,7 @@ void usage(enum logcode F)
rprintf(F," --backup-dir=DIR make backups into hierarchy based in DIR\n");
rprintf(F," --suffix=SUFFIX set backup suffix (default %s w/o --backup-dir)\n",BACKUP_SUFFIX);
rprintf(F," -u, --update skip files that are newer on the receiver\n");
rprintf(F," --inplace update destination files in-place (SEE MAN PAGE)\n");
rprintf(F," --append append data onto shorter files\n");
rprintf(F," --append-verify like --append, but with old data in file checksum\n");
-@@ -524,6 +526,7 @@ static struct poptOption long_options[] = {
+@@ -525,6 +527,7 @@ static struct poptOption long_options[] = {
{"size-only", 0, POPT_ARG_NONE, &size_only, 0, 0, 0 },
{"one-file-system", 'x', POPT_ARG_NONE, 0, 'x', 0, 0 },
{"update", 'u', POPT_ARG_NONE, &update_only, 0, 0, 0 },
diff --git a/options.c b/options.c
--- a/options.c
+++ b/options.c
-@@ -58,6 +58,7 @@ int preserve_uid = 0;
+@@ -59,6 +59,7 @@ int preserve_uid = 0;
int preserve_gid = 0;
int preserve_times = 0;
int update_only = 0;
int cvs_exclude = 0;
int dry_run = 0;
int do_xfers = 1;
-@@ -320,6 +321,9 @@ void usage(enum logcode F)
+@@ -321,6 +322,9 @@ void usage(enum logcode F)
rprintf(F," --backup-dir=DIR make backups into hierarchy based in DIR\n");
rprintf(F," --suffix=SUFFIX set backup suffix (default %s w/o --backup-dir)\n",BACKUP_SUFFIX);
rprintf(F," -u, --update skip files that are newer on the receiver\n");
rprintf(F," --inplace update destination files in-place (SEE MAN PAGE)\n");
rprintf(F," --append append data onto shorter files\n");
rprintf(F," --append-verify like --append, but with old data in file checksum\n");
-@@ -524,6 +528,9 @@ static struct poptOption long_options[] = {
+@@ -525,6 +529,9 @@ static struct poptOption long_options[] = {
{"size-only", 0, POPT_ARG_NONE, &size_only, 0, 0, 0 },
{"one-file-system", 'x', POPT_ARG_NONE, 0, 'x', 0, 0 },
{"update", 'u', POPT_ARG_NONE, &update_only, 0, 0, 0 },
{"existing", 0, POPT_ARG_NONE, &ignore_non_existing, 0, 0, 0 },
{"ignore-non-existing",0,POPT_ARG_NONE, &ignore_non_existing, 0, 0, 0 },
{"ignore-existing", 0, POPT_ARG_NONE, &ignore_existing, 0, 0, 0 },
-@@ -1662,6 +1669,11 @@ void server_options(char **args, int *argc_p)
+@@ -1670,6 +1677,11 @@ void server_options(char **args, int *argc_p)
if (!am_sender)
args[ac++] = "--sender";
-S, --sparse handle sparse files efficiently
+ --drop-cache tell OS to drop caching of file data
-n, --dry-run perform a trial run with no changes made
- -W, --whole-file copy files whole (without rsync algorithm)
+ -W, --whole-file copy files whole (w/o delta-xfer algorithm)
-x, --one-file-system don't cross filesystem boundaries
@@ -1023,6 +1024,10 @@ NOTE: Don't use this option when the destination is a Solaris "tmpfs"
filesystem. It doesn't seem to handle seeks over null regions
extern int uid_ndx;
extern int gid_ndx;
extern int eol_nulls;
-@@ -345,6 +346,9 @@ static void send_file_entry(int f, struct file_struct *file, int ndx, int first_
+@@ -344,6 +345,9 @@ static void send_file_entry(int f, struct file_struct *file, int ndx, int first_
{
static time_t modtime;
static mode_t mode;
if ((preserve_devices && IS_DEVICE(mode))
|| (preserve_specials && IS_SPECIAL(mode))) {
-@@ -523,6 +533,10 @@ static void send_file_entry(int f, struct file_struct *file, int ndx, int first_
+@@ -522,6 +532,10 @@ static void send_file_entry(int f, struct file_struct *file, int ndx, int first_
}
if (!(xflags & XMIT_SAME_MODE))
write_int(f, to_wire_mode(mode));
if (uid_ndx && !(xflags & XMIT_SAME_UID)) {
if (protocol_version < 30)
write_int(f, uid);
-@@ -611,6 +625,9 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
+@@ -610,6 +624,9 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
{
static int64 modtime;
static mode_t mode;
#ifdef SUPPORT_HARD_LINKS
static int64 dev;
#endif
-@@ -742,9 +759,12 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
+@@ -741,9 +758,12 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
}
if (!(xflags & XMIT_SAME_MODE))
mode = from_wire_mode(read_int(f));
if (uid_ndx && !(xflags & XMIT_SAME_UID)) {
if (protocol_version < 30)
-@@ -866,6 +886,10 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
+@@ -865,6 +885,10 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
OPT_EXTRA(file, 0)->unum = (uint32)(file_length >> 32);
}
file->mode = mode;
if (uid_ndx)
F_OWNER(file) = uid;
if (gid_ndx) {
-@@ -1196,6 +1220,10 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1193,6 +1217,10 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
OPT_EXTRA(file, 0)->unum = (uint32)(st.st_size >> 32);
}
file->mode = st.st_mode;
diff --git a/options.c b/options.c
--- a/options.c
+++ b/options.c
-@@ -51,6 +51,7 @@ int preserve_hard_links = 0;
+@@ -52,6 +52,7 @@ int preserve_hard_links = 0;
int preserve_acls = 0;
int preserve_xattrs = 0;
int preserve_perms = 0;
int preserve_executability = 0;
int preserve_devices = 0;
int preserve_specials = 0;
-@@ -222,6 +223,7 @@ static void print_rsync_version(enum logcode f)
+@@ -223,6 +224,7 @@ static void print_rsync_version(enum logcode f)
char const *links = "no ";
char const *iconv = "no ";
char const *ipv6 = "no ";
STRUCT_STAT *dumstat;
#if SUBPROTOCOL_VERSION != 0
-@@ -251,6 +253,9 @@ static void print_rsync_version(enum logcode f)
+@@ -252,6 +254,9 @@ static void print_rsync_version(enum logcode f)
#ifdef ICONV_OPTION
iconv = "";
#endif
rprintf(f, "%s version %s protocol version %d%s\n",
RSYNC_NAME, RSYNC_VERSION, PROTOCOL_VERSION, subprotocol);
-@@ -264,8 +269,8 @@ static void print_rsync_version(enum logcode f)
+@@ -265,8 +270,8 @@ static void print_rsync_version(enum logcode f)
(int)(sizeof (int64) * 8));
rprintf(f, " %ssocketpairs, %shardlinks, %ssymlinks, %sIPv6, batchfiles, %sinplace,\n",
got_socketpair, hardlinks, links, ipv6, have_inplace);
#ifdef MAINTAINER_MODE
rprintf(f, "Panic Action: \"%s\"\n", get_panic_action());
-@@ -332,6 +337,7 @@ void usage(enum logcode F)
+@@ -333,6 +338,7 @@ void usage(enum logcode F)
rprintf(F," -K, --keep-dirlinks treat symlinked dir on receiver as dir\n");
rprintf(F," -H, --hard-links preserve hard links\n");
rprintf(F," -p, --perms preserve permissions\n");
rprintf(F," -E, --executability preserve the file's executability\n");
rprintf(F," --chmod=CHMOD affect file and/or directory permissions\n");
#ifdef SUPPORT_ACLS
-@@ -472,6 +478,8 @@ static struct poptOption long_options[] = {
+@@ -473,6 +479,8 @@ static struct poptOption long_options[] = {
{"perms", 'p', POPT_ARG_VAL, &preserve_perms, 1, 0, 0 },
{"no-perms", 0, POPT_ARG_VAL, &preserve_perms, 0, 0, 0 },
{"no-p", 0, POPT_ARG_VAL, &preserve_perms, 0, 0, 0 },
{"executability", 'E', POPT_ARG_NONE, &preserve_executability, 0, 0, 0 },
{"acls", 'A', POPT_ARG_NONE, 0, 'A', 0, 0 },
{"no-acls", 0, POPT_ARG_VAL, &preserve_acls, 0, 0, 0 },
-@@ -1287,6 +1295,15 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
+@@ -1289,6 +1297,15 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
}
#endif
if (write_batch && read_batch) {
snprintf(err_buf, sizeof err_buf,
"--write-batch and --read-batch can not be used together\n");
-@@ -1795,6 +1812,9 @@ void server_options(char **args, int *argc_p)
+@@ -1803,6 +1820,9 @@ void server_options(char **args, int *argc_p)
if (xfer_dirs && !recurse && delete_mode && am_sender)
args[ac++] = "--no-r";
static const char *default_charset(void)
{
# if defined HAVE_LIBCHARSET_H && defined HAVE_LOCALE_CHARSET
-@@ -337,6 +348,41 @@ mode_t dest_mode(mode_t flist_mode, mode_t stat_mode, int dflt_perms,
+@@ -338,6 +349,41 @@ mode_t dest_mode(mode_t flist_mode, mode_t stat_mode, int dflt_perms,
return new_mode;
}
int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
const char *fnamecmp, int flags)
{
-@@ -468,6 +514,15 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
+@@ -469,6 +515,15 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
}
#endif
if (verbose > 1 && flags & ATTRS_REPORT) {
if (updated)
rprintf(FCLIENT, "%s\n", fname);
-@@ -527,6 +582,9 @@ void finish_transfer(const char *fname, const char *fnametmp,
+@@ -528,6 +583,9 @@ void finish_transfer(const char *fname, const char *fnametmp,
set_file_attrs(fnametmp, file, NULL, fnamecmp,
ok_to_set_time ? 0 : ATTRS_SKIP_MTIME);
/* move tmp file over real file */
if (verbose > 2)
rprintf(FINFO, "renaming %s to %s\n", fnametmp, fname);
-@@ -541,6 +599,9 @@ void finish_transfer(const char *fname, const char *fnametmp,
+@@ -542,6 +600,9 @@ void finish_transfer(const char *fname, const char *fnametmp,
}
if (ret == 0) {
/* The file was moved into place (not copied), so it's done. */
diff --git a/options.c b/options.c
--- a/options.c
+++ b/options.c
-@@ -46,6 +46,7 @@ int append_mode = 0;
+@@ -47,6 +47,7 @@ int append_mode = 0;
int keep_dirlinks = 0;
int copy_dirlinks = 0;
int copy_links = 0;
int preserve_links = 0;
int preserve_hard_links = 0;
int preserve_acls = 0;
-@@ -377,6 +378,7 @@ void usage(enum logcode F)
+@@ -378,6 +379,7 @@ void usage(enum logcode F)
rprintf(F," --partial-dir=DIR put a partially transferred file into DIR\n");
rprintf(F," --delay-updates put all updated files into place at transfer's end\n");
rprintf(F," -m, --prune-empty-dirs prune empty directory chains from the file-list\n");
rprintf(F," --numeric-ids don't map uid/gid values by user/group name\n");
rprintf(F," --timeout=SECONDS set I/O timeout in seconds\n");
rprintf(F," --contimeout=SECONDS set daemon connection timeout in seconds\n");
-@@ -606,6 +608,7 @@ static struct poptOption long_options[] = {
+@@ -607,6 +609,7 @@ static struct poptOption long_options[] = {
{"timeout", 0, POPT_ARG_INT, &io_timeout, 0, 0, 0 },
{"no-timeout", 0, POPT_ARG_VAL, &io_timeout, 0, 0, 0 },
{"contimeout", 0, POPT_ARG_INT, &connect_timeout, 0, 0, 0 },
{"rsh", 'e', POPT_ARG_STRING, &shell_cmd, 0, 0, 0 },
{"rsync-path", 0, POPT_ARG_STRING, &rsync_path, 0, 0, 0 },
{"temp-dir", 'T', POPT_ARG_STRING, &tmpdir, 0, 0, 0 },
-@@ -1946,6 +1949,9 @@ void server_options(char **args, int *argc_p)
+@@ -1954,6 +1957,9 @@ void server_options(char **args, int *argc_p)
args[ac++] = tmpdir;
}
extern int ignore_errors;
extern int numeric_ids;
extern int recurse;
-@@ -2619,6 +2620,7 @@ int f_name_cmp(const struct file_struct *f1, const struct file_struct *f2)
+@@ -2604,6 +2605,7 @@ int f_name_cmp(const struct file_struct *f1, const struct file_struct *f2)
{
int dif;
const uchar *c1, *c2;
enum fnc_state state1, state2;
enum fnc_type type1, type2;
enum fnc_type t_path = protocol_version >= 29 ? t_PATH : t_ITEM;
-@@ -2729,7 +2731,15 @@ int f_name_cmp(const struct file_struct *f1, const struct file_struct *f2)
+@@ -2714,7 +2716,15 @@ int f_name_cmp(const struct file_struct *f1, const struct file_struct *f2)
if (type1 != type2)
return type1 == t_PATH ? 1 : -1;
}
diff --git a/options.c b/options.c
--- a/options.c
+++ b/options.c
-@@ -116,6 +116,7 @@ OFF_T max_size = 0;
+@@ -117,6 +117,7 @@ OFF_T max_size = 0;
OFF_T min_size = 0;
int ignore_errors = 0;
int modify_window = 0;
int blocking_io = -1;
int checksum_seed = 0;
int inplace = 0;
-@@ -402,6 +403,7 @@ void usage(enum logcode F)
+@@ -403,6 +404,7 @@ void usage(enum logcode F)
rprintf(F," --files-from=FILE read list of source-file names from FILE\n");
rprintf(F," -0, --from0 all *-from/filter files are delimited by 0s\n");
rprintf(F," -s, --protect-args no space-splitting; only wildcard special-chars\n");
rprintf(F," --address=ADDRESS bind address for outgoing socket to daemon\n");
rprintf(F," --port=PORT specify double-colon alternate port number\n");
rprintf(F," --sockopts=OPTIONS specify custom TCP options\n");
-@@ -595,6 +597,8 @@ static struct poptOption long_options[] = {
+@@ -596,6 +598,8 @@ static struct poptOption long_options[] = {
{"read-batch", 0, POPT_ARG_STRING, &batch_name, OPT_READ_BATCH, 0, 0 },
{"write-batch", 0, POPT_ARG_STRING, &batch_name, OPT_WRITE_BATCH, 0, 0 },
{"only-write-batch", 0, POPT_ARG_STRING, &batch_name, OPT_ONLY_WRITE_BATCH, 0, 0 },
{"files-from", 0, POPT_ARG_STRING, &files_from, 0, 0, 0 },
{"from0", '0', POPT_ARG_VAL, &eol_nulls, 1, 0, 0},
{"no-from0", 0, POPT_ARG_VAL, &eol_nulls, 0, 0, 0},
-@@ -1908,6 +1912,9 @@ void server_options(char **args, int *argc_p)
+@@ -1916,6 +1920,9 @@ void server_options(char **args, int *argc_p)
args[ac++] = arg;
}
extern char curr_dir[MAXPATHLEN];
-@@ -823,7 +824,7 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
+@@ -822,7 +823,7 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
extra_len += (S_ISDIR(mode) ? 2 : 1) * EXTRA_LEN;
#endif
diff --git a/options.c b/options.c
--- a/options.c
+++ b/options.c
-@@ -155,6 +155,7 @@ char *backup_suffix = NULL;
+@@ -156,6 +156,7 @@ char *backup_suffix = NULL;
char *tmpdir = NULL;
char *partial_dir = NULL;
char *basis_dir[MAX_BASIS_DIRS+1];
char *config_file = NULL;
char *shell_cmd = NULL;
char *logfile_name = NULL;
-@@ -388,6 +389,7 @@ void usage(enum logcode F)
+@@ -389,6 +390,7 @@ void usage(enum logcode F)
rprintf(F," --compare-dest=DIR also compare destination files relative to DIR\n");
rprintf(F," --copy-dest=DIR ... and include copies of unchanged files\n");
rprintf(F," --link-dest=DIR hardlink to files in DIR when unchanged\n");
rprintf(F," -z, --compress compress file data during the transfer\n");
rprintf(F," --compress-level=NUM explicitly set compression level\n");
rprintf(F," --skip-compress=LIST skip compressing files with a suffix in LIST\n");
-@@ -440,7 +442,7 @@ enum {OPT_VERSION = 1000, OPT_DAEMON, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
+@@ -441,7 +443,7 @@ enum {OPT_VERSION = 1000, OPT_DAEMON, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
OPT_FILTER, OPT_COMPARE_DEST, OPT_COPY_DEST, OPT_LINK_DEST, OPT_HELP,
OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_MODIFY_WINDOW, OPT_MIN_SIZE, OPT_CHMOD,
OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_ONLY_WRITE_BATCH, OPT_MAX_SIZE,
OPT_SERVER, OPT_REFUSED_BASE = 9000};
static struct poptOption long_options[] = {
-@@ -563,6 +565,7 @@ static struct poptOption long_options[] = {
+@@ -564,6 +566,7 @@ static struct poptOption long_options[] = {
{"compare-dest", 0, POPT_ARG_STRING, 0, OPT_COMPARE_DEST, 0, 0 },
{"copy-dest", 0, POPT_ARG_STRING, 0, OPT_COPY_DEST, 0, 0 },
{"link-dest", 0, POPT_ARG_STRING, 0, OPT_LINK_DEST, 0, 0 },
{"fuzzy", 'y', POPT_ARG_NONE, &fuzzy_basis, 0, 0, 0 },
{"compress", 'z', POPT_ARG_NONE, 0, 'z', 0, 0 },
{"no-compress", 0, POPT_ARG_VAL, &do_compression, 0, 0, 0 },
-@@ -1224,6 +1227,21 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
+@@ -1226,6 +1229,21 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
return 0;
#endif
default:
/* A large opt value means that set_refuse_options()
* turned this option off. */
-@@ -1966,6 +1984,11 @@ void server_options(char **args, int *argc_p)
+@@ -1974,6 +1992,11 @@ void server_options(char **args, int *argc_p)
} else if (inplace)
args[ac++] = "--inplace";
}
static void handle_delayed_updates(char *local_name)
-@@ -673,7 +684,7 @@ int recv_files(int f_in, char *local_name)
+@@ -675,7 +686,7 @@ int recv_files(int f_in, char *local_name)
/* recv file data */
recv_ok = receive_data(f_in, fnamecmp, fd1, st.st_size,
extern struct file_list *cur_flist, *first_flist, *dir_flist;
extern struct chmod_mode_struct *daemon_chmod_modes;
#ifdef ICONV_OPTION
-@@ -530,8 +531,15 @@ void finish_transfer(const char *fname, const char *fnametmp,
+@@ -531,8 +532,15 @@ void finish_transfer(const char *fname, const char *fnametmp,
/* move tmp file over real file */
if (verbose > 2)
rprintf(FINFO, "renaming %s to %s\n", fnametmp, fname);
diff --git a/rsync.h b/rsync.h
--- a/rsync.h
+++ b/rsync.h
-@@ -817,6 +817,14 @@ struct stats {
- int current_file_index;
+@@ -816,6 +816,14 @@ struct stats {
+ int num_transferred_files;
};
+struct hashfile_struct {
diff --git a/options.c b/options.c
--- a/options.c
+++ b/options.c
-@@ -1469,7 +1469,8 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
+@@ -1475,7 +1475,8 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
else if (log_format_has(stdout_format, 'i'))
stdout_format_has_i = itemize_changes | 1;
if (!log_format_has(stdout_format, 'b')
diff --git a/options.c b/options.c
--- a/options.c
+++ b/options.c
-@@ -57,6 +57,7 @@ int preserve_specials = 0;
+@@ -58,6 +58,7 @@ int preserve_specials = 0;
int preserve_uid = 0;
int preserve_gid = 0;
int preserve_times = 0;
int update_only = 0;
int cvs_exclude = 0;
int dry_run = 0;
-@@ -347,6 +348,7 @@ void usage(enum logcode F)
+@@ -348,6 +349,7 @@ void usage(enum logcode F)
rprintf(F," -D same as --devices --specials\n");
rprintf(F," -t, --times preserve modification times\n");
rprintf(F," -O, --omit-dir-times omit directories from --times\n");
rprintf(F," --super receiver attempts super-user activities\n");
#ifdef SUPPORT_XATTRS
rprintf(F," --fake-super store/recover privileged attrs using xattrs\n");
-@@ -485,6 +487,7 @@ static struct poptOption long_options[] = {
+@@ -486,6 +488,7 @@ static struct poptOption long_options[] = {
{"omit-dir-times", 'O', POPT_ARG_VAL, &omit_dir_times, 1, 0, 0 },
{"no-omit-dir-times",0, POPT_ARG_VAL, &omit_dir_times, 0, 0, 0 },
{"no-O", 0, POPT_ARG_VAL, &omit_dir_times, 0, 0, 0 },
{"modify-window", 0, POPT_ARG_INT, &modify_window, OPT_MODIFY_WINDOW, 0, 0 },
{"super", 0, POPT_ARG_VAL, &am_root, 2, 0, 0 },
{"no-super", 0, POPT_ARG_VAL, &am_root, 0, 0, 0 },
-@@ -1454,6 +1457,8 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
+@@ -1460,6 +1463,8 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
parse_rule(&filter_list, backup_dir_buf, 0, 0);
}
if (make_backups && !backup_dir) {
omit_dir_times = 0; /* Implied, so avoid -O to sender. */
if (preserve_times > 1)
-@@ -1690,6 +1695,8 @@ void server_options(char **args, int *argc_p)
+@@ -1698,6 +1703,8 @@ void server_options(char **args, int *argc_p)
argstr[x++] = 'm';
if (omit_dir_times)
argstr[x++] = 'O';
extern int am_root;
extern int am_server;
extern int am_sender;
-@@ -400,9 +401,11 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
+@@ -401,9 +402,11 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
updated = 1;
}
diff --git a/options.c b/options.c
--- a/options.c
+++ b/options.c
-@@ -183,6 +183,14 @@ int logfile_format_has_o_or_i = 0;
+@@ -184,6 +184,14 @@ int logfile_format_has_o_or_i = 0;
int always_checksum = 0;
int list_only = 0;
#define MAX_BATCH_NAME_LEN 256 /* Must be less than MAXPATHLEN-13 */
char *batch_name = NULL;
-@@ -222,6 +230,7 @@ static void print_rsync_version(enum logcode f)
+@@ -223,6 +231,7 @@ static void print_rsync_version(enum logcode f)
char const *links = "no ";
char const *iconv = "no ";
char const *ipv6 = "no ";
STRUCT_STAT *dumstat;
#if SUBPROTOCOL_VERSION != 0
-@@ -251,6 +260,9 @@ static void print_rsync_version(enum logcode f)
+@@ -252,6 +261,9 @@ static void print_rsync_version(enum logcode f)
#ifdef ICONV_OPTION
iconv = "";
#endif
rprintf(f, "%s version %s protocol version %d%s\n",
RSYNC_NAME, RSYNC_VERSION, PROTOCOL_VERSION, subprotocol);
-@@ -264,8 +276,8 @@ static void print_rsync_version(enum logcode f)
+@@ -265,8 +277,8 @@ static void print_rsync_version(enum logcode f)
(int)(sizeof (int64) * 8));
rprintf(f, " %ssocketpairs, %shardlinks, %ssymlinks, %sIPv6, batchfiles, %sinplace,\n",
got_socketpair, hardlinks, links, ipv6, have_inplace);
#ifdef MAINTAINER_MODE
rprintf(f, "Panic Action: \"%s\"\n", get_panic_action());
-@@ -427,6 +439,13 @@ void usage(enum logcode F)
+@@ -428,6 +440,13 @@ void usage(enum logcode F)
#endif
rprintf(F," -4, --ipv4 prefer IPv4\n");
rprintf(F," -6, --ipv6 prefer IPv6\n");
rprintf(F," --version print version number\n");
rprintf(F,"(-h) --help show this help (-h works with no other options)\n");
-@@ -440,7 +459,7 @@ enum {OPT_VERSION = 1000, OPT_DAEMON, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
+@@ -441,7 +460,7 @@ enum {OPT_VERSION = 1000, OPT_DAEMON, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
OPT_FILTER, OPT_COMPARE_DEST, OPT_COPY_DEST, OPT_LINK_DEST, OPT_HELP,
OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_MODIFY_WINDOW, OPT_MIN_SIZE, OPT_CHMOD,
OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_ONLY_WRITE_BATCH, OPT_MAX_SIZE,
OPT_SERVER, OPT_REFUSED_BASE = 9000};
static struct poptOption long_options[] = {
-@@ -626,6 +645,13 @@ static struct poptOption long_options[] = {
+@@ -627,6 +646,13 @@ static struct poptOption long_options[] = {
{"checksum-seed", 0, POPT_ARG_INT, &checksum_seed, 0, 0, 0 },
{"server", 0, POPT_ARG_NONE, 0, OPT_SERVER, 0, 0 },
{"sender", 0, POPT_ARG_NONE, 0, OPT_SENDER, 0, 0 },
/* All the following options switch us into daemon-mode option-parsing. */
{"config", 0, POPT_ARG_STRING, 0, OPT_DAEMON, 0, 0 },
{"daemon", 0, POPT_ARG_NONE, 0, OPT_DAEMON, 0, 0 },
-@@ -651,6 +677,13 @@ static void daemon_usage(enum logcode F)
+@@ -652,6 +678,13 @@ static void daemon_usage(enum logcode F)
rprintf(F," -v, --verbose increase verbosity\n");
rprintf(F," -4, --ipv4 prefer IPv4\n");
rprintf(F," -6, --ipv6 prefer IPv6\n");
rprintf(F," --help show this help screen\n");
rprintf(F,"\n");
-@@ -675,6 +708,13 @@ static struct poptOption long_daemon_options[] = {
+@@ -676,6 +709,13 @@ static struct poptOption long_daemon_options[] = {
{"protocol", 0, POPT_ARG_INT, &protocol_version, 0, 0, 0 },
{"server", 0, POPT_ARG_NONE, &am_server, 0, 0, 0 },
{"temp-dir", 'T', POPT_ARG_STRING, &tmpdir, 0, 0, 0 },
{"verbose", 'v', POPT_ARG_NONE, 0, 'v', 0, 0 },
{"no-verbose", 0, POPT_ARG_VAL, &verbose, 0, 0, 0 },
{"no-v", 0, POPT_ARG_VAL, &verbose, 0, 0, 0 },
-@@ -949,6 +989,12 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
+@@ -950,6 +990,12 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
verbose++;
break;
default:
rprintf(FERROR,
"rsync: %s: %s (in daemon mode)\n",
-@@ -972,6 +1018,17 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
+@@ -973,6 +1019,17 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
exit_cleanup(RERR_SYNTAX);
}
*argv_p = argv = poptGetArgs(pc);
*argc_p = argc = count_args(argv);
am_starting_up = 0;
-@@ -1224,6 +1281,12 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
+@@ -1226,6 +1283,12 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
return 0;
#endif
default:
/* A large opt value means that set_refuse_options()
* turned this option off. */
-@@ -1538,6 +1601,17 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
+@@ -1544,6 +1607,17 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
if (delay_updates && !partial_dir)
partial_dir = tmp_partialdir;
if (inplace) {
#ifdef HAVE_FTRUNCATE
if (partial_dir) {
-@@ -2010,10 +2084,27 @@ char *check_for_hostspec(char *s, char **host_ptr, int *port_ptr)
+@@ -2018,10 +2092,27 @@ char *check_for_hostspec(char *s, char **host_ptr, int *port_ptr)
char *p;
int not_host;
int hostlen;
diff --git a/options.c b/options.c
--- a/options.c
+++ b/options.c
-@@ -71,6 +71,7 @@ int remove_source_files = 0;
+@@ -72,6 +72,7 @@ int remove_source_files = 0;
int one_file_system = 0;
int protocol_version = PROTOCOL_VERSION;
int sparse_files = 0;
int do_compression = 0;
int def_compress_level = Z_DEFAULT_COMPRESSION;
int am_root = 0; /* 0 = normal, 1 = root, 2 = --super, -1 = --fake-super */
-@@ -222,6 +223,7 @@ static void print_rsync_version(enum logcode f)
+@@ -223,6 +224,7 @@ static void print_rsync_version(enum logcode f)
char const *links = "no ";
char const *iconv = "no ";
char const *ipv6 = "no ";
STRUCT_STAT *dumstat;
#if SUBPROTOCOL_VERSION != 0
-@@ -251,6 +253,9 @@ static void print_rsync_version(enum logcode f)
+@@ -252,6 +254,9 @@ static void print_rsync_version(enum logcode f)
#ifdef ICONV_OPTION
iconv = "";
#endif
rprintf(f, "%s version %s protocol version %d%s\n",
RSYNC_NAME, RSYNC_VERSION, PROTOCOL_VERSION, subprotocol);
-@@ -264,8 +269,8 @@ static void print_rsync_version(enum logcode f)
+@@ -265,8 +270,8 @@ static void print_rsync_version(enum logcode f)
(int)(sizeof (int64) * 8));
rprintf(f, " %ssocketpairs, %shardlinks, %ssymlinks, %sIPv6, batchfiles, %sinplace,\n",
got_socketpair, hardlinks, links, ipv6, have_inplace);
#ifdef MAINTAINER_MODE
rprintf(f, "Panic Action: \"%s\"\n", get_panic_action());
-@@ -352,6 +357,9 @@ void usage(enum logcode F)
+@@ -353,6 +358,9 @@ void usage(enum logcode F)
rprintf(F," --fake-super store/recover privileged attrs using xattrs\n");
#endif
rprintf(F," -S, --sparse handle sparse files efficiently\n");
+ rprintf(F," --preallocate posix_fallocate dest files before writing them\n");
+#endif
rprintf(F," -n, --dry-run perform a trial run with no changes made\n");
- rprintf(F," -W, --whole-file copy files whole (without rsync algorithm)\n");
+ rprintf(F," -W, --whole-file copy files whole (without delta-xfer algorithm)\n");
rprintf(F," -x, --one-file-system don't cross filesystem boundaries\n");
-@@ -530,6 +538,7 @@ static struct poptOption long_options[] = {
+@@ -531,6 +539,7 @@ static struct poptOption long_options[] = {
{"max-size", 0, POPT_ARG_STRING, &max_size_arg, OPT_MAX_SIZE, 0, 0 },
{"min-size", 0, POPT_ARG_STRING, &min_size_arg, OPT_MIN_SIZE, 0, 0 },
{"sparse", 'S', POPT_ARG_NONE, &sparse_files, 0, 0, 0 },
{"inplace", 0, POPT_ARG_NONE, &inplace, 0, 0, 0 },
{"append", 0, POPT_ARG_NONE, 0, OPT_APPEND, 0, 0 },
{"append-verify", 0, POPT_ARG_VAL, &append_mode, 2, 0, 0 },
-@@ -1287,6 +1296,15 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
+@@ -1289,6 +1298,15 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
}
#endif
if (write_batch && read_batch) {
snprintf(err_buf, sizeof err_buf,
"--write-batch and --read-batch can not be used together\n");
-@@ -1991,6 +2009,9 @@ void server_options(char **args, int *argc_p)
+@@ -1999,6 +2017,9 @@ void server_options(char **args, int *argc_p)
else if (remove_source_files)
args[ac++] = "--remove-sent-files";
-S, --sparse handle sparse files efficiently
+ --preallocate posix_fallocate dest files before writing
-n, --dry-run perform a trial run with no changes made
- -W, --whole-file copy files whole (without rsync algorithm)
+ -W, --whole-file copy files whole (w/o delta-xfer algorithm)
-x, --one-file-system don't cross filesystem boundaries
@@ -1023,6 +1024,19 @@ NOTE: Don't use this option when the destination is a Solaris "tmpfs"
filesystem. It doesn't seem to handle seeks over null regions
diff --git a/options.c b/options.c
--- a/options.c
+++ b/options.c
-@@ -107,6 +107,7 @@ int size_only = 0;
+@@ -108,6 +108,7 @@ int size_only = 0;
int daemon_bwlimit = 0;
int bwlimit = 0;
int fuzzy_basis = 0;
size_t bwlimit_writemax = 0;
int ignore_existing = 0;
int ignore_non_existing = 0;
-@@ -418,6 +419,7 @@ void usage(enum logcode F)
+@@ -419,6 +420,7 @@ void usage(enum logcode F)
rprintf(F," --password-file=FILE read daemon-access password from FILE\n");
rprintf(F," --list-only list the files instead of copying them\n");
rprintf(F," --bwlimit=KBPS limit I/O bandwidth; KBytes per second\n");
rprintf(F," --write-batch=FILE write a batched update to FILE\n");
rprintf(F," --only-write-batch=FILE like --write-batch but w/o updating destination\n");
rprintf(F," --read-batch=FILE read a batched update from FILE\n");
-@@ -585,6 +587,7 @@ static struct poptOption long_options[] = {
+@@ -586,6 +588,7 @@ static struct poptOption long_options[] = {
{"itemize-changes", 'i', POPT_ARG_NONE, 0, 'i', 0, 0 },
{"no-itemize-changes",0, POPT_ARG_VAL, &itemize_changes, 0, 0, 0 },
{"no-i", 0, POPT_ARG_VAL, &itemize_changes, 0, 0, 0 },
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) $(LIBSLP)
$(OBJS): $(HEADERS)
-
+ $(CHECK_OBJS): $(HEADERS)
diff --git a/clientserver.c b/clientserver.c
--- a/clientserver.c
+++ b/clientserver.c
diff --git a/main.c b/main.c
--- a/main.c
+++ b/main.c
-@@ -1141,6 +1141,18 @@ static int start_client(int argc, char *argv[])
+@@ -1144,6 +1144,18 @@ static int start_client(int argc, char *argv[])
if (!read_batch) { /* for read_batch, NO source is specified */
char *path = check_for_hostspec(argv[0], &shell_machine, &rsync_port);
diff --git a/options.c b/options.c
--- a/options.c
+++ b/options.c
-@@ -222,6 +222,7 @@ static void print_rsync_version(enum logcode f)
+@@ -223,6 +223,7 @@ static void print_rsync_version(enum logcode f)
char const *links = "no ";
char const *iconv = "no ";
char const *ipv6 = "no ";
STRUCT_STAT *dumstat;
#if SUBPROTOCOL_VERSION != 0
-@@ -251,6 +252,9 @@ static void print_rsync_version(enum logcode f)
+@@ -252,6 +253,9 @@ static void print_rsync_version(enum logcode f)
#ifdef ICONV_OPTION
iconv = "";
#endif
rprintf(f, "%s version %s protocol version %d%s\n",
RSYNC_NAME, RSYNC_VERSION, PROTOCOL_VERSION, subprotocol);
-@@ -264,8 +268,8 @@ static void print_rsync_version(enum logcode f)
+@@ -265,8 +269,8 @@ static void print_rsync_version(enum logcode f)
(int)(sizeof (int64) * 8));
rprintf(f, " %ssocketpairs, %shardlinks, %ssymlinks, %sIPv6, batchfiles, %sinplace,\n",
got_socketpair, hardlinks, links, ipv6, have_inplace);
diff --git a/options.c b/options.c
--- a/options.c
+++ b/options.c
-@@ -31,6 +31,7 @@ extern struct filter_list_struct filter_list;
+@@ -32,6 +32,7 @@ extern struct filter_list_struct filter_list;
extern struct filter_list_struct server_filter_list;
int make_backups = 0;
/**
* If 1, send the whole file as literal data rather than trying to
-@@ -361,6 +362,7 @@ void usage(enum logcode F)
+@@ -362,6 +363,7 @@ void usage(enum logcode F)
rprintf(F," --existing skip creating new files on receiver\n");
rprintf(F," --ignore-existing skip updating files that already exist on receiver\n");
rprintf(F," --remove-source-files sender removes synchronized files (non-dirs)\n");
rprintf(F," --del an alias for --delete-during\n");
rprintf(F," --delete delete extraneous files from destination dirs\n");
rprintf(F," --delete-before receiver deletes before transfer, not during\n");
-@@ -588,6 +590,7 @@ static struct poptOption long_options[] = {
+@@ -589,6 +591,7 @@ static struct poptOption long_options[] = {
{"bwlimit", 0, POPT_ARG_INT, &bwlimit, 0, 0, 0 },
{"no-bwlimit", 0, POPT_ARG_VAL, &bwlimit, 0, 0, 0 },
{"backup", 'b', POPT_ARG_VAL, &make_backups, 1, 0, 0 },
{"no-backup", 0, POPT_ARG_VAL, &make_backups, 0, 0, 0 },
{"backup-dir", 0, POPT_ARG_STRING, &backup_dir, 0, 0, 0 },
{"suffix", 0, POPT_ARG_STRING, &backup_suffix, 0, 0, 0 },
-@@ -1894,6 +1897,8 @@ void server_options(char **args, int *argc_p)
+@@ -1902,6 +1905,8 @@ void server_options(char **args, int *argc_p)
goto oom;
args[ac++] = arg;
}
diff --git a/main.c b/main.c
--- a/main.c
+++ b/main.c
-@@ -135,7 +135,7 @@ pid_t wait_process(pid_t pid, int *status_ptr, int flags)
+@@ -137,7 +137,7 @@ pid_t wait_process(pid_t pid, int *status_ptr, int flags)
}
/* Wait for a process to exit, calling io_flush while waiting. */
diff --git a/options.c b/options.c
--- a/options.c
+++ b/options.c
-@@ -104,6 +104,7 @@ int keep_partial = 0;
+@@ -105,6 +105,7 @@ int keep_partial = 0;
int safe_symlinks = 0;
int copy_unsafe_links = 0;
int size_only = 0;
int daemon_bwlimit = 0;
int bwlimit = 0;
int fuzzy_basis = 0;
-@@ -161,6 +162,8 @@ char *logfile_name = NULL;
+@@ -162,6 +163,8 @@ char *logfile_name = NULL;
char *logfile_format = NULL;
char *stdout_format = NULL;
char *password_file = NULL;
char *rsync_path = RSYNC_PATH;
char *backup_dir = NULL;
char backup_dir_buf[MAXPATHLEN];
-@@ -382,6 +385,7 @@ void usage(enum logcode F)
+@@ -383,6 +386,7 @@ void usage(enum logcode F)
rprintf(F," --contimeout=SECONDS set daemon connection timeout in seconds\n");
rprintf(F," -I, --ignore-times don't skip files that match in size and mod-time\n");
rprintf(F," --size-only skip files that match in size\n");
rprintf(F," --modify-window=NUM compare mod-times with reduced accuracy\n");
rprintf(F," -T, --temp-dir=DIR create temporary files in directory DIR\n");
rprintf(F," -y, --fuzzy find similar file for basis if no dest file\n");
-@@ -421,6 +425,8 @@ void usage(enum logcode F)
+@@ -422,6 +426,8 @@ void usage(enum logcode F)
rprintf(F," --write-batch=FILE write a batched update to FILE\n");
rprintf(F," --only-write-batch=FILE like --write-batch but w/o updating destination\n");
rprintf(F," --read-batch=FILE read a batched update from FILE\n");
rprintf(F," --protocol=NUM force an older protocol version to be used\n");
#ifdef ICONV_OPTION
rprintf(F," --iconv=CONVERT_SPEC request charset conversion of filenames\n");
-@@ -522,6 +528,7 @@ static struct poptOption long_options[] = {
+@@ -523,6 +529,7 @@ static struct poptOption long_options[] = {
{"chmod", 0, POPT_ARG_STRING, 0, OPT_CHMOD, 0, 0 },
{"ignore-times", 'I', POPT_ARG_NONE, &ignore_times, 0, 0, 0 },
{"size-only", 0, POPT_ARG_NONE, &size_only, 0, 0, 0 },
{"one-file-system", 'x', POPT_ARG_NONE, 0, 'x', 0, 0 },
{"update", 'u', POPT_ARG_NONE, &update_only, 0, 0, 0 },
{"existing", 0, POPT_ARG_NONE, &ignore_non_existing, 0, 0, 0 },
-@@ -622,6 +629,8 @@ static struct poptOption long_options[] = {
+@@ -623,6 +630,8 @@ static struct poptOption long_options[] = {
{"password-file", 0, POPT_ARG_STRING, &password_file, 0, 0, 0 },
{"blocking-io", 0, POPT_ARG_VAL, &blocking_io, 1, 0, 0 },
{"no-blocking-io", 0, POPT_ARG_VAL, &blocking_io, 0, 0, 0 },
{"protocol", 0, POPT_ARG_INT, &protocol_version, 0, 0, 0 },
{"checksum-seed", 0, POPT_ARG_INT, &checksum_seed, 0, 0, 0 },
{"server", 0, POPT_ARG_NONE, 0, OPT_SERVER, 0, 0 },
-@@ -1579,6 +1588,16 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
+@@ -1585,6 +1594,16 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
}
}
if (files_from) {
char *h, *p;
int q;
-@@ -1896,6 +1915,25 @@ void server_options(char **args, int *argc_p)
+@@ -1904,6 +1923,25 @@ void server_options(char **args, int *argc_p)
}
}
while (1) {
cleanup_disable();
-@@ -671,6 +691,9 @@ int recv_files(int f_in, char *local_name)
+@@ -673,6 +693,9 @@ int recv_files(int f_in, char *local_name)
else if (!am_server && verbose && do_progress)
rprintf(FINFO, "%s\n", fname);
/* recv file data */
recv_ok = receive_data(f_in, fnamecmp, fd1, st.st_size,
fname, fd2, F_LENGTH(file));
-@@ -685,6 +708,16 @@ int recv_files(int f_in, char *local_name)
+@@ -687,6 +710,16 @@ int recv_files(int f_in, char *local_name)
exit_cleanup(RERR_FILEIO);
}
if (verbose > 2)
rprintf(FINFO, "send_files starting\n");
-@@ -284,6 +305,7 @@ void send_files(int f_in, int f_out)
+@@ -285,6 +306,7 @@ void send_files(int f_in, int f_out)
exit_cleanup(RERR_PROTOCOL);
}
fd = do_open(fname, O_RDONLY, 0);
if (fd == -1) {
if (errno == ENOENT) {
-@@ -305,6 +327,33 @@ void send_files(int f_in, int f_out)
+@@ -306,6 +328,33 @@ void send_files(int f_in, int f_out)
continue;
}
/* map the local file */
if (do_fstat(fd, &st) != 0) {
io_error |= IOERR_GENERAL;
-@@ -355,6 +404,8 @@ void send_files(int f_in, int f_out)
+@@ -356,6 +405,8 @@ void send_files(int f_in, int f_out)
}
}
close(fd);
--- /dev/null
+This patch adds a --stdout=line|unbuf option that lets the
+user change the buffering of stdout.
+
+To use this patch, run these commands for a successful build:
+
+ patch -p1 <patches/stdout.diff
+ ./configure (optional if already run)
+ make
+
+diff --git a/options.c b/options.c
+--- a/options.c
++++ b/options.c
+@@ -203,6 +203,7 @@ static int refused_delete, refused_archive_part, refused_compress;
+ static int refused_partial, refused_progress, refused_delete_before;
+ static int refused_delete_during;
+ static int refused_inplace;
++static char *stdout_buffering;
+ static char *max_size_arg, *min_size_arg;
+ static char tmp_partialdir[] = ".~tmp~";
+
+@@ -419,6 +420,7 @@ void usage(enum logcode F)
+ rprintf(F," --password-file=FILE read daemon-access password from FILE\n");
+ rprintf(F," --list-only list the files instead of copying them\n");
+ rprintf(F," --bwlimit=KBPS limit I/O bandwidth; KBytes per second\n");
++ rprintf(F," --stdout=line|unbuf change buffering of stdout\n");
+ rprintf(F," --write-batch=FILE write a batched update to FILE\n");
+ rprintf(F," --only-write-batch=FILE like --write-batch but w/o updating destination\n");
+ rprintf(F," --read-batch=FILE read a batched update from FILE\n");
+@@ -623,6 +625,7 @@ static struct poptOption long_options[] = {
+ {"password-file", 0, POPT_ARG_STRING, &password_file, 0, 0, 0 },
+ {"blocking-io", 0, POPT_ARG_VAL, &blocking_io, 1, 0, 0 },
+ {"no-blocking-io", 0, POPT_ARG_VAL, &blocking_io, 0, 0, 0 },
++ {"stdout", 0, POPT_ARG_STRING, &stdout_buffering, 0, 0, 0 },
+ {"protocol", 0, POPT_ARG_INT, &protocol_version, 0, 0, 0 },
+ {"checksum-seed", 0, POPT_ARG_INT, &checksum_seed, 0, 0, 0 },
+ {"server", 0, POPT_ARG_NONE, 0, OPT_SERVER, 0, 0 },
+@@ -1241,6 +1244,13 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
+ }
+ }
+
++ if (stdout_buffering && !am_server) {
++ if (*stdout_buffering == 'u')
++ setvbuf(stdout, NULL, _IONBF, 0);
++ else
++ setvbuf(stdout, NULL, _IOLBF, 0);
++ }
++
+ if (human_readable && argc == 2) {
+ /* Allow the old meaning of 'h' (--help) on its own. */
+ usage(FINFO);
diff --git a/options.c b/options.c
--- a/options.c
+++ b/options.c
-@@ -111,6 +111,7 @@ size_t bwlimit_writemax = 0;
+@@ -112,6 +112,7 @@ size_t bwlimit_writemax = 0;
int ignore_existing = 0;
int ignore_non_existing = 0;
int need_messages_from_generator = 0;
int max_delete = INT_MIN;
OFF_T max_size = 0;
OFF_T min_size = 0;
-@@ -418,6 +419,8 @@ void usage(enum logcode F)
+@@ -419,6 +420,8 @@ void usage(enum logcode F)
rprintf(F," --password-file=FILE read daemon-access password from FILE\n");
rprintf(F," --list-only list the files instead of copying them\n");
rprintf(F," --bwlimit=KBPS limit I/O bandwidth; KBytes per second\n");
rprintf(F," --write-batch=FILE write a batched update to FILE\n");
rprintf(F," --only-write-batch=FILE like --write-batch but w/o updating destination\n");
rprintf(F," --read-batch=FILE read a batched update from FILE\n");
-@@ -440,7 +443,7 @@ enum {OPT_VERSION = 1000, OPT_DAEMON, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
+@@ -441,7 +444,7 @@ enum {OPT_VERSION = 1000, OPT_DAEMON, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
OPT_FILTER, OPT_COMPARE_DEST, OPT_COPY_DEST, OPT_LINK_DEST, OPT_HELP,
OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_MODIFY_WINDOW, OPT_MIN_SIZE, OPT_CHMOD,
OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_ONLY_WRITE_BATCH, OPT_MAX_SIZE,
OPT_SERVER, OPT_REFUSED_BASE = 9000};
static struct poptOption long_options[] = {
-@@ -606,6 +609,8 @@ static struct poptOption long_options[] = {
+@@ -607,6 +610,8 @@ static struct poptOption long_options[] = {
{"timeout", 0, POPT_ARG_INT, &io_timeout, 0, 0, 0 },
{"no-timeout", 0, POPT_ARG_VAL, &io_timeout, 0, 0, 0 },
{"contimeout", 0, POPT_ARG_INT, &connect_timeout, 0, 0, 0 },
{"rsh", 'e', POPT_ARG_STRING, &shell_cmd, 0, 0, 0 },
{"rsync-path", 0, POPT_ARG_STRING, &rsync_path, 0, 0, 0 },
{"temp-dir", 'T', POPT_ARG_STRING, &tmpdir, 0, 0, 0 },
-@@ -1224,6 +1229,36 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
+@@ -1226,6 +1231,36 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
return 0;
#endif
default:
/* A large opt value means that set_refuse_options()
* turned this option off. */
-@@ -1840,6 +1875,15 @@ void server_options(char **args, int *argc_p)
+@@ -1848,6 +1883,15 @@ void server_options(char **args, int *argc_p)
args[ac++] = arg;
}
#define PTR_SIZE (sizeof (struct file_struct *))
int io_error;
-@@ -606,6 +609,24 @@ static void send_file_entry(int f, struct file_struct *file, int ndx, int first_
+@@ -605,6 +608,24 @@ static void send_file_entry(int f, struct file_struct *file, int ndx, int first_
stats.total_size += F_LENGTH(file);
}
static struct file_struct *recv_file_entry(struct file_list *flist,
int xflags, int f)
{
-@@ -674,6 +695,9 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
+@@ -673,6 +694,9 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
}
#endif
diff --git a/options.c b/options.c
--- a/options.c
+++ b/options.c
-@@ -182,6 +182,8 @@ int logfile_format_has_i = 0;
+@@ -183,6 +183,8 @@ int logfile_format_has_i = 0;
int logfile_format_has_o_or_i = 0;
int always_checksum = 0;
int list_only = 0;
#define MAX_BATCH_NAME_LEN 256 /* Must be less than MAXPATHLEN-13 */
char *batch_name = NULL;
-@@ -425,6 +427,7 @@ void usage(enum logcode F)
+@@ -426,6 +428,7 @@ void usage(enum logcode F)
#ifdef ICONV_OPTION
rprintf(F," --iconv=CONVERT_SPEC request charset conversion of filenames\n");
#endif
rprintf(F," -4, --ipv4 prefer IPv4\n");
rprintf(F," -6, --ipv6 prefer IPv6\n");
rprintf(F," --version print version number\n");
-@@ -612,6 +615,7 @@ static struct poptOption long_options[] = {
+@@ -613,6 +616,7 @@ static struct poptOption long_options[] = {
#ifdef ICONV_OPTION
{"iconv", 0, POPT_ARG_STRING, &iconv_opt, 0, 0, 0 },
#endif
{"ipv4", '4', POPT_ARG_VAL, &default_af_hint, AF_INET, 0, 0 },
{"ipv6", '6', POPT_ARG_VAL, &default_af_hint, AF_INET6, 0, 0 },
{"8-bit-output", '8', POPT_ARG_NONE, &allow_8bit_chars, 0, 0, 0 },
-@@ -1623,6 +1627,31 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
+@@ -1631,6 +1635,31 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
}
}
am_starting_up = 0;
return 1;
-@@ -1991,6 +2020,12 @@ void server_options(char **args, int *argc_p)
+@@ -1999,6 +2028,12 @@ void server_options(char **args, int *argc_p)
else if (remove_source_files)
args[ac++] = "--remove-sent-files";
extern char curr_dir[MAXPATHLEN];
-@@ -753,7 +754,7 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
+@@ -752,7 +753,7 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
uid = (uid_t)read_varint(f);
if (xflags & XMIT_USER_NAME_FOLLOWS)
uid = recv_user_name(f, uid);
uid = match_uid(uid);
}
}
-@@ -765,7 +766,7 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
+@@ -764,7 +765,7 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
gid_flags = 0;
if (xflags & XMIT_GROUP_NAME_FOLLOWS)
gid = recv_group_name(f, gid, &gid_flags);
gid = match_gid(gid, &gid_flags);
}
}
-@@ -2090,8 +2091,13 @@ struct file_list *recv_file_list(int f)
+@@ -2074,8 +2075,13 @@ struct file_list *recv_file_list(int f)
int dstart, flags;
int64 start_read;
diff --git a/options.c b/options.c
--- a/options.c
+++ b/options.c
-@@ -165,6 +165,8 @@ char *rsync_path = RSYNC_PATH;
+@@ -166,6 +166,8 @@ char *rsync_path = RSYNC_PATH;
char *backup_dir = NULL;
char backup_dir_buf[MAXPATHLEN];
char *sockopts = NULL;
int rsync_port = 0;
int compare_dest = 0;
int copy_dest = 0;
-@@ -378,6 +380,8 @@ void usage(enum logcode F)
+@@ -379,6 +381,8 @@ void usage(enum logcode F)
rprintf(F," --delay-updates put all updated files into place at transfer's end\n");
rprintf(F," -m, --prune-empty-dirs prune empty directory chains from the file-list\n");
rprintf(F," --numeric-ids don't map uid/gid values by user/group name\n");
rprintf(F," --timeout=SECONDS set I/O timeout in seconds\n");
rprintf(F," --contimeout=SECONDS set daemon connection timeout in seconds\n");
rprintf(F," -I, --ignore-times don't skip files that match in size and mod-time\n");
-@@ -603,6 +607,8 @@ static struct poptOption long_options[] = {
+@@ -604,6 +608,8 @@ static struct poptOption long_options[] = {
{"no-s", 0, POPT_ARG_VAL, &protect_args, 0, 0, 0},
{"numeric-ids", 0, POPT_ARG_VAL, &numeric_ids, 1, 0, 0 },
{"no-numeric-ids", 0, POPT_ARG_VAL, &numeric_ids, 0, 0, 0 },
{"timeout", 0, POPT_ARG_INT, &io_timeout, 0, 0, 0 },
{"no-timeout", 0, POPT_ARG_VAL, &io_timeout, 0, 0, 0 },
{"contimeout", 0, POPT_ARG_INT, &connect_timeout, 0, 0, 0 },
-@@ -1934,6 +1940,18 @@ void server_options(char **args, int *argc_p)
+@@ -1942,6 +1948,18 @@ void server_options(char **args, int *argc_p)
args[ac++] = "--use-qsort";
if (am_sender) {