--- old/compat.c
+++ new/compat.c
-@@ -50,6 +50,8 @@ void setup_protocol(int f_out,int f_in)
+@@ -56,6 +56,8 @@ void setup_protocol(int f_out,int f_in)
preserve_uid = ++file_extra_cnt;
if (preserve_gid)
preserve_gid = ++file_extra_cnt;
if (!read_batch)
--- old/flist.c
+++ new/flist.c
-@@ -47,6 +47,7 @@ extern int preserve_devices;
+@@ -48,6 +48,7 @@ extern int preserve_devices;
extern int preserve_specials;
extern int preserve_uid;
extern int preserve_gid;
extern int relative_paths;
extern int implied_dirs;
extern int file_extra_cnt;
-@@ -137,6 +138,7 @@ void show_flist_stats(void)
+@@ -143,6 +144,7 @@ void show_flist_stats(void)
static void list_file_entry(struct file_struct *f)
{
char permbuf[PERMSTRING_SIZE];
double len;
if (!F_IS_ACTIVE(f)) {
-@@ -149,14 +151,16 @@ static void list_file_entry(struct file_
+@@ -155,14 +157,16 @@ static void list_file_entry(struct file_
#ifdef SUPPORT_LINKS
if (preserve_links && S_ISLNK(f->mode)) {
f_name(f, NULL));
}
}
-@@ -313,6 +317,7 @@ void flist_expand(struct file_list *flis
- static void send_file_entry(struct file_struct *file, int f, int ndx)
+@@ -346,6 +350,7 @@ int push_flist_dir(const char *dir, int
+ static void send_file_entry(int f, struct file_struct *file, int ndx)
{
static time_t modtime;
+ static time_t atime;
static mode_t mode;
static int64 dev;
static dev_t rdev;
-@@ -367,6 +372,13 @@ static void send_file_entry(struct file_
+@@ -413,6 +418,13 @@ static void send_file_entry(int f, struc
flags |= XMIT_SAME_TIME;
else
modtime = file->modtime;
#ifdef SUPPORT_HARD_LINKS
if (tmp_dev != 0) {
-@@ -434,6 +446,8 @@ static void send_file_entry(struct file_
+@@ -480,6 +492,8 @@ static void send_file_entry(int f, struc
write_int(f, modtime);
if (!(flags & XMIT_SAME_MODE))
write_int(f, to_wire_mode(mode));
+ if (preserve_atimes && !S_ISDIR(mode) && !(flags & XMIT_SAME_ATIME))
+ write_int(f, atime);
if (preserve_uid && !(flags & XMIT_SAME_UID)) {
- if (!numeric_ids)
- add_uid(uid);
-@@ -501,7 +515,7 @@ static void send_file_entry(struct file_
+ write_int(f, uid);
+ if (flags & XMIT_USER_NAME_FOLLOWS) {
+@@ -553,7 +567,7 @@ static void send_file_entry(int f, struc
static struct file_struct *recv_file_entry(struct file_list *flist,
int flags, int f)
{
static mode_t mode;
static int64 dev;
static dev_t rdev;
-@@ -522,7 +536,7 @@ static struct file_struct *recv_file_ent
- struct file_struct *file;
-
- if (!flist) {
-- modtime = 0, mode = 0;
-+ modtime = 0, atime = 0, mode = 0;
- dev = 0, rdev = MAKEDEV(0, 0);
- rdev_major = 0;
- uid = 0, gid = 0;
-@@ -610,6 +624,8 @@ static struct file_struct *recv_file_ent
+@@ -650,6 +664,8 @@ static struct file_struct *recv_file_ent
modtime = (time_t)read_int(f);
if (!(flags & XMIT_SAME_MODE))
mode = from_wire_mode(read_int(f));
if (chmod_modes && !S_ISLNK(mode))
mode = tweak_mode(mode, chmod_modes);
-@@ -700,6 +716,8 @@ static struct file_struct *recv_file_ent
- F_UID(file) = uid;
+@@ -758,6 +774,8 @@ static struct file_struct *recv_file_ent
+ F_OWNER(file) = uid;
if (preserve_gid)
- F_GID(file) = gid;
+ F_GROUP(file) = gid;
+ if (preserve_atimes)
+ F_ATIME(file) = atime;
- if (dirname_len) {
- file->dirname = lastdir = bp;
-@@ -1002,6 +1020,8 @@ struct file_struct *make_file(const char
- F_UID(file) = st.st_uid;
+ if (basename != thisname) {
+ file->dirname = lastdir;
+@@ -1055,6 +1073,8 @@ struct file_struct *make_file(const char
+ F_OWNER(file) = st.st_uid;
if (preserve_gid)
- F_GID(file) = st.st_gid;
+ F_GROUP(file) = st.st_gid;
+ if (preserve_atimes)
+ F_ATIME(file) = st.st_atime;
- if (dirname_len) {
- file->dirname = lastdir = bp;
+ if (basename != thisname)
+ file->dirname = lastdir;
--- old/generator.c
+++ new/generator.c
-@@ -43,6 +43,7 @@ extern int preserve_perms;
+@@ -44,6 +44,7 @@ extern int preserve_perms;
extern int preserve_uid;
extern int preserve_gid;
extern int preserve_times;
extern int omit_dir_times;
extern int delete_mode;
extern int delete_before;
-@@ -547,6 +548,9 @@ void itemize(struct file_struct *file, i
+@@ -539,6 +540,9 @@ void itemize(struct file_struct *file, i
&& (!(iflags & ITEM_XNAME_FOLLOWS) || *xname))
|| (keep_time && cmp_time(file->modtime, st->st_mtime) != 0))
iflags |= ITEM_REPORT_TIME;
if (!BITS_EQUAL(st->st_mode, file->mode, CHMOD_BITS))
iflags |= ITEM_REPORT_PERMS;
if (preserve_uid && am_root && F_UID(file) != st->st_uid)
-@@ -858,6 +862,8 @@ static int try_dests_reg(struct file_str
+@@ -849,6 +853,8 @@ static int try_dests_reg(struct file_str
if (link_dest) {
if (!hard_link_one(file, fname, cmpbuf, 1))
goto try_a_copy;
int update_only = 0;
int cvs_exclude = 0;
int dry_run = 0;
-@@ -306,8 +307,9 @@ void usage(enum logcode F)
+@@ -307,8 +308,9 @@ void usage(enum logcode F)
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," --super receiver attempts super-user activities\n");
rprintf(F," -S, --sparse handle sparse files efficiently\n");
rprintf(F," -n, --dry-run show what would have been transferred\n");
-@@ -424,6 +426,9 @@ static struct poptOption long_options[]
+@@ -425,6 +427,9 @@ static struct poptOption long_options[]
{"times", 't', POPT_ARG_VAL, &preserve_times, 1, 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, 2, 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 },
-@@ -1536,6 +1541,8 @@ void server_options(char **args,int *arg
+@@ -1552,6 +1557,8 @@ void server_options(char **args,int *arg
argstr[x++] = 'D';
if (preserve_times)
argstr[x++] = 't';
extern int preserve_times;
extern int omit_dir_times;
extern int am_root;
-@@ -182,6 +183,7 @@ int set_file_attrs(char *fname, struct f
+@@ -232,6 +233,7 @@ int set_file_attrs(char *fname, struct f
int updated = 0;
STRUCT_STAT st2;
int change_uid, change_gid;
mode_t new_mode = file->mode;
if (!st) {
-@@ -201,18 +203,36 @@ int set_file_attrs(char *fname, struct f
+@@ -251,18 +253,36 @@ int set_file_attrs(char *fname, struct f
}
}
change_uid = am_root && preserve_uid && st->st_uid != F_UID(file);
--- old/rsync.h
+++ new/rsync.h
-@@ -55,6 +55,7 @@
- #define XMIT_SAME_DEV_pre30 (1<<10) /* protocols < 30 */
- #define XMIT_HLINK_FIRST (1<<10) /* protocols >= 30 */
+@@ -57,6 +57,7 @@
#define XMIT_RDEV_MINOR_IS_SMALL (1<<11)
-+#define XMIT_SAME_ATIME (1<<12)
+ #define XMIT_USER_NAME_FOLLOWS (1<<12) /* protocols >= 30 */
+ #define XMIT_GROUP_NAME_FOLLOWS (1<<13) /* protocols >= 30 */
++#define XMIT_SAME_ATIME (1<<14) /* protocols >= 30 */
/* These flags are used in the live flist data. */
-@@ -128,6 +129,7 @@
+@@ -135,6 +136,7 @@
#define ATTRS_REPORT (1<<0)
#define ATTRS_SKIP_MTIME (1<<1)
#define FULL_FLUSH 1
#define NORMAL_FLUSH 0
-@@ -551,6 +553,7 @@ struct file_struct {
+@@ -565,6 +567,7 @@ struct file_struct {
extern int file_extra_cnt;
extern int preserve_uid;
extern int preserve_gid;
#define FILE_STRUCT_LEN (offsetof(struct file_struct, basename))
#define EXTRA_LEN (sizeof (union file_extras))
-@@ -583,6 +586,7 @@ extern int preserve_gid;
+@@ -597,6 +600,7 @@ extern int preserve_gid;
/* When the associated option is on, all entries will have these present: */
- #define F_UID(f) REQ_EXTRA(f, preserve_uid)->unum
- #define F_GID(f) REQ_EXTRA(f, preserve_gid)->unum
+ #define F_OWNER(f) REQ_EXTRA(f, preserve_uid)->unum
+ #define F_GROUP(f) REQ_EXTRA(f, preserve_gid)->unum
+#define F_ATIME(f) REQ_EXTRA(f, preserve_atimes)->unum
/* These items are per-entry optional and mutally exclusive: */
One other output is possible: when deleting files, the "%i" will output
--- old/sender.c
+++ new/sender.c
-@@ -41,6 +41,7 @@ extern int do_progress;
+@@ -42,6 +42,7 @@ extern int do_progress;
extern int inplace;
extern int batch_fd;
extern int write_batch;
+extern unsigned int file_struct_len;
extern struct stats stats;
- extern struct file_list *the_file_list;
+ extern struct file_list *cur_flist, *first_flist;
extern char *stdout_format;
--- old/testsuite/atimes.test
+++ new/testsuite/atimes.test
--- old/backup.c
+++ new/backup.c
-@@ -30,10 +30,17 @@ extern int safe_symlinks;
- extern int flist_extra_ndx;
- extern int file_struct_len;
+@@ -28,10 +28,17 @@ extern int preserve_specials;
+ extern int preserve_links;
+ extern int safe_symlinks;
extern int backup_dir_len;
+extern int backup_dir_dels_len;
extern unsigned int backup_dir_remainder;
/* make a complete pathname for backup file */
char *get_backup_name(const char *fname)
-@@ -52,11 +59,28 @@ char *get_backup_name(const char *fname)
+@@ -50,11 +57,28 @@ char *get_backup_name(const char *fname)
return NULL;
}
if (!fnamebak)
return 0;
-@@ -96,7 +120,8 @@ path
+@@ -94,7 +118,8 @@ path
static int make_bak_dir(char *fullpath)
{
STRUCT_STAT st;
char *end = rel + strlen(rel);
char *p = end;
-@@ -186,7 +211,8 @@ static int keep_backup(const char *fname
+@@ -184,7 +209,8 @@ static int keep_backup(const char *fname
if (!(file = make_file(fname, NULL, NULL, 0, NO_FILTERS)))
return 1; /* the file could have disappeared */
unmake_file(file);
return 0;
}
-@@ -285,3 +311,13 @@ int make_backup(const char *fname)
+@@ -284,3 +310,13 @@ int make_backup(const char *fname)
return keep_backup(fname);
return make_simple_backup(fname);
}
+}
--- old/generator.c
+++ new/generator.c
-@@ -92,6 +92,9 @@ extern dev_t filesystem_dev;
+@@ -93,6 +93,9 @@ extern dev_t filesystem_dev;
extern char *backup_dir;
extern char *backup_suffix;
extern int backup_suffix_len;
+extern char *backup_dir_dels;
+extern char *backup_suffix_dels;
+extern int backup_suffix_dels_len;
- extern struct file_list *the_file_list;
+ extern struct file_list *cur_flist, *first_flist, *dir_flist;
extern struct filter_list_struct server_filter_list;
-@@ -117,10 +120,14 @@ enum delret {
+@@ -123,10 +126,14 @@ enum delret {
static enum delret delete_dir_contents(char *fname, int flags);
}
/* Delete a file or directory. If DEL_RECURSE is set in the flags, this will
-@@ -156,9 +163,9 @@ static enum delret delete_item(char *fbu
+@@ -162,9 +169,9 @@ static enum delret delete_item(char *fbu
if (S_ISDIR(mode)) {
what = "rmdir";
ok = do_rmdir(fbuf) == 0;
-- } else if (make_backups && (backup_dir || !is_backup_file(fbuf))) {
-+ } else if (make_backups && (backup_dir_dels || !is_backup_file(fbuf))) {
+- } else if (make_backups > 0 && (backup_dir || !is_backup_file(fbuf))) {
++ } else if (make_backups > 0 && (backup_dir_dels || !is_backup_file(fbuf))) {
what = "make_backup";
- ok = make_backup(fbuf);
+ ok = safe_delete(fbuf);
ok = robust_unlink(fbuf) == 0;
--- old/options.c
+++ new/options.c
-@@ -138,10 +138,14 @@ int no_detach
+@@ -137,10 +137,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];
-@@ -153,7 +157,9 @@ char *stdout_format = NULL;
+@@ -152,7 +156,9 @@ char *stdout_format = NULL;
char *password_file = NULL;
char *rsync_path = RSYNC_PATH;
char *backup_dir = NULL;
{"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 },
-@@ -1235,6 +1245,8 @@ int parse_arguments(int *argc, const cha
+@@ -1242,6 +1252,8 @@ int parse_arguments(int *argc, const cha
tmpdir = sanitize_path(NULL, tmpdir, NULL, 0, NULL);
if (backup_dir)
backup_dir = sanitize_path(NULL, backup_dir, NULL, 0, NULL);
}
if (server_filter_list.head && !am_sender) {
struct filter_list_struct *elp = &server_filter_list;
-@@ -1252,6 +1264,14 @@ int parse_arguments(int *argc, const cha
+@@ -1259,6 +1271,14 @@ int parse_arguments(int *argc, const cha
if (check_filter(elp, backup_dir, 1) < 0)
goto options_rejected;
}
}
if (!backup_suffix)
-@@ -1263,6 +1283,16 @@ int parse_arguments(int *argc, const cha
+@@ -1270,6 +1290,16 @@ int parse_arguments(int *argc, const cha
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;
-@@ -1286,6 +1316,31 @@ int parse_arguments(int *argc, const cha
+@@ -1293,6 +1323,31 @@ int parse_arguments(int *argc, const cha
"P *%s", backup_suffix);
parse_rule(&filter_list, backup_dir_buf, 0, 0);
}
if (make_backups && !backup_dir)
omit_dir_times = 1;
-@@ -1650,6 +1705,10 @@ void server_options(char **args,int *arg
+@@ -1660,6 +1715,10 @@ void server_options(char **args,int *arg
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) {
-@@ -1658,7 +1717,13 @@ void server_options(char **args,int *arg
+@@ -1668,7 +1727,13 @@ void server_options(char **args,int *arg
goto oom;
args[ac++] = arg;
}
+ args[ac++] = arg;
+ }
if (am_sender) {
- if (delete_excluded)
- args[ac++] = "--delete-excluded";
+ if (delete_before)
+ args[ac++] = "--delete-before";
--- old/flist.c
+++ new/flist.c
-@@ -55,6 +55,7 @@ extern int non_perishable_cnt;
+@@ -56,6 +56,7 @@ extern int non_perishable_cnt;
extern int prune_empty_dirs;
extern int copy_links;
extern int copy_unsafe_links;
extern int protocol_version;
extern int sanitize_paths;
extern struct stats stats;
-@@ -80,6 +81,8 @@ static int64 tmp_dev, tmp_ino;
+@@ -86,6 +87,8 @@ static int64 tmp_dev, tmp_ino;
#endif
static char tmp_sum[MD4_SUM_LENGTH];
static char empty_sum[MD4_SUM_LENGTH];
static int flist_count_offset; /* for --delete --progress */
-@@ -262,6 +265,45 @@ static mode_t from_wire_mode(int mode)
+@@ -268,6 +271,45 @@ static mode_t from_wire_mode(int mode)
return mode;
}
+ return u_strcmp(f1->dirname, f2->dirname);
+}
+
- static void send_directory(int f, struct file_list *flist,
- char *fbuf, int len);
+ static void send_directory(int f, struct file_list *flist, int ndx,
+ char *fbuf, int len, int flags);
-@@ -1501,6 +1543,25 @@ struct file_list *recv_file_list(int f)
+@@ -1702,6 +1744,25 @@ struct file_list *recv_file_list(int f)
clean_flist(flist, relative_paths, 1);
+ memcpy(the_fattr_list.files, flist->files,
+ j * sizeof (struct file_struct *));
+ qsort(the_fattr_list.files, j,
-+ sizeof the_fattr_list.files[0], (int (*)())fattr_compare);
++ sizeof the_fattr_list.files[0], (int (*)())fattr_compare);
+ the_fattr_list.low = 0;
+ while (j-- > 0) {
+ struct file_struct *fp = the_fattr_list.files[j];
+ the_fattr_list.high = j;
+ }
+
- if (f >= 0) {
- recv_uid_list(f, flist);
-
+ if (incremental) {
+ qsort(dir_flist->files + dstart, dir_flist->count - dstart,
+ sizeof dir_flist->files[0], (int (*)())file_compare);
--- old/generator.c
+++ new/generator.c
-@@ -76,6 +76,7 @@ extern char *basis_dir[];
+@@ -79,6 +79,7 @@ extern char *basis_dir[];
extern int compare_dest;
extern int copy_dest;
extern int link_dest;
extern int whole_file;
extern int list_only;
extern int new_root_dir;
-@@ -91,6 +92,7 @@ extern char *backup_dir;
- extern char *backup_suffix;
+@@ -95,6 +96,7 @@ extern char *backup_suffix;
extern int backup_suffix_len;
- extern struct file_list *the_file_list;
-+extern struct file_list the_fattr_list;
+ extern struct file_list *cur_flist, *first_flist, *dir_flist;
extern struct filter_list_struct server_filter_list;
++extern struct file_list the_fattr_list;
int ignore_perishable = 0;
-@@ -98,12 +100,14 @@ int non_perishable_cnt = 0;
- int maybe_ATTRS_REPORT = 0;
+ int non_perishable_cnt = 0;
+@@ -102,12 +104,14 @@ int maybe_ATTRS_REPORT = 0;
+ static dev_t dev_zero;
static int deletion_count = 0; /* used to implement --max-delete */
+static int unexplored_dirs = 1;
static int deldelay_size = 0, deldelay_cnt = 0;
#define DEL_RECURSE (1<<1) /* recurse */
#define DEL_DIR_IS_EMPTY (1<<2) /* internal delete_FUNCTIONS use only */
-@@ -125,11 +129,120 @@ static int is_backup_file(char *fn)
+@@ -129,11 +133,120 @@ static int is_backup_file(char *fn)
return k > 0 && strcmp(fn+k, backup_suffix) == 0;
}
*/
static enum delret delete_item(char *fbuf, int mode, char *replace, int flags)
{
-@@ -151,6 +264,8 @@ static enum delret delete_item(char *fbu
+@@ -155,6 +268,8 @@ static enum delret delete_item(char *fbu
goto check_ret;
/* OK: try to delete the directory. */
}
if (!replace && max_delete >= 0 && ++deletion_count > max_delete)
return DR_AT_LIMIT;
-@@ -197,6 +312,8 @@ static enum delret delete_item(char *fbu
+@@ -201,6 +316,8 @@ static enum delret delete_item(char *fbu
* its contents, otherwise just checks for content. Returns DR_SUCCESS or
* DR_NOT_EMPTY. Note that fname must point to a MAXPATHLEN buffer! (The
* buffer is used for recursion, but returned unchanged.)
*/
static enum delret delete_dir_contents(char *fname, int flags)
{
-@@ -216,7 +333,9 @@ static enum delret delete_dir_contents(c
+@@ -220,7 +337,9 @@ static enum delret delete_dir_contents(c
save_filters = push_local_filters(fname, dlen);
non_perishable_cnt = 0;
ret = non_perishable_cnt ? DR_NOT_EMPTY : DR_SUCCESS;
if (!dirlist->count)
-@@ -253,6 +372,8 @@ static enum delret delete_dir_contents(c
+@@ -257,6 +376,8 @@ static enum delret delete_dir_contents(c
if (S_ISDIR(fp->mode)
&& delete_dir_contents(fname, flags | DEL_RECURSE) != DR_SUCCESS)
ret = DR_NOT_EMPTY;
if (delete_item(fname, fp->mode, NULL, flags) != DR_SUCCESS)
ret = DR_NOT_EMPTY;
}
-@@ -405,15 +526,19 @@ static void do_delayed_deletions(char *d
+@@ -409,13 +530,17 @@ static void do_delayed_deletions(char *d
* all the --delete-WHEN options. Note that the fbuf pointer must point to a
* MAXPATHLEN buffer with the name of the directory in it (the functions we
* call will append names onto the end, but the old dir value will be restored
+ * Note: --detect-rename may use this routine with DEL_NO_DELETIONS set!
+ */
static void delete_in_dir(struct file_list *flist, char *fbuf,
-- struct file_struct *file, STRUCT_STAT *stp)
-+ struct file_struct *file, STRUCT_STAT *stp, int flags)
+- struct file_struct *file, dev_t *fs_dev)
++ struct file_struct *file, dev_t *fs_dev, int flags)
{
- static int min_depth = MAXPATHLEN, cur_depth = -1;
- static void *filt_array[MAXPATHLEN/2+1];
static int already_warned = 0;
struct file_list *dirlist;
- char delbuf[MAXPATHLEN];
int dlen, i;
if (!flist) {
-@@ -427,6 +552,8 @@ static void delete_in_dir(struct file_li
+@@ -426,21 +551,28 @@ static void delete_in_dir(struct file_li
if (verbose > 2)
rprintf(FINFO, "delete_in_dir(%s)\n", fbuf);
if (allowed_lull)
maybe_send_keepalive();
-@@ -434,12 +561,14 @@ static void delete_in_dir(struct file_li
- return; /* Impossible... */
-
if (io_error && !ignore_errors) {
- if (already_warned)
+ if (!already_warned) {
+ flags |= DEL_NO_DELETIONS;
}
- while (cur_depth >= F_DEPTH(file) && cur_depth >= min_depth)
-@@ -450,6 +579,9 @@ static void delete_in_dir(struct file_li
dlen = strlen(fbuf);
- filt_array[cur_depth] = push_local_filters(fbuf, dlen);
+ change_local_filter_dir(fbuf, dlen, F_DEPTH(file));
+ if (detect_renamed)
+ unexplored_dirs--;
+
if (one_file_system) {
if (file->flags & FLAG_TOP_DIR)
- filesystem_dev = stp->st_dev;
-@@ -459,6 +591,11 @@ static void delete_in_dir(struct file_li
+ filesystem_dev = *fs_dev;
+@@ -450,6 +582,11 @@ static void delete_in_dir(struct file_li
dirlist = get_dirlist(fbuf, dlen, 0);
/* If an item in dirlist is not found in flist, delete it
* from the filesystem. */
for (i = dirlist->count; i--; ) {
-@@ -471,16 +608,23 @@ static void delete_in_dir(struct file_li
+@@ -462,16 +599,23 @@ static void delete_in_dir(struct file_li
f_name(fp, NULL));
continue;
}
flist_free(dirlist);
}
-@@ -510,9 +654,9 @@ static void do_delete_pass(struct file_l
+@@ -501,9 +645,9 @@ static void do_delete_pass(struct file_l
|| !S_ISDIR(st.st_mode))
continue;
-- delete_in_dir(flist, fbuf, file, &st);
-+ delete_in_dir(flist, fbuf, file, &st, 0);
+- delete_in_dir(flist, fbuf, file, &st.st_dev);
++ delete_in_dir(flist, fbuf, file, &st.st_dev, 0);
}
-- delete_in_dir(NULL, NULL, NULL, NULL);
-+ delete_in_dir(NULL, NULL, NULL, NULL, 0);
+- delete_in_dir(NULL, NULL, NULL, &dev_zero);
++ delete_in_dir(NULL, NULL, NULL, &dev_zero, 0);
if (do_progress && !am_server)
rprintf(FINFO, " \r");
-@@ -1047,6 +1191,7 @@ static int try_dests_non(struct file_str
+@@ -1038,6 +1182,7 @@ static int try_dests_non(struct file_str
return j;
}
+static struct bitbag *delayed_bits = NULL;
static int phase = 0;
- /* Acts on the_file_list->file's ndx'th item, whose name is fname. If a dir,
-@@ -1232,8 +1377,12 @@ static void recv_generator(char *fname,
- if (real_ret != 0 && one_file_system)
- real_st.st_dev = filesystem_dev;
- if (delete_during && f_out != -1 && !phase && dry_run < 2
+ /* Acts on cur_flist->file's ndx'th item, whose name is fname. If a dir,
+@@ -1229,8 +1374,12 @@ static void recv_generator(char *fname,
+ }
+ }
+ else if (delete_during && f_out != -1 && !phase && dry_run < 2
- && (file->flags & FLAG_XFER_DIR))
-- delete_in_dir(the_file_list, fname, file, &real_st);
+- delete_in_dir(cur_flist, fname, file, &real_st.st_dev);
+ && (file->flags & FLAG_XFER_DIR)) {
+ if (detect_renamed && real_ret != 0)
+ unexplored_dirs++;
-+ delete_in_dir(the_file_list, fname, file, &real_st,
++ delete_in_dir(cur_flist, fname, file, &real_st.st_dev,
+ delete_during < 0 ? DEL_NO_DELETIONS : 0);
+ }
return;
}
-@@ -1497,8 +1646,14 @@ static void recv_generator(char *fname,
+@@ -1494,8 +1643,14 @@ static void recv_generator(char *fname,
if (preserve_hard_links && F_HLINK_NOT_LAST(file))
return;
#endif
rsyserr(FERROR, stat_errno, "recv_generator: failed to stat %s",
full_fname(fname));
return;
-@@ -1688,6 +1843,12 @@ void generate_files(int f_out, struct fi
- (long)getpid(), flist->count);
- }
+@@ -1683,6 +1838,12 @@ void generate_files(int f_out, char *loc
+ if (verbose > 2)
+ rprintf(FINFO, "generator starting pid=%ld\n", (long)getpid());
+ if (detect_renamed) {
+ delayed_bits = bitbag_create(flist->count);
+ delete_during = -1;
+ }
+
- if (delete_before && !local_name && flist->count > 0)
- do_delete_pass(flist);
+ if (delete_before && !local_name && cur_flist->count > 0)
+ do_delete_pass(cur_flist);
if (delete_during == 2) {
-@@ -1698,7 +1859,7 @@ void generate_files(int f_out, struct fi
+@@ -1693,7 +1854,7 @@ void generate_files(int f_out, char *loc
}
do_progress = 0;
-- if (append_mode || whole_file < 0)
-+ if (append_mode || detect_renamed || whole_file < 0)
+- if (append_mode > 0 || whole_file < 0)
++ if (append_mode > 0 || detect_renamed || whole_file < 0)
whole_file = 0;
if (verbose >= 2) {
rprintf(FINFO, "delta-transmission %s\n",
-@@ -1754,7 +1915,22 @@ void generate_files(int f_out, struct fi
- }
- recv_generator(NULL, NULL, 0, 0, code, -1);
- if (delete_during)
-- delete_in_dir(NULL, NULL, NULL, NULL);
-+ delete_in_dir(NULL, NULL, NULL, NULL, 0);
-+
-+ if (detect_renamed) {
-+ if (delete_during < 0)
-+ delete_during = 0;
-+ detect_renamed = 0;
+@@ -1718,7 +1879,7 @@ void generate_files(int f_out, char *loc
+ dirdev = MAKEDEV(DEV_MAJOR(devp), DEV_MINOR(devp));
+ } else
+ dirdev = MAKEDEV(0, 0);
+- delete_in_dir(cur_flist, f_name(fp, fbuf), fp, &dirdev);
++ delete_in_dir(cur_flist, f_name(fp, fbuf), fp, &dirdev, 0);
+ }
+ }
+ for (i = cur_flist->low; i <= cur_flist->high; i++) {
+@@ -1764,7 +1925,21 @@ void generate_files(int f_out, char *loc
+
+ if (!incremental) {
+ if (delete_during)
+- delete_in_dir(NULL, NULL, NULL, &dev_zero);
++ delete_in_dir(NULL, NULL, NULL, &dev_zero, 0);
++ if (detect_renamed) {
++ if (delete_during < 0)
++ delete_during = 0;
++ detect_renamed = 0;
+
-+ for (i = -1; (i = bitbag_next_bit(delayed_bits, i)) >= 0; ) {
-+ struct file_struct *file = flist->files[i];
-+ if (local_name)
-+ strlcpy(fbuf, local_name, sizeof fbuf);
-+ else
-+ f_name(file, fbuf);
-+ recv_generator(fbuf, file, i, itemizing, code, f_out);
-+ }
-+ }
-
- phase++;
- csum_length = SUM_LENGTH;
++ for (i = -1; (i = bitbag_next_bit(delayed_bits, i)) >= 0; ) {
++ struct file_struct *file = flist->files[i];
++ if (local_name)
++ strlcpy(fbuf, local_name, sizeof fbuf);
++ else
++ f_name(file, fbuf);
++ recv_generator(fbuf, file, i, itemizing, code, f_out);
++ }
++ }
+ phase++;
+ if (verbose > 2) {
+ rprintf(FINFO, "generate_files phase=%d\n",
--- old/options.c
+++ new/options.c
@@ -78,6 +78,7 @@ int am_generator = 0;
int numeric_ids = 0;
int allow_8bit_chars = 0;
int force_delete = 0;
-@@ -342,6 +343,7 @@ void usage(enum logcode F)
+@@ -343,6 +344,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");
-@@ -496,6 +498,7 @@ static struct poptOption long_options[]
+@@ -497,6 +499,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 },
{"compress-level", 0, POPT_ARG_INT, &def_compress_level, 'z', 0, 0 },
-@@ -1355,7 +1358,7 @@ int parse_arguments(int *argc, const cha
+@@ -1368,7 +1371,7 @@ int parse_arguments(int *argc, const cha
inplace = 1;
}
partial_dir = tmp_partialdir;
if (inplace) {
-@@ -1364,6 +1367,7 @@ int parse_arguments(int *argc, const cha
+@@ -1377,6 +1380,7 @@ int parse_arguments(int *argc, const cha
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;
}
-@@ -1674,6 +1678,8 @@ void server_options(char **args,int *arg
+@@ -1690,6 +1694,8 @@ void server_options(char **args,int *arg
args[ac++] = "--super";
if (size_only)
args[ac++] = "--size-only";
--- old/generator.c
+++ new/generator.c
-@@ -53,6 +53,7 @@ extern int ignore_errors;
+@@ -54,6 +54,7 @@ extern int ignore_errors;
extern int remove_source_files;
extern int delay_updates;
extern int update_only;
extern int ignore_existing;
extern int ignore_non_existing;
extern int inplace;
-@@ -1144,6 +1145,13 @@ static void recv_generator(char *fname,
+@@ -1437,6 +1438,13 @@ static void recv_generator(char *fname,
return;
}
fnamecmp = fname;
fnamecmp_type = FNAMECMP_FNAME;
-@@ -1452,7 +1460,7 @@ void generate_files(int f_out, struct fi
- phase++;
- csum_length = SUM_LENGTH;
- max_size = min_size = ignore_existing = ignore_non_existing = 0;
-- update_only = always_checksum = size_only = 0;
-+ downdate_only = update_only = always_checksum = size_only = 0;
- ignore_times = 1;
- if (append_mode) /* resend w/o append mode */
- append_mode = -1; /* ... but only longer files */
+@@ -1780,6 +1788,7 @@ void generate_files(int f_out, char *loc
+ ignore_existing = -ignore_existing;
+ ignore_non_existing = -ignore_non_existing;
+ update_only = -update_only;
++ downdate_only = -downdate_only;
+ always_checksum = -always_checksum;
+ size_only = -size_only;
+ append_mode = -append_mode;
+@@ -1819,6 +1828,7 @@ void generate_files(int f_out, char *loc
+ ignore_existing = -ignore_existing;
+ ignore_non_existing = -ignore_non_existing;
+ update_only = -update_only;
++ downdate_only = -downdate_only;
+ always_checksum = -always_checksum;
+ size_only = -size_only;
+ append_mode = -append_mode;
--- old/options.c
+++ new/options.c
@@ -56,6 +56,7 @@ int preserve_gid = 0;
int cvs_exclude = 0;
int dry_run = 0;
int do_xfers = 1;
-@@ -293,6 +294,7 @@ void usage(enum logcode F)
+@@ -289,6 +290,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," -d, --dirs transfer directories without recursing\n");
-@@ -465,6 +467,7 @@ static struct poptOption long_options[]
+@@ -462,6 +464,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 },
--- old/flist.c
+++ new/flist.c
-@@ -31,6 +31,7 @@ extern int am_daemon;
- extern int am_sender;
+@@ -33,6 +33,7 @@ extern int am_sender;
+ extern int incremental;
extern int do_progress;
extern int always_checksum;
+extern int pre_checksum;
extern int module_id;
extern int ignore_errors;
extern int numeric_ids;
-@@ -785,6 +786,15 @@ static struct file_struct *recv_file_ent
+@@ -847,6 +848,15 @@ static struct file_struct *recv_file_ent
memcpy(bp, F_SUM(first), checksum_len);
} else
read_buf(f, bp, checksum_len);
return file;
--- old/generator.c
+++ new/generator.c
-@@ -70,6 +70,7 @@ extern int ignore_timeout;
- extern int protocol_version;
+@@ -73,6 +73,7 @@ extern int protocol_version;
+ extern int file_total;
extern int fuzzy_basis;
extern int always_checksum;
+extern int pre_checksum;
extern int checksum_len;
extern char *partial_dir;
extern char *basis_dir[];
-@@ -577,7 +578,8 @@ void itemize(struct file_struct *file, i
+@@ -569,7 +570,8 @@ void itemize(struct file_struct *file, i
/* Perform our quick-check heuristic for determining if a file is unchanged. */
{
if (st->st_size != F_LENGTH(file))
return 0;
-@@ -586,6 +588,8 @@ int unchanged_file(char *fn, struct file
+@@ -578,6 +580,8 @@ int unchanged_file(char *fn, struct file
of the file time to determine whether to sync */
- if (always_checksum && S_ISREG(st->st_mode)) {
+ if (always_checksum > 0 && S_ISREG(st->st_mode)) {
char sum[MD4_SUM_LENGTH];
+ if (pre_checksum && fnamecmp_type == FNAMECMP_FNAME)
+ return !(file->flags & FLAG_SUM_DIFFERS);
file_checksum(fn, sum, st->st_size);
return memcmp(sum, F_SUM(file), checksum_len) == 0;
}
-@@ -825,7 +829,7 @@ static int try_dests_reg(struct file_str
+@@ -816,7 +820,7 @@ static int try_dests_reg(struct file_str
match_level = 1;
/* FALL THROUGH */
case 1:
continue;
best_match = j;
match_level = 2;
-@@ -1511,7 +1515,7 @@ static void recv_generator(char *fname,
+@@ -1508,7 +1512,7 @@ static void recv_generator(char *fname,
;
else if (fnamecmp_type == FNAMECMP_FUZZY)
;
handle_partial_dir(partialptr, PDIR_DELETE);
--- old/hlink.c
+++ new/hlink.c
-@@ -448,7 +448,7 @@ int hard_link_check(struct file_struct *
+@@ -382,7 +382,7 @@ int hard_link_check(struct file_struct *
}
break;
}
*stp = alt_st;
--- old/main.c
+++ new/main.c
-@@ -47,6 +47,7 @@ extern int copy_dirlinks;
+@@ -46,6 +46,7 @@ extern int module_id;
+ extern int copy_links;
+ extern int copy_dirlinks;
extern int keep_dirlinks;
++extern int always_checksum;
extern int preserve_hard_links;
extern int protocol_version;
-+extern int always_checksum;
- extern int recurse;
- extern int relative_paths;
- extern int sanitize_paths;
-@@ -71,6 +72,9 @@ extern char *batch_name;
+ extern int file_total;
+@@ -73,6 +74,9 @@ extern char *password_file;
extern char curr_dir[MAXPATHLEN];
extern struct filter_list_struct server_filter_list;
int local_server = 0;
int new_root_dir = 0;
mode_t orig_umask = 0;
-@@ -788,6 +792,7 @@ static void do_server_recv(int f_in, int
+@@ -792,6 +796,7 @@ static void do_server_recv(int f_in, int
struct file_list *flist;
char *local_name = NULL;
char *dir = NULL;
int save_verbose = verbose;
if (filesfrom_fd >= 0) {
-@@ -831,6 +836,10 @@ static void do_server_recv(int f_in, int
+@@ -838,6 +843,10 @@ static void do_server_recv(int f_in, int
filesfrom_fd = -1;
}
+ pre_checksum = push_dir(argv[0], 0);
+
flist = recv_file_list(f_in);
- verbose = save_verbose;
if (!flist) {
-@@ -839,6 +848,9 @@ static void do_server_recv(int f_in, int
- }
- the_file_list = flist;
+ rprintf(FERROR,"server_recv: recv_file_list error\n");
+@@ -847,6 +856,9 @@ static void do_server_recv(int f_in, int
+ recv_additional_file_list(f_in);
+ verbose = save_verbose;
+ if (pre_checksum)
+ pop_dir(olddir);
if (argc > 0)
local_name = get_local_name(flist,argv[0]);
-@@ -918,6 +930,7 @@ int client_run(int f_in, int f_out, pid_
+@@ -926,6 +938,7 @@ int client_run(int f_in, int f_out, pid_
{
struct file_list *flist = NULL;
int exit_code = 0, exit_code2 = 0;
char *local_name = NULL;
cleanup_child_pid = pid;
-@@ -992,11 +1005,18 @@ int client_run(int f_in, int f_out, pid_
+@@ -1006,12 +1019,19 @@ int client_run(int f_in, int f_out, pid_
filesfrom_fd = -1;
}
if (write_batch && !am_server)
start_write_batch(f_in);
flist = recv_file_list(f_in);
- the_file_list = flist;
+ if (incremental && file_total == 1)
+ recv_additional_file_list(f_in);
+ if (pre_checksum)
+ pop_dir(olddir);
--- old/rsync.h
+++ new/rsync.h
-@@ -68,6 +68,7 @@
+@@ -71,6 +71,7 @@
#define FLAG_HLINK_LAST (1<<7) /* receiver/generator */
#define FLAG_HLINK_DONE (1<<8) /* receiver/generator */
#define FLAG_LENGTH64 (1<<9) /* sender/receiver/generator */
+#define FLAG_SUM_DIFFERS (1<<10)/* receiver/generator */
- #define BITS_SET(val,bits) (((val) & (bits)) == (bits))
- #define BITS_SETnUNSET(val,onbits,offbits) (((val) & ((onbits)|(offbits))) == (onbits))
+ /* These flags are passed to functions but not stored. */
+
--- old/flist.c
+++ new/flist.c
-@@ -193,7 +193,7 @@ static int readlink_stat(const char *pat
+@@ -194,12 +194,12 @@ static int readlink_stat(const char *pat
+ rprintf(FINFO,"copying unsafe symlink \"%s\" -> \"%s\"\n",
+ path, linkbuf);
+ }
+- return do_stat(path, stp);
++ return x_stat(path, stp, NULL);
+ }
}
return 0;
#else
#endif
}
-@@ -201,17 +201,17 @@ int link_stat(const char *path, STRUCT_S
+@@ -207,17 +207,17 @@ int link_stat(const char *path, STRUCT_S
{
#ifdef SUPPORT_LINKS
if (copy_links)
#endif
}
-@@ -246,26 +246,6 @@ static int is_excluded(char *fname, int
+@@ -252,26 +252,6 @@ static int is_excluded(char *fname, int
return 0;
}
- return mode;
-}
-
- static void send_directory(int f, struct file_list *flist,
- char *fbuf, int len);
+ static void send_directory(int f, struct file_list *flist, int ndx,
+ char *fbuf, int len, int flags);
-@@ -877,7 +857,7 @@ struct file_struct *make_file(const char
+@@ -925,7 +905,7 @@ struct file_struct *make_file(const char
if (save_errno == ENOENT) {
#ifdef SUPPORT_LINKS
/* Avoid "vanished" error if symlink points nowhere. */
&& S_ISLNK(st.st_mode)) {
io_error |= IOERR_GENERAL;
rprintf(FERROR, "symlink has no referent: %s\n",
-@@ -1050,7 +1030,7 @@ struct file_struct *make_file(const char
+@@ -1097,7 +1077,7 @@ struct file_struct *make_file(const char
int save_mode = file->mode;
file->mode = S_IFDIR; /* Find a directory with our name. */
- if (flist_find(the_file_list, file) >= 0
+ if (flist_find(dir_flist, file) >= 0
- && do_stat(thisname, &st2) == 0 && S_ISDIR(st2.st_mode)) {
+ && x_stat(thisname, &st2, NULL) == 0 && S_ISDIR(st2.st_mode)) {
file->modtime = st2.st_mtime;
int am_server = 0;
int am_sender = 0;
int am_generator = 0;
-@@ -325,6 +325,9 @@ void usage(enum logcode F)
+@@ -326,6 +326,9 @@ void usage(enum logcode F)
rprintf(F," -t, --times preserve times\n");
rprintf(F," -O, --omit-dir-times omit directories when preserving times\n");
rprintf(F," --super receiver attempts super-user activities\n");
rprintf(F," -S, --sparse handle sparse files efficiently\n");
rprintf(F," -n, --dry-run show what would have been transferred\n");
rprintf(F," -W, --whole-file copy files whole (without rsync algorithm)\n");
-@@ -450,6 +453,7 @@ static struct poptOption long_options[]
+@@ -451,6 +454,7 @@ static struct poptOption long_options[]
{"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 },
{"owner", 'o', POPT_ARG_VAL, &preserve_uid, 1, 0, 0 },
{"no-owner", 0, POPT_ARG_VAL, &preserve_uid, 0, 0, 0 },
{"no-o", 0, POPT_ARG_VAL, &preserve_uid, 0, 0, 0 },
-@@ -1176,6 +1180,14 @@ int parse_arguments(int *argc, const cha
+@@ -1183,6 +1187,14 @@ int parse_arguments(int *argc, const cha
}
#endif
"--write-batch and --read-batch can not be used together\n");
--- old/rsync.c
+++ new/rsync.c
-@@ -249,7 +249,9 @@ int set_file_attrs(char *fname, struct f
+@@ -299,7 +299,9 @@ int set_file_attrs(char *fname, struct f
(long)sxp->st.st_gid, (long)F_GID(file));
}
}
change_uid ? F_UID(file) : sxp->st.st_uid,
change_gid ? F_GID(file) : sxp->st.st_gid) != 0) {
/* shouldn't have attempted to change uid or gid
-@@ -258,7 +260,7 @@ int set_file_attrs(char *fname, struct f
+@@ -308,7 +310,7 @@ int set_file_attrs(char *fname, struct f
change_uid ? "chown" : "chgrp",
full_fname(fname));
goto cleanup;
/* a lchown had been done - we have to re-stat if the
* destination had the setuid or setgid bits set due
* to the side effect of the chown call */
-@@ -275,6 +277,8 @@ int set_file_attrs(char *fname, struct f
+@@ -325,6 +327,8 @@ int set_file_attrs(char *fname, struct f
#ifdef SUPPORT_XATTRS
if (preserve_xattrs && set_xattr(fname, file, sxp) == 0)
updated = 1;
#endif
#ifdef SUPPORT_ACLS
/* It's OK to call set_acl() now, even for a dir, as the generator
-@@ -289,7 +293,7 @@ int set_file_attrs(char *fname, struct f
+@@ -339,7 +343,7 @@ int set_file_attrs(char *fname, struct f
#ifdef HAVE_CHMOD
if (!BITS_EQUAL(sxp->st.st_mode, new_mode, CHMOD_BITS)) {
"failed to set permissions on %s",
--- old/rsync.h
+++ new/rsync.h
-@@ -783,6 +783,12 @@ typedef struct {
+@@ -813,6 +813,12 @@ typedef struct {
#include "proto.h"
/* We have replacement versions of these if they're missing. */
#ifndef HAVE_ASPRINTF
int asprintf(char **ptr, const char *format, ...);
-@@ -1001,6 +1007,26 @@ int inet_pton(int af, const char *src, v
+@@ -1031,6 +1037,26 @@ int inet_pton(int af, const char *src, v
const char *get_panic_action(void);
#endif
--- old/compat.c
+++ new/compat.c
-@@ -50,6 +50,8 @@ void setup_protocol(int f_out,int f_in)
+@@ -56,6 +56,8 @@ void setup_protocol(int f_out,int f_in)
preserve_uid = ++file_extra_cnt;
if (preserve_gid)
preserve_gid = ++file_extra_cnt;
AC_CHECK_FUNCS(getpgrp tcgetpgrp)
--- old/flist.c
+++ new/flist.c
-@@ -45,6 +45,7 @@ extern int preserve_links;
+@@ -46,6 +46,7 @@ extern int preserve_links;
extern int preserve_hard_links;
extern int preserve_devices;
extern int preserve_specials;
extern int preserve_uid;
extern int preserve_gid;
extern int relative_paths;
-@@ -314,6 +315,9 @@ static void send_file_entry(struct file_
+@@ -347,6 +348,9 @@ static void send_file_entry(int f, struc
{
static time_t modtime;
static mode_t mode;
static int64 dev;
static dev_t rdev;
static uint32 rdev_major;
-@@ -333,6 +337,12 @@ static void send_file_entry(struct file_
+@@ -367,6 +371,12 @@ static void send_file_entry(int f, struc
flags |= XMIT_SAME_MODE;
else
mode = file->mode;
if ((preserve_devices && IS_DEVICE(mode))
|| (preserve_specials && IS_SPECIAL(mode))) {
if (protocol_version < 28) {
-@@ -434,6 +444,10 @@ static void send_file_entry(struct file_
+@@ -480,6 +490,10 @@ static void send_file_entry(int f, struc
write_int(f, modtime);
if (!(flags & XMIT_SAME_MODE))
write_int(f, to_wire_mode(mode));
+ write_int(f, (int)fileflags);
+#endif
if (preserve_uid && !(flags & XMIT_SAME_UID)) {
- if (!numeric_ids)
- add_uid(uid);
-@@ -503,6 +517,9 @@ static struct file_struct *recv_file_ent
+ write_int(f, uid);
+ if (flags & XMIT_USER_NAME_FOLLOWS) {
+@@ -555,6 +569,9 @@ static struct file_struct *recv_file_ent
{
static time_t modtime;
static mode_t mode;
static int64 dev;
static dev_t rdev;
static uint32 rdev_major;
-@@ -610,9 +627,12 @@ static struct file_struct *recv_file_ent
+@@ -650,9 +667,12 @@ static struct file_struct *recv_file_ent
modtime = (time_t)read_int(f);
if (!(flags & XMIT_SAME_MODE))
mode = from_wire_mode(read_int(f));
+ fileflags = (uint32)read_int(f);
+#endif
- if (preserve_uid && !(flags & XMIT_SAME_UID))
+ if (preserve_uid && !(flags & XMIT_SAME_UID)) {
uid = (uid_t)read_int(f);
-@@ -696,6 +716,10 @@ static struct file_struct *recv_file_ent
+@@ -754,6 +774,10 @@ static struct file_struct *recv_file_ent
OPT_EXTRA(file, 0)->unum = (uint32)(file_length >> 32);
}
file->mode = mode;
+ F_FFLAGS(file) = fileflags;
+#endif
if (preserve_uid)
- F_UID(file) = uid;
+ F_OWNER(file) = uid;
if (preserve_gid)
-@@ -998,6 +1022,10 @@ struct file_struct *make_file(const char
+@@ -1051,6 +1075,10 @@ struct file_struct *make_file(const char
OPT_EXTRA(file, 0)->unum = (uint32)(st.st_size >> 32);
}
file->mode = st.st_mode;
+ F_FFLAGS(file) = st.st_flags;
+#endif
if (preserve_uid)
- F_UID(file) = st.st_uid;
+ F_OWNER(file) = st.st_uid;
if (preserve_gid)
--- old/generator.c
+++ new/generator.c
-@@ -103,6 +103,12 @@ static char *deldelay_buf = NULL;
+@@ -107,6 +107,12 @@ static char *deldelay_buf = NULL;
static int deldelay_fd = -1;
static BOOL solo_file = 0;
/* For calling delete_item() and delete_dir_contents(). */
#define DEL_RECURSE (1<<1) /* recurse */
#define DEL_DIR_IS_EMPTY (1<<2) /* internal delete_FUNCTIONS use only */
-@@ -118,7 +124,6 @@ enum delret {
+@@ -122,7 +128,6 @@ enum delret {
/* Forward declaration for delete_item(). */
static enum delret delete_dir_contents(char *fname, int flags);
static int is_backup_file(char *fn)
{
int k = strlen(fn) - backup_suffix_len;
-@@ -131,17 +136,20 @@ static int is_backup_file(char *fn)
+@@ -135,17 +140,20 @@ static int is_backup_file(char *fn)
* Note that fbuf must point to a MAXPATHLEN buffer if the mode indicates it's
* a directory! (The buffer is used for recursion, but returned unchanged.)
*/
if (S_ISDIR(mode) && !(flags & DEL_DIR_IS_EMPTY)) {
ignore_perishable = 1;
/* If DEL_RECURSE is not set, this just reports emptiness. */
-@@ -253,7 +261,7 @@ static enum delret delete_dir_contents(c
+@@ -257,7 +265,7 @@ static enum delret delete_dir_contents(c
if (S_ISDIR(fp->mode)
&& delete_dir_contents(fname, flags | DEL_RECURSE) != DR_SUCCESS)
ret = DR_NOT_EMPTY;
ret = DR_NOT_EMPTY;
}
-@@ -309,8 +317,9 @@ static int remember_delete(struct file_s
+@@ -313,8 +321,9 @@ static int remember_delete(struct file_s
while (1) {
len = snprintf(deldelay_buf + deldelay_cnt,
if ((deldelay_cnt += len) <= deldelay_size)
break;
if (deldelay_fd < 0 && !start_delete_delay_temp())
-@@ -323,7 +332,7 @@ static int remember_delete(struct file_s
+@@ -327,7 +336,7 @@ static int remember_delete(struct file_s
return 1;
}
{
static int read_pos = 0;
int j, len, mode;
-@@ -365,7 +374,7 @@ static int read_delay_line(char *buf)
+@@ -369,7 +378,7 @@ static int read_delay_line(char *buf)
bp = deldelay_buf + read_pos;
invalid_data:
rprintf(FERROR, "ERROR: invalid data in delete-delay file.\n");
return -1;
-@@ -388,15 +397,15 @@ static int read_delay_line(char *buf)
+@@ -392,15 +401,15 @@ static int read_delay_line(char *buf)
static void do_delayed_deletions(char *delbuf)
{
if (deldelay_fd >= 0)
close(deldelay_fd);
}
-@@ -477,7 +486,7 @@ static void delete_in_dir(struct file_li
+@@ -468,7 +477,7 @@ static void delete_in_dir(struct file_li
if (!remember_delete(fp, delbuf))
break;
} else
}
}
-@@ -1181,7 +1190,7 @@ static void recv_generator(char *fname,
+@@ -1174,7 +1183,7 @@ static void recv_generator(char *fname,
* we need to delete it. If it doesn't exist, then
* (perhaps recursively) create it. */
if (statret == 0 && !S_ISDIR(st.st_mode)) {
return;
statret = -1;
}
-@@ -1278,7 +1287,7 @@ static void recv_generator(char *fname,
+@@ -1275,7 +1284,7 @@ static void recv_generator(char *fname,
}
/* Not the right symlink (or not a symlink), so
* delete it. */
return;
} else if (basis_dir[0] != NULL) {
int j = try_dests_non(file, fname, ndx, fnamecmpbuf, &st,
-@@ -1355,7 +1364,7 @@ static void recv_generator(char *fname,
+@@ -1352,7 +1361,7 @@ static void recv_generator(char *fname,
goto return_with_success;
return;
}
return;
} else if (basis_dir[0] != NULL) {
int j = try_dests_non(file, fname, ndx, fnamecmpbuf, &st,
-@@ -1444,7 +1453,7 @@ static void recv_generator(char *fname,
+@@ -1441,7 +1450,7 @@ static void recv_generator(char *fname,
fnamecmp_type = FNAMECMP_FNAME;
if (statret == 0 && !S_ISREG(st.st_mode)) {
int preserve_executability = 0;
int preserve_devices = 0;
int preserve_specials = 0;
-@@ -200,6 +201,7 @@ static void print_rsync_version(enum log
+@@ -201,6 +202,7 @@ static void print_rsync_version(enum log
char const *hardlinks = "no ";
char const *links = "no ";
char const *ipv6 = "no ";
STRUCT_STAT *dumstat;
#ifdef HAVE_SOCKETPAIR
-@@ -222,6 +224,10 @@ static void print_rsync_version(enum log
+@@ -223,6 +225,10 @@ static void print_rsync_version(enum log
ipv6 = "";
#endif
rprintf(f, "%s version %s protocol version %d\n",
RSYNC_NAME, RSYNC_VERSION, PROTOCOL_VERSION);
rprintf(f, "Copyright (C) 1996-2006 by Andrew Tridgell, Wayne Davison, and others.\n");
-@@ -232,8 +238,8 @@ static void print_rsync_version(enum log
+@@ -233,8 +239,8 @@ static void print_rsync_version(enum log
(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());
-@@ -299,6 +305,7 @@ void usage(enum logcode F)
+@@ -300,6 +306,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");
rprintf(F," -o, --owner preserve owner (super-user only)\n");
-@@ -420,6 +427,8 @@ static struct poptOption long_options[]
+@@ -421,6 +428,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 },
{"times", 't', POPT_ARG_VAL, &preserve_times, 1, 0, 0 },
{"no-times", 0, POPT_ARG_VAL, &preserve_times, 0, 0, 0 },
-@@ -1125,6 +1134,15 @@ int parse_arguments(int *argc, const cha
+@@ -1132,6 +1141,15 @@ int parse_arguments(int *argc, const cha
}
#endif
if (write_batch && read_batch) {
snprintf(err_buf, sizeof err_buf,
"--write-batch and --read-batch can not be used together\n");
-@@ -1579,6 +1597,9 @@ void server_options(char **args,int *arg
+@@ -1595,6 +1613,9 @@ void server_options(char **args,int *arg
if (xfer_dirs && !recurse && delete_mode && am_sender)
args[ac++] = "--no-r";
extern int preserve_executability;
extern int preserve_times;
extern int omit_dir_times;
-@@ -176,6 +179,41 @@ mode_t dest_mode(mode_t flist_mode, mode
+@@ -226,6 +229,41 @@ mode_t dest_mode(mode_t flist_mode, mode
return new_mode;
}
int set_file_attrs(char *fname, struct file_struct *file, STRUCT_STAT *st,
int flags)
{
-@@ -274,6 +312,15 @@ int set_file_attrs(char *fname, struct f
+@@ -324,6 +362,15 @@ int set_file_attrs(char *fname, struct f
}
#endif
if (verbose > 1 && flags & ATTRS_REPORT) {
if (updated)
rprintf(FCLIENT, "%s\n", fname);
-@@ -321,6 +368,9 @@ void finish_transfer(char *fname, char *
+@@ -371,6 +418,9 @@ void finish_transfer(char *fname, char *
set_file_attrs(fnametmp, file, NULL,
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);
-@@ -335,6 +385,9 @@ void finish_transfer(char *fname, char *
+@@ -385,6 +435,9 @@ void finish_transfer(char *fname, char *
}
if (ret == 0) {
/* The file was moved into place (not copied), so it's done. */
/* The file was copied, so tweak the perms of the copied file. If it
--- old/rsync.h
+++ new/rsync.h
-@@ -55,6 +55,7 @@
- #define XMIT_SAME_DEV_pre30 (1<<10) /* protocols < 30 */
- #define XMIT_HLINK_FIRST (1<<10) /* protocols >= 30 */
+@@ -57,6 +57,7 @@
#define XMIT_RDEV_MINOR_IS_SMALL (1<<11)
-+#define XMIT_SAME_FLAGS (1<<12)
+ #define XMIT_USER_NAME_FOLLOWS (1<<12) /* protocols >= 30 */
+ #define XMIT_GROUP_NAME_FOLLOWS (1<<13) /* protocols >= 30 */
++#define XMIT_SAME_FLAGS (1<<15)
/* These flags are used in the live flist data. */
-@@ -374,6 +375,10 @@ enum msgcode {
+@@ -388,6 +389,10 @@ enum msgcode {
#endif
#endif
/* Find a variable that is either exactly 32-bits or longer.
* If some code depends on 32-bit truncation, it will need to
* take special action in a "#if SIZEOF_INT32 > 4" section. */
-@@ -551,6 +556,7 @@ struct file_struct {
+@@ -565,6 +570,7 @@ struct file_struct {
extern int file_extra_cnt;
extern int preserve_uid;
extern int preserve_gid;
#define FILE_STRUCT_LEN (offsetof(struct file_struct, basename))
#define EXTRA_LEN (sizeof (union file_extras))
-@@ -583,6 +589,7 @@ extern int preserve_gid;
+@@ -597,6 +603,7 @@ extern int preserve_gid;
/* When the associated option is on, all entries will have these present: */
- #define F_UID(f) REQ_EXTRA(f, preserve_uid)->unum
- #define F_GID(f) REQ_EXTRA(f, preserve_gid)->unum
-+#define F_FFLAGS(f) REQ_EXTRA(f, preserve_fileflags).num
+ #define F_OWNER(f) REQ_EXTRA(f, preserve_uid)->unum
+ #define F_GROUP(f) REQ_EXTRA(f, preserve_gid)->unum
++#define F_FFLAGS(f) REQ_EXTRA(f, preserve_fileflags).unum
/* These items are per-entry optional and mutally exclusive: */
#define F_HL_GNUM(f) OPT_EXTRA(f, LEN64_BUMP(f))->num
--- old/Makefile.in
+++ new/Makefile.in
-@@ -35,7 +35,7 @@ OBJS1=rsync.o generator.o receiver.o cle
- main.o checksum.o match.o syscall.o log.o backup.o
- OBJS2=options.o flist.o io.o compat.o hlink.o token.o uidlist.o socket.o \
+@@ -35,7 +35,7 @@ OBJS1=flist.o rsync.o generator.o receiv
+ util.o main.o checksum.o match.o syscall.o log.o backup.o
+ OBJS2=options.o io.o compat.o hlink.o token.o uidlist.o socket.o \
fileio.o batch.o clientname.o chmod.o
-OBJS3=progress.o pipe.o
+OBJS3=progress.o pipe.o hashlink.o
popt/popthelp.o popt/poptparse.o
--- old/flist.c
+++ new/flist.c
-@@ -57,6 +57,7 @@ extern int copy_unsafe_links;
+@@ -59,6 +59,7 @@ extern int copy_unsafe_links;
extern int protocol_version;
extern int sanitize_paths;
extern struct stats stats;
+extern char *link_by_hash_dir;
- extern struct file_list *the_file_list;
- extern alloc_pool_t hlink_pool;
-@@ -624,7 +625,7 @@ static struct file_struct *recv_file_ent
+ extern char curr_dir[MAXPATHLEN];
+
+@@ -712,7 +713,7 @@ static struct file_struct *recv_file_ent
}
#endif
+#endif
--- old/options.c
+++ new/options.c
-@@ -145,6 +145,7 @@ char *backup_suffix = NULL;
+@@ -144,6 +144,7 @@ char *backup_suffix = NULL;
char *tmpdir = NULL;
char *partial_dir = NULL;
char *basis_dir[MAX_BASIS_DIRS+1];
{"fuzzy", 'y', POPT_ARG_NONE, &fuzzy_basis, 0, 0, 0 },
{"compress", 'z', POPT_ARG_NONE, 0, 'z', 0, 0 },
{"compress-level", 0, POPT_ARG_INT, &def_compress_level, 'z', 0, 0 },
-@@ -1087,6 +1090,21 @@ int parse_arguments(int *argc, const cha
+@@ -1093,6 +1096,21 @@ int parse_arguments(int *argc, const cha
usage(FINFO);
exit_cleanup(0);
default:
/* A large opt value means that set_refuse_options()
* turned this option off. */
-@@ -1745,6 +1763,11 @@ void server_options(char **args,int *arg
+@@ -1755,6 +1773,11 @@ void server_options(char **args,int *arg
}
}
+
sum_init(checksum_seed);
- if (append_mode) {
+ if (append_mode > 0) {
@@ -191,6 +196,8 @@ static int receive_data(int f_in, char *
cleanup_got_literal = 1;
+ receive_data(f_in, NULL, -1, 0, NULL, -1, length, NULL);
}
- static void handle_delayed_updates(struct file_list *flist, char *local_name)
-@@ -604,7 +615,7 @@ int recv_files(int f_in, struct file_lis
+ static void handle_delayed_updates(char *local_name)
+@@ -621,7 +632,7 @@ int recv_files(int f_in, char *local_nam
/* recv file data */
recv_ok = receive_data(f_in, fnamecmp, fd1, st.st_size,
--- old/rsync.c
+++ new/rsync.c
-@@ -49,6 +49,7 @@ extern int inplace;
+@@ -51,6 +51,7 @@ extern int flist_eof;
extern int keep_dirlinks;
extern int make_backups;
extern mode_t orig_umask;
+extern char *link_by_hash_dir;
extern struct stats stats;
- extern struct file_list *the_file_list;
+ extern struct file_list *cur_flist, *first_flist, *dir_flist;
extern struct chmod_mode_struct *daemon_chmod_modes;
-@@ -324,8 +325,15 @@ void finish_transfer(char *fname, char *
+@@ -374,8 +375,15 @@ void finish_transfer(char *fname, char *
/* move tmp file over real file */
if (verbose > 2)
rprintf(FINFO, "renaming %s to %s\n", fnametmp, fname);
ret == -2 ? "copy" : "rename",
--- old/rsync.h
+++ new/rsync.h
-@@ -685,6 +685,14 @@ struct stats {
+@@ -750,6 +750,14 @@ struct stats {
int current_file_index;
};
--- old/generator.c
+++ new/generator.c
-@@ -44,6 +44,7 @@ extern int preserve_uid;
+@@ -45,6 +45,7 @@ extern int preserve_uid;
extern int preserve_gid;
extern int preserve_times;
extern int omit_dir_times;
extern int delete_mode;
extern int delete_before;
extern int delete_during;
-@@ -550,10 +551,11 @@ void itemize(struct file_struct *file, i
+@@ -541,10 +542,11 @@ void itemize(struct file_struct *file, i
iflags |= ITEM_REPORT_TIME;
- if ((unsigned)(st->st_mode & CHMOD_BITS) != (file->mode & CHMOD_BITS))
+ if (!BITS_EQUAL(st->st_mode, file->mode, CHMOD_BITS))
iflags |= ITEM_REPORT_PERMS;
- if (preserve_uid && am_root && F_UID(file) != st->st_uid)
+ if (preserve_uid && am_root && F_UID(file) != st->st_uid
iflags |= ITEM_REPORT_GROUP;
} else
iflags |= ITEM_IS_NEW;
-@@ -1169,7 +1171,7 @@ static void recv_generator(char *fname,
+@@ -1161,7 +1163,7 @@ static void recv_generator(char *fname,
/* If we're not preserving permissions, change the file-list's
* mode based on the local permissions and some heuristics. */
{"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 },
-@@ -1286,6 +1289,9 @@ int parse_arguments(int *argc, const cha
+@@ -1293,6 +1296,9 @@ int parse_arguments(int *argc, const cha
"P *%s", backup_suffix);
parse_rule(&filter_list, backup_dir_buf, 0, 0);
}
if (make_backups && !backup_dir)
omit_dir_times = 1;
-@@ -1519,6 +1525,8 @@ void server_options(char **args,int *arg
+@@ -1526,6 +1532,8 @@ void server_options(char **args,int *arg
argstr[x++] = 'm';
if (omit_dir_times == 2)
argstr[x++] = 'O';
argstr[x++] = 'L';
--- old/receiver.c
+++ new/receiver.c
-@@ -37,6 +37,7 @@ extern int protocol_version;
+@@ -38,6 +38,7 @@ extern int protocol_version;
extern int relative_paths;
extern int preserve_hard_links;
extern int preserve_perms;
extern int basis_dir_cnt;
extern int make_backups;
extern int cleanup_got_literal;
-@@ -543,7 +544,7 @@ int recv_files(int f_in, struct file_lis
+@@ -560,7 +561,7 @@ int recv_files(int f_in, char *local_nam
/* If we're not preserving permissions, change the file-list's
* mode based on the local permissions and some heuristics. */
extern int am_root;
extern int am_server;
extern int am_sender;
-@@ -215,9 +216,11 @@ int set_file_attrs(char *fname, struct f
+@@ -265,9 +266,11 @@ int set_file_attrs(char *fname, struct f
updated = 1;
}
--- old/flist.c
+++ new/flist.c
-@@ -53,6 +53,7 @@ extern int copy_links;
+@@ -58,6 +58,7 @@ extern int copy_links;
extern int copy_unsafe_links;
extern int protocol_version;
extern int sanitize_paths;
+extern unsigned long sleep_asec;
extern struct stats stats;
- extern struct file_list *the_file_list;
-@@ -1036,6 +1037,9 @@ static void send_directory(int f, struct
+ extern char curr_dir[MAXPATHLEN];
+@@ -1246,6 +1247,9 @@ static void send_directory(int f, struct
}
- send_file_name(f, flist, fbuf, NULL, 0);
+ send_file_name(f, flist, fbuf, NULL, flags, filter_flags);
+ /* Sleep for a bit, to avoid hammering the disk. */
+ if (sleep_asec)
+ usleep(sleep_asec);
size_t bwlimit_writemax = 0;
int ignore_existing = 0;
int ignore_non_existing = 0;
-@@ -377,6 +378,7 @@ void usage(enum logcode F)
- rprintf(F," --password-file=FILE read password from FILE\n");
+@@ -374,6 +375,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," --slow-down=USECs sleep N usec while creating the filelist\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");
-@@ -516,6 +518,7 @@ static struct poptOption long_options[]
+@@ -514,6 +516,7 @@ static struct poptOption long_options[]
{"log-format", 0, POPT_ARG_STRING, &stdout_format, 0, 0, 0 }, /* DEPRECATED */
{"itemize-changes", 'i', POPT_ARG_NONE, 0, 'i', 0, 0 },
{"bwlimit", 0, POPT_ARG_INT, &bwlimit, 0, 0, 0 },
--- old/generator.c
+++ new/generator.c
-@@ -60,6 +60,7 @@ extern int append_mode;
+@@ -61,6 +61,7 @@ extern int append_mode;
extern int make_backups;
extern int csum_length;
extern int ignore_times;
extern int size_only;
extern OFF_T max_size;
extern OFF_T min_size;
-@@ -508,7 +509,7 @@ void itemize(struct file_struct *file, i
+@@ -571,7 +572,7 @@ void itemize(struct file_struct *file, i
/* Perform our quick-check heuristic for determining if a file is unchanged. */
int unchanged_file(char *fn, struct file_struct *file, STRUCT_STAT *st)
{
/* if always checksum is set then we use the checksum instead
--- old/main.c
+++ new/main.c
-@@ -126,7 +126,7 @@ pid_t wait_process(pid_t pid, int *statu
+@@ -128,7 +128,7 @@ pid_t wait_process(pid_t pid, int *statu
}
/* Wait for a process to exit, calling io_flush while waiting. */
int daemon_bwlimit = 0;
int bwlimit = 0;
int fuzzy_basis = 0;
-@@ -151,6 +152,8 @@ char *logfile_name = NULL;
+@@ -150,6 +151,8 @@ char *logfile_name = NULL;
char *logfile_format = NULL;
char *stdout_format = NULL;
char *password_file = NULL;
{"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 },
-@@ -1409,6 +1418,16 @@ int parse_arguments(int *argc, const cha
+@@ -1416,6 +1425,16 @@ int parse_arguments(int *argc, const cha
}
}
if (files_from) {
char *h, *p;
int q;
-@@ -1682,6 +1701,25 @@ void server_options(char **args,int *arg
+@@ -1692,6 +1711,25 @@ void server_options(char **args,int *arg
args[ac++] = "--size-only";
}
+}
--- old/receiver.c
+++ new/receiver.c
-@@ -48,6 +48,7 @@ extern int checksum_seed;
+@@ -49,6 +49,7 @@ extern int checksum_seed;
extern int inplace;
extern int delay_updates;
extern struct stats stats;
extern char *stdout_format;
extern char *tmpdir;
extern char *partial_dir;
-@@ -348,6 +349,8 @@ int recv_files(int f_in, struct file_lis
+@@ -350,6 +351,8 @@ int recv_files(int f_in, char *local_nam
enum logcode log_code = log_before_transfer ? FLOG : FINFO;
int max_phase = protocol_version >= 29 ? 2 : 1;
int ndx, recv_ok;
+ char *filter_argv[MAX_FILTER_ARGS + 1];
if (verbose > 2)
- rprintf(FINFO, "recv_files(%d) starting\n", flist->count);
-@@ -362,6 +365,23 @@ int recv_files(int f_in, struct file_lis
+ rprintf(FINFO, "recv_files(%d) starting\n", cur_flist->count);
+@@ -359,6 +362,23 @@ int recv_files(int f_in, char *local_nam
updating_basis = inplace;
while (1) {
cleanup_disable();
-@@ -607,6 +627,9 @@ int recv_files(int f_in, struct file_lis
+@@ -619,6 +639,9 @@ int recv_files(int f_in, char *local_nam
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));
-@@ -621,6 +644,16 @@ int recv_files(int f_in, struct file_lis
+@@ -633,6 +656,16 @@ int recv_files(int f_in, char *local_nam
exit_cleanup(RERR_FILEIO);
}
if (partialptr == fname)
--- old/rsync.h
+++ new/rsync.h
-@@ -105,6 +105,7 @@
+@@ -119,6 +119,7 @@
#define IOERR_DEL_LIMIT (1<<2)
#define MAX_ARGS 1000
--protocol=NUM force an older protocol version to be used
--checksum-seed=NUM set block/file checksum seed (advanced)
-4, --ipv4 prefer IPv4
-@@ -1772,6 +1775,33 @@ file previously generated by bf(--write-
+@@ -1774,6 +1777,33 @@ file previously generated by bf(--write-
If em(FILE) is bf(-), the batch data will be read from standard input.
See the "BATCH MODE" section for details.
version of rsync. For instance, if rsync 2.6.4 is being used with the
--- old/sender.c
+++ new/sender.c
-@@ -43,6 +43,7 @@ extern int batch_fd;
+@@ -44,6 +44,7 @@ extern int batch_fd;
extern int write_batch;
extern struct stats stats;
- extern struct file_list *the_file_list;
+ extern struct file_list *cur_flist, *first_flist;
+extern char *source_filter;
extern char *stdout_format;
-
-@@ -174,6 +175,26 @@ void send_files(struct file_list *flist,
+ /**
+@@ -176,6 +177,26 @@ void send_files(int f_in, int f_out)
enum logcode log_code = log_before_transfer ? FLOG : FINFO;
int f_xfer = write_batch < 0 ? batch_fd : f_out;
- int i, j;
+ int ndx, j;
+ char *filter_argv[MAX_FILTER_ARGS + 1];
+ char *tmp = 0;
+ int unlink_tmp = 0;
if (verbose > 2)
rprintf(FINFO, "send_files starting\n");
-@@ -247,6 +268,7 @@ void send_files(struct file_list *flist,
- return;
+@@ -266,6 +287,7 @@ void send_files(int f_in, int f_out)
+ exit_cleanup(RERR_PROTOCOL);
}
+ unlink_tmp = 0;
fd = do_open(fname, O_RDONLY, 0);
if (fd == -1) {
if (errno == ENOENT) {
-@@ -275,6 +297,33 @@ void send_files(struct file_list *flist,
- return;
+@@ -296,6 +318,33 @@ void send_files(int f_in, int f_out)
+ exit_cleanup(RERR_PROTOCOL);
}
+ if (source_filter) {
if (st.st_size) {
int32 read_size = MAX(s->blength * 3, MAX_MAP_SIZE);
mbuf = map_file(fd, st.st_size, read_size, s->blength);
-@@ -316,6 +365,8 @@ void send_files(struct file_list *flist,
+@@ -337,6 +386,8 @@ void send_files(int f_in, int f_out)
}
}
close(fd);
--- old/io.c
+++ new/io.c
-@@ -50,6 +50,7 @@ extern int remove_source_files;
+@@ -53,6 +53,7 @@ extern int remove_source_files;
extern int preserve_hard_links;
extern char *filesfrom_host;
extern struct stats stats;
+extern time_t stop_at_utime;
- extern struct file_list *the_file_list;
+ extern struct file_list *cur_flist, *first_flist;
const char phase_unknown[] = "unknown";
-@@ -166,16 +167,24 @@ static void check_timeout(void)
+@@ -173,16 +174,24 @@ static void check_timeout(void)
{
time_t t;
OFF_T max_size = 0;
OFF_T min_size = 0;
@@ -374,6 +375,8 @@ void usage(enum logcode F)
- rprintf(F," --password-file=FILE read password from FILE\n");
+ 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," --stop-at=y-m-dTh:m Stop rsync at year-month-dayThour:minute\n");
{"backup", 'b', POPT_ARG_NONE, &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 },
-@@ -1087,6 +1092,36 @@ int parse_arguments(int *argc, const cha
+@@ -1093,6 +1098,36 @@ int parse_arguments(int *argc, const cha
usage(FINFO);
exit_cleanup(0);
default:
/* A large opt value means that set_refuse_options()
* turned this option off. */
-@@ -1646,6 +1681,15 @@ void server_options(char **args,int *arg
+@@ -1656,6 +1691,15 @@ void server_options(char **args,int *arg
args[ac++] = arg;
}
--- old/rsync.yo
+++ new/rsync.yo
@@ -395,6 +395,8 @@ to the detailed description below for a
- --password-file=FILE read password from FILE
+ --password-file=FILE read daemon-access password from FILE
--list-only list the files instead of copying them
--bwlimit=KBPS limit I/O bandwidth; KBytes per second
+ --stop-at=y-m-dTh:m Stop rsync at year-month-dayThour:minute
--write-batch=FILE write a batched update to FILE
--only-write-batch=FILE like --write-batch but w/o updating dest
--read-batch=FILE read a batched update from FILE
-@@ -1746,6 +1748,19 @@ transfer was too fast, it will wait befo
+@@ -1748,6 +1750,19 @@ transfer was too fast, it will wait befo
result is an average transfer rate equaling the specified limit. A value
of zero specifies no limit.
if ((am_root && preserve_devices && IS_DEVICE(file->mode))
--- old/compat.c
+++ new/compat.c
-@@ -52,6 +52,8 @@ void setup_protocol(int f_out,int f_in)
+@@ -58,6 +58,8 @@ void setup_protocol(int f_out,int f_in)
preserve_gid = ++file_extra_cnt;
if (preserve_acls && !am_sender)
preserve_acls = ++file_extra_cnt;
--- old/flist.c
+++ new/flist.c
-@@ -42,6 +42,7 @@ extern int one_file_system;
+@@ -43,6 +43,7 @@ extern int one_file_system;
extern int copy_dirlinks;
extern int keep_dirlinks;
extern int preserve_acls;
extern int preserve_links;
extern int preserve_hard_links;
extern int preserve_devices;
-@@ -812,6 +813,10 @@ static struct file_struct *recv_file_ent
+@@ -862,6 +863,10 @@ static struct file_struct *recv_file_ent
if (preserve_acls)
receive_acl(file, f);
#endif
return file;
}
-@@ -1082,7 +1087,7 @@ static struct file_struct *send_file_nam
- int flags)
+@@ -1134,7 +1139,7 @@ static struct file_struct *send_file_nam
+ int flags, int filter_flags)
{
struct file_struct *file;
-#ifdef SUPPORT_ACLS
statx sx;
#endif
-@@ -1102,6 +1107,13 @@ static struct file_struct *send_file_nam
+@@ -1153,6 +1158,13 @@ static struct file_struct *send_file_nam
return NULL;
}
#endif
maybe_emit_filelist_progress(flist->count + flist_count_offset);
-@@ -1113,6 +1125,10 @@ static struct file_struct *send_file_nam
+@@ -1164,6 +1176,10 @@ static struct file_struct *send_file_nam
if (preserve_acls)
send_acl(&sx, f);
#endif
int preserve_perms = 0;
int preserve_executability = 0;
int preserve_devices = 0;
-@@ -200,6 +201,7 @@ static void print_rsync_version(enum log
+@@ -201,6 +202,7 @@ static void print_rsync_version(enum log
char const *have_inplace = "no ";
char const *hardlinks = "no ";
char const *acls = "no ";
char const *links = "no ";
char const *ipv6 = "no ";
STRUCT_STAT *dumstat;
-@@ -219,7 +221,9 @@ static void print_rsync_version(enum log
+@@ -220,7 +222,9 @@ static void print_rsync_version(enum log
#ifdef SUPPORT_ACLS
acls = "";
#endif
#ifdef SUPPORT_LINKS
links = "";
#endif
-@@ -238,8 +242,8 @@ static void print_rsync_version(enum log
+@@ -239,8 +243,8 @@ static void print_rsync_version(enum log
(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());
-@@ -285,7 +289,7 @@ void usage(enum logcode F)
+@@ -286,7 +290,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," --no-OPTION turn off an implied OPTION (e.g. --no-D)\n");
rprintf(F," -r, --recursive recurse into directories\n");
rprintf(F," -R, --relative use relative path names\n");
-@@ -310,6 +314,9 @@ void usage(enum logcode F)
+@@ -311,6 +315,9 @@ void usage(enum logcode F)
#ifdef SUPPORT_ACLS
rprintf(F," -A, --acls preserve ACLs (implies --perms)\n");
#endif
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");
-@@ -433,6 +440,9 @@ static struct poptOption long_options[]
+@@ -434,6 +441,9 @@ static struct poptOption long_options[]
{"acls", 'A', POPT_ARG_NONE, 0, 'A', 0, 0 },
{"no-acls", 0, POPT_ARG_VAL, &preserve_acls, 0, 0, 0 },
{"no-A", 0, POPT_ARG_VAL, &preserve_acls, 0, 0, 0 },
{"times", 't', POPT_ARG_VAL, &preserve_times, 1, 0, 0 },
{"no-times", 0, POPT_ARG_VAL, &preserve_times, 0, 0, 0 },
{"no-t", 0, POPT_ARG_VAL, &preserve_times, 0, 0, 0 },
-@@ -1115,6 +1125,17 @@ int parse_arguments(int *argc, const cha
+@@ -1122,6 +1132,17 @@ int parse_arguments(int *argc, const cha
return 0;
#endif
default:
/* A large opt value means that set_refuse_options()
-@@ -1562,6 +1583,10 @@ void server_options(char **args,int *arg
+@@ -1590,6 +1611,10 @@ void server_options(char **args,int *arg
if (preserve_acls)
argstr[x++] = 'A';
#endif
+ if (preserve_xattrs)
+ argstr[x++] = 'X';
+#endif
- if (preserve_uid)
- argstr[x++] = 'o';
- if (preserve_gid)
+ if (recurse)
+ argstr[x++] = 'r';
+ if (always_checksum)
--- old/rsync.c
+++ new/rsync.c
@@ -33,6 +33,7 @@
extern int preserve_perms;
extern int preserve_executability;
extern int preserve_times;
-@@ -271,6 +272,10 @@ int set_file_attrs(char *fname, struct f
+@@ -321,6 +322,10 @@ int set_file_attrs(char *fname, struct f
if (daemon_chmod_modes && !S_ISLNK(new_mode))
new_mode = tweak_mode(new_mode, daemon_chmod_modes);
* will enable owner-writability using chmod, if necessary.
--- old/rsync.h
+++ new/rsync.h
-@@ -540,6 +540,10 @@ struct idev_node {
+@@ -554,6 +554,10 @@ struct idev_node {
#define ACLS_NEED_MASK 1
#endif
#define GID_NONE ((gid_t)-1)
union file_extras {
-@@ -560,6 +564,7 @@ extern int file_extra_cnt;
+@@ -574,6 +578,7 @@ extern int file_extra_cnt;
extern int preserve_uid;
extern int preserve_gid;
extern int preserve_acls;
#define FILE_STRUCT_LEN (offsetof(struct file_struct, basename))
#define EXTRA_LEN (sizeof (union file_extras))
-@@ -593,6 +598,7 @@ extern int preserve_acls;
- #define F_UID(f) REQ_EXTRA(f, preserve_uid)->unum
- #define F_GID(f) REQ_EXTRA(f, preserve_gid)->unum
+@@ -607,6 +612,7 @@ extern int preserve_acls;
+ #define F_OWNER(f) REQ_EXTRA(f, preserve_uid)->unum
+ #define F_GROUP(f) REQ_EXTRA(f, preserve_gid)->unum
#define F_ACL(f) REQ_EXTRA(f, preserve_acls)->unum
+#define F_XATTR(f) REQ_EXTRA(f, preserve_xattrs)->unum
/* These items are per-entry optional and mutally exclusive: */
#define F_HL_GNUM(f) OPT_EXTRA(f, LEN64_BUMP(f))->num
-@@ -768,6 +774,9 @@ typedef struct {
+@@ -798,6 +804,9 @@ typedef struct {
struct rsync_acl *acc_acl; /* access ACL */
struct rsync_acl *def_acl; /* default ACL */
#endif