summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWayne Davison <wayned@samba.org>2009-01-03 08:53:59 -0800
committerWayne Davison <wayned@samba.org>2009-01-03 08:53:59 -0800
commit09ca0d15d31d93a5964a1db4c387879f31c22831 (patch)
treea966cbf8f02b8796d5c8d9f66e3c533ad97a4b41
parentc43c66125e8fd35896a358ccce9687ebcfe82dc5 (diff)
downloadrsync-09ca0d15d31d93a5964a1db4c387879f31c22831.tar.gz
Added init_stat_x() to avoid duplication of acl/xattr init code.
-rw-r--r--NEWS2
-rw-r--r--backup.c17
-rw-r--r--flist.c3
-rw-r--r--generator.c8
-rw-r--r--hlink.c15
-rw-r--r--ifuncs.h11
-rw-r--r--rsync.c7
7 files changed, 24 insertions, 39 deletions
diff --git a/NEWS b/NEWS
index f0de0ca6..eaacde62 100644
--- a/NEWS
+++ b/NEWS
@@ -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.
diff --git a/backup.c b/backup.c
index 60c85b17..b40da92f 100644
--- a/backup.c
+++ b/backup.c
@@ -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 */
diff --git a/flist.c b/flist.c
index e86b57a2..84420c0b 100644
--- a/flist.c
+++ b/flist.c
@@ -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) {
diff --git a/hlink.c b/hlink.c
index 05813985..e6ed0720 100644
--- a/hlink.c
+++ b/hlink.c
@@ -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;
diff --git a/ifuncs.h b/ifuncs.h
index 0fe900a3..8c128d58 100644
--- a/ifuncs.h
+++ b/ifuncs.h
@@ -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
+}
diff --git a/rsync.c b/rsync.c
index 845517d6..49cc41c7 100644
--- a/rsync.c
+++ b/rsync.c
@@ -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