diff options
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | backup.c | 17 | ||||
-rw-r--r-- | flist.c | 3 | ||||
-rw-r--r-- | generator.c | 8 | ||||
-rw-r--r-- | hlink.c | 15 | ||||
-rw-r--r-- | ifuncs.h | 11 | ||||
-rw-r--r-- | rsync.c | 7 |
7 files changed, 24 insertions, 39 deletions
@@ -51,3 +51,5 @@ Changes since 3.0.4: - The pool_alloc library has received some minor improvements in alignment handling. + + - Added init_stat_x() function to avoid duplication of acl/xattr init code. @@ -19,6 +19,7 @@ */ #include "rsync.h" +#include "ifuncs.h" extern int am_root; extern int preserve_acls; @@ -131,17 +132,12 @@ int make_bak_dir(const char *fullpath) if (p >= rel) { /* Try to transfer the directory settings of the * actual dir that the files are coming from. */ + init_stat_x(&sx); if (x_stat(rel, &sx.st, NULL) < 0) { rsyserr(FERROR, errno, "make_bak_dir stat %s failed", full_fname(rel)); } else { -#ifdef SUPPORT_ACLS - sx.acc_acl = sx.def_acl = NULL; -#endif -#ifdef SUPPORT_XATTRS - sx.xattr = NULL; -#endif if (!(file = make_file(rel, NULL, NULL, 0, NO_FILTERS))) continue; #ifdef SUPPORT_ACLS @@ -207,15 +203,10 @@ static int keep_backup(const char *fname) int kept = 0; int ret_code; - /* return if no file to keep */ + init_stat_x(&sx); + /* Return success if no file to keep. */ if (x_lstat(fname, &sx.st, NULL) < 0) return 1; -#ifdef SUPPORT_ACLS - sx.acc_acl = sx.def_acl = NULL; -#endif -#ifdef SUPPORT_XATTRS - sx.xattr = NULL; -#endif if (!(file = make_file(fname, NULL, NULL, 0, NO_FILTERS))) return 1; /* the file could have disappeared */ @@ -1378,6 +1378,7 @@ static struct file_struct *send_file_name(int f, struct file_list *flist, #endif #if defined SUPPORT_ACLS || defined SUPPORT_XATTRS stat_x sx; + init_stat_x(&sx); #endif #ifdef SUPPORT_LINKS @@ -1441,7 +1442,6 @@ static struct file_struct *send_file_name(int f, struct file_list *flist, #ifdef SUPPORT_ACLS if (preserve_acls && !S_ISLNK(file->mode)) { sx.st.st_mode = file->mode; - sx.acc_acl = sx.def_acl = NULL; if (get_acl(fname, &sx) < 0) { io_error |= IOERR_GENERAL; return NULL; @@ -1450,7 +1450,6 @@ static struct file_struct *send_file_name(int f, struct file_list *flist, #endif #ifdef SUPPORT_XATTRS if (preserve_xattrs) { - sx.xattr = NULL; if (get_xattr(fname, &sx) < 0) { io_error |= IOERR_GENERAL; return NULL; diff --git a/generator.c b/generator.c index 1db0fe01..1e660859 100644 --- a/generator.c +++ b/generator.c @@ -22,6 +22,7 @@ #include "rsync.h" #include "inums.h" +#include "ifuncs.h" extern int dry_run; extern int do_xfers; @@ -1333,12 +1334,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, } } -#ifdef SUPPORT_ACLS - sx.acc_acl = sx.def_acl = NULL; -#endif -#ifdef SUPPORT_XATTRS - sx.xattr = NULL; -#endif + init_stat_x(&sx); if (dry_run > 1 || (dry_missing_dir && is_below(file, dry_missing_dir))) { parent_is_dry_missing: if (fuzzy_dirlist) { @@ -22,6 +22,7 @@ #include "rsync.h" #include "inums.h" +#include "ifuncs.h" extern int dry_run; extern int list_only; @@ -393,12 +394,7 @@ int hard_link_check(struct file_struct *file, int ndx, const char *fname, char cmpbuf[MAXPATHLEN]; stat_x alt_sx; int j = 0; -#ifdef SUPPORT_ACLS - alt_sx.acc_acl = alt_sx.def_acl = NULL; -#endif -#ifdef SUPPORT_XATTRS - alt_sx.xattr = NULL; -#endif + init_stat_x(&alt_sx); do { pathjoin(cmpbuf, MAXPATHLEN, basis_dir[j], fname); if (link_stat(cmpbuf, &alt_sx.st, 0) < 0) @@ -521,12 +517,7 @@ void finish_hard_link(struct file_struct *file, const char *fname, int fin_ndx, } else our_name = fname; -#ifdef SUPPORT_ACLS - prev_sx.acc_acl = prev_sx.def_acl = NULL; -#endif -#ifdef SUPPORT_XATTRS - prev_sx.xattr = NULL; -#endif + init_stat_x(&prev_sx); while ((ndx = prev_ndx) >= 0) { int val; @@ -66,3 +66,14 @@ d_name(struct dirent *di) return di->d_name; #endif } + +static inline void +init_stat_x(stat_x *sx_p) +{ +#ifdef SUPPORT_ACLS + sx_p->acc_acl = sx_p->def_acl = NULL; +#endif +#ifdef SUPPORT_XATTRS + sx_p->xattr = NULL; +#endif +} @@ -395,12 +395,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp, full_fname(fname)); return 0; } -#ifdef SUPPORT_ACLS - sx2.acc_acl = sx2.def_acl = NULL; -#endif -#ifdef SUPPORT_XATTRS - sx2.xattr = NULL; -#endif + init_stat_x(&sx2); sxp = &sx2; inherit = !preserve_perms; } else |