#ifdef SUPPORT_LINKS
if (preserve_links && S_ISLNK(f->mode)) {
rprintf(FINFO, "%s %11.0f %s %s -> %s\n",
-@@ -624,6 +627,12 @@ static struct file_struct *recv_file_ent
+@@ -662,6 +665,12 @@ static struct file_struct *recv_file_ent
}
#endif
if (always_checksum && S_ISREG(mode))
extra_len += SUM_EXTRA_CNT * EXTRA_LEN;
-@@ -736,6 +745,11 @@ static struct file_struct *recv_file_ent
- read_buf(f, bp, checksum_len);
+@@ -787,6 +796,11 @@ static struct file_struct *recv_file_ent
+ read_buf(f, bp, checksum_len);
}
+#ifdef SUPPORT_ACLS
return file;
}
-@@ -996,6 +1010,9 @@ static struct file_struct *send_file_nam
+@@ -1047,6 +1061,9 @@ static struct file_struct *send_file_nam
unsigned short flags)
{
struct file_struct *file;
file = make_file(fname, flist, stp, flags,
f == -2 ? SERVER_FILTERS : ALL_FILTERS);
-@@ -1005,11 +1022,24 @@ static struct file_struct *send_file_nam
+@@ -1056,12 +1073,26 @@ static struct file_struct *send_file_nam
if (chmod_modes && !S_ISLNK(file->mode))
file->mode = tweak_mode(file->mode, chmod_modes);
flist_expand(flist);
flist->files[flist->count++] = file;
- send_file_entry(file, f);
+- if (f >= 0)
++ if (f >= 0) {
+ send_file_entry(file, f, flist->count - 1);
+#ifdef SUPPORT_ACLS
-+ if (preserve_acls && f >= 0)
-+ send_acl(&sx, f);
++ if (preserve_acls)
++ send_acl(&sx, f);
+#endif
++ }
return file;
}
extern int link_dest;
+extern int preserve_acls;
extern int make_backups;
+ extern int protocol_version;
extern int remove_source_files;
- extern int stdout_format_has_i;
-@@ -119,15 +120,19 @@ void match_hard_links(void)
+@@ -334,15 +335,19 @@ void match_hard_links(void)
}
static int maybe_hard_link(struct file_struct *file, int ndx,
ITEM_LOCAL_CHANGE | ITEM_XNAME_FOLLOWS,
0, "");
}
-@@ -148,7 +153,11 @@ static int maybe_hard_link(struct file_s
+@@ -363,7 +368,11 @@ static int maybe_hard_link(struct file_s
if (hard_link_one(file, fname, oldname, 0)) {
if (itemizing) {
ITEM_LOCAL_CHANGE | ITEM_XNAME_FOLLOWS, 0,
realname);
}
-@@ -162,7 +171,7 @@ static int maybe_hard_link(struct file_s
+@@ -377,7 +386,7 @@ static int maybe_hard_link(struct file_s
/* Only called if FLAG_HLINKED is set and FLAG_HLINK_FIRST is not. Returns:
* 0 = process the file, 1 = skip the file, -1 = error occurred. */
int hard_link_check(struct file_struct *file, int ndx, const char *fname,
enum logcode code)
{
STRUCT_STAT prev_st;
-@@ -213,18 +222,20 @@ int hard_link_check(struct file_struct *
+@@ -428,18 +437,20 @@ int hard_link_check(struct file_struct *
if (statret < 0 && basis_dir[0] != NULL) {
/* If we match an alt-dest item, we don't output this as a change. */
char cmpbuf[MAXPATHLEN];
if (verbose < 2 || !stdout_format_has_i) {
itemizing = 0;
code = FNONE;
-@@ -233,16 +244,36 @@ int hard_link_check(struct file_struct *
+@@ -448,16 +459,36 @@ int hard_link_check(struct file_struct *
}
break;
}
realname, itemizing, code) < 0)
return -1;
-@@ -277,7 +308,8 @@ void finish_hard_link(struct file_struct
+@@ -492,7 +523,8 @@ void finish_hard_link(struct file_struct
STRUCT_STAT *stp, int itemizing, enum logcode code,
int alt_dest)
{
char alt_name[MAXPATHLEN], *prev_name;
const char *our_name;
int prev_statret, ndx, prev_ndx = F_HL_PREV(file);
-@@ -301,14 +333,24 @@ void finish_hard_link(struct file_struct
+@@ -516,14 +548,24 @@ void finish_hard_link(struct file_struct
} else
our_name = fname;
--- old/rsync.h
+++ new/rsync.h
-@@ -502,6 +502,14 @@ struct idev {
+@@ -508,6 +508,14 @@ struct idev_node {
#define IN_LOOPBACKNET 127
#endif
#define GID_NONE ((gid_t)-1)
struct file_struct {
-@@ -553,10 +561,12 @@ extern int preserve_gid;
+@@ -559,11 +567,13 @@ 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)->uid
#define F_GID(f) REQ_EXTRA(f, preserve_gid)->gid
/* These items are per-entry optional and mutally exclusive: */
#define F_HL_IDEV(f) OPT_EXTRA(f, LEN64_BUMP(f))->idev
+ #define F_HL_GNUM(f) OPT_EXTRA(f, LEN64_BUMP(f))->num
#define F_HL_PREV(f) OPT_EXTRA(f, LEN64_BUMP(f))->num
+#define F_DEF_ACL(f) OPT_EXTRA(f, LEN64_BUMP(f))->unum
/* This optional item might follow an F_HL_*() item.
* (Note: a device doesn't need to check LEN64_BUMP(f).) */
-@@ -692,6 +702,17 @@ struct stats {
+@@ -699,6 +709,17 @@ struct stats {
struct chmod_mode_struct;
#include "byteorder.h"
#include "lib/mdfour.h"
#include "lib/wildmatch.h"
-@@ -710,6 +731,16 @@ struct chmod_mode_struct;
+@@ -717,6 +738,16 @@ struct chmod_mode_struct;
#define NORETURN __attribute__((__noreturn__))
#endif
static mode_t mode;
static int64 dev;
static dev_t rdev;
-@@ -329,7 +334,7 @@ static void send_file_entry(struct file_
-
- if (!file) {
- write_byte(f, 0);
-- modtime = 0, mode = 0;
-+ modtime = 0, atime = 0, mode = 0;
- dev = 0, rdev = MAKEDEV(0, 0);
- rdev_major = 0;
- uid = 0, gid = 0;
-@@ -379,6 +384,13 @@ static void send_file_entry(struct file_
+@@ -367,6 +372,13 @@ static void send_file_entry(struct file_
flags |= XMIT_SAME_TIME;
else
modtime = file->modtime;
#ifdef SUPPORT_HARD_LINKS
if (tmp_idev.dev != 0) {
-@@ -431,6 +443,8 @@ static void send_file_entry(struct file_
+@@ -434,6 +446,8 @@ static void send_file_entry(struct file_
write_int(f, modtime);
if (!(flags & XMIT_SAME_MODE))
write_int(f, to_wire_mode(mode));
if (preserve_uid && !(flags & XMIT_SAME_UID)) {
if (!numeric_ids)
add_uid(uid);
-@@ -497,7 +511,7 @@ static void send_file_entry(struct file_
+@@ -501,7 +515,7 @@ static void send_file_entry(struct file_
static struct file_struct *recv_file_entry(struct file_list *flist,
unsigned short flags, int f)
{
static mode_t mode;
static int64 dev;
static dev_t rdev;
-@@ -517,7 +531,7 @@ static struct file_struct *recv_file_ent
+@@ -522,7 +536,7 @@ static struct file_struct *recv_file_ent
struct file_struct *file;
if (!flist) {
dev = 0, rdev = MAKEDEV(0, 0);
rdev_major = 0;
uid = 0, gid = 0;
-@@ -573,6 +587,8 @@ static struct file_struct *recv_file_ent
+@@ -610,6 +624,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);
-@@ -657,6 +673,8 @@ static struct file_struct *recv_file_ent
+@@ -695,6 +711,8 @@ static struct file_struct *recv_file_ent
F_UID(file) = uid;
if (preserve_gid)
F_GID(file) = gid;
if (dirname_len) {
file->dirname = lastdir = bp;
-@@ -934,6 +952,8 @@ struct file_struct *make_file(const char
+@@ -985,6 +1003,8 @@ struct file_struct *make_file(const char
F_UID(file) = st.st_uid;
if (preserve_gid)
F_GID(file) = st.st_gid;
change_uid = am_root && preserve_uid && st->st_uid != F_UID(file);
--- old/rsync.h
+++ new/rsync.h
-@@ -54,6 +54,7 @@
- #define XMIT_HAS_IDEV_DATA (1<<9)
- #define XMIT_SAME_DEV (1<<10)
+@@ -55,6 +55,7 @@
+ #define XMIT_SAME_DEV_pre30 (1<<10) /* protocols < 30 */
+ #define XMIT_HLINK_FIRST (1<<10) /* protocols >= 30 */
#define XMIT_RDEV_MINOR_IS_SMALL (1<<11)
+#define XMIT_SAME_ATIME (1<<12)
/* These flags are used in the live flist data. */
-@@ -127,6 +128,7 @@
+@@ -128,6 +129,7 @@
#define ATTRS_REPORT (1<<0)
#define ATTRS_SKIP_MTIME (1<<1)
#define FULL_FLUSH 1
#define NORMAL_FLUSH 0
-@@ -508,6 +510,7 @@ struct file_struct {
+@@ -514,6 +516,7 @@ struct file_struct {
union flist_extras {
uid_t uid; /* The user ID number */
uid_t gid; /* The group ID number or GID_NONE */
struct idev *idev; /* The hard-link info during matching */
int32 num; /* A signed number */
uint32 unum; /* An unsigned number */
-@@ -553,6 +556,7 @@ extern int preserve_gid;
+@@ -559,6 +562,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)->uid
#define F_GID(f) REQ_EXTRA(f, preserve_gid)->gid
extern int module_id;
extern int ignore_errors;
extern int numeric_ids;
-@@ -734,6 +735,15 @@ static struct file_struct *recv_file_ent
- bp = tmp_sum;
- }
- read_buf(f, bp, checksum_len);
+@@ -785,6 +786,15 @@ static struct file_struct *recv_file_ent
+ memcpy(bp, F_SUM(first), checksum_len);
+ } else
+ read_buf(f, bp, checksum_len);
+ if (pre_checksum && sum_len) {
+ STRUCT_STAT st;
+ char *fname = f_name(file, NULL);
extern int checksum_len;
extern char *partial_dir;
extern char *basis_dir[];
-@@ -578,7 +579,8 @@ void itemize(struct file_struct *file, i
+@@ -577,7 +578,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;
-@@ -587,6 +589,8 @@ int unchanged_file(char *fn, struct file
+@@ -586,6 +588,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)) {
char sum[MD4_SUM_LENGTH];
file_checksum(fn, sum, st->st_size);
return memcmp(sum, F_SUM(file), checksum_len) == 0;
}
-@@ -826,7 +830,7 @@ static int try_dests_reg(struct file_str
+@@ -825,7 +829,7 @@ static int try_dests_reg(struct file_str
match_level = 1;
/* FALL THROUGH */
case 1:
continue;
best_match = j;
match_level = 2;
-@@ -1512,7 +1516,7 @@ static void recv_generator(char *fname,
+@@ -1511,7 +1515,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
-@@ -233,7 +233,7 @@ int hard_link_check(struct file_struct *
+@@ -448,7 +448,7 @@ int hard_link_check(struct file_struct *
}
break;
}
int save_verbose = verbose;
if (filesfrom_fd >= 0) {
-@@ -836,6 +841,10 @@ static void do_server_recv(int f_in, int
- init_hard_links();
- #endif
+@@ -831,6 +836,10 @@ static void do_server_recv(int f_in, int
+ filesfrom_fd = -1;
+ }
+ strlcpy(olddir, curr_dir, sizeof olddir);
+ if (always_checksum && !local_server && argc > 0)
flist = recv_file_list(f_in);
verbose = save_verbose;
if (!flist) {
-@@ -844,6 +853,9 @@ static void do_server_recv(int f_in, int
+@@ -839,6 +848,9 @@ static void do_server_recv(int f_in, int
}
the_file_list = flist;
if (argc > 0)
local_name = get_local_name(flist,argv[0]);
-@@ -923,6 +935,7 @@ int client_run(int f_in, int f_out, pid_
+@@ -918,6 +930,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;
-@@ -1002,11 +1015,18 @@ int client_run(int f_in, int f_out, pid_
- init_hard_links();
- #endif
+@@ -992,11 +1005,18 @@ int client_run(int f_in, int f_out, pid_
+ filesfrom_fd = -1;
+ }
+ strlcpy(olddir, curr_dir, sizeof olddir);
+ if (always_checksum && !local_server)
--- old/rsync.h
+++ new/rsync.h
-@@ -67,6 +67,7 @@
+@@ -68,6 +68,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 */
extern int preserve_links;
extern int preserve_hard_links;
extern int preserve_devices;
-@@ -749,6 +750,10 @@ static struct file_struct *recv_file_ent
+@@ -800,6 +801,10 @@ static struct file_struct *recv_file_ent
if (preserve_acls)
receive_acl(file, f);
#endif
return file;
}
-@@ -1010,7 +1015,7 @@ static struct file_struct *send_file_nam
+@@ -1061,7 +1066,7 @@ static struct file_struct *send_file_nam
unsigned short flags)
{
struct file_struct *file;
statx sx;
#endif
-@@ -1030,6 +1035,13 @@ static struct file_struct *send_file_nam
+@@ -1081,6 +1086,13 @@ static struct file_struct *send_file_nam
return NULL;
}
#endif
maybe_emit_filelist_progress(flist->count + flist_count_offset);
-@@ -1040,6 +1052,10 @@ static struct file_struct *send_file_nam
- if (preserve_acls && f >= 0)
- send_acl(&sx, f);
+@@ -1092,6 +1104,10 @@ static struct file_struct *send_file_nam
+ if (preserve_acls)
+ send_acl(&sx, f);
#endif
+#ifdef SUPPORT_XATTRS
-+ if (preserve_xattrs && f >= 0)
-+ send_xattr(&sx, f);
++ if (preserve_xattrs)
++ send_xattr(&sx, f);
+#endif
+ }
return file;
}
-
--- old/lib/sysxattr.c
+++ new/lib/sysxattr.c
@@ -0,0 +1,135 @@
* will enable owner-writability using chmod, if necessary.
--- old/rsync.h
+++ new/rsync.h
-@@ -508,6 +508,10 @@ struct idev {
+@@ -516,6 +516,10 @@ struct idev_node {
#define ACLS_NEED_MASK 1
#endif
#define GID_NONE ((gid_t)-1)
struct file_struct {
-@@ -557,6 +561,7 @@ extern int preserve_gid;
+@@ -568,6 +572,7 @@ extern int preserve_gid;
#define F_UID(f) REQ_EXTRA(f, preserve_uid)->uid
#define F_GID(f) REQ_EXTRA(f, preserve_gid)->gid
#define F_ACL(f) REQ_EXTRA(f, preserve_acls)->unum
/* These items are per-entry optional and mutally exclusive: */
#define F_HL_IDEV(f) OPT_EXTRA(f, LEN64_BUMP(f))->idev
-@@ -732,6 +737,9 @@ typedef struct {
+@@ -744,6 +749,9 @@ typedef struct {
struct rsync_acl *acc_acl; /* access ACL */
struct rsync_acl *def_acl; /* default ACL */
#endif