The Samba-Bugzilla – Attachment 6630 Details for
Bug 7622
Factor out common logic from itemize and unchanged_attrs functions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
7622.patch (text/plain), 8.58 KB, created by
Matt McCutchen
on 2011-06-26 20:46:51 UTC
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Matt McCutchen
Created:
2011-06-26 20:46:51 UTC
Size:
8.58 KB
patch
obsolete
>From Mon Sep 17 00:00:00 2001 >From: Matt McCutchen <matt@mattmccutchen.net> >Date: Sun, 26 Jun 2011 16:39:21 -0400 > >Factor out common logic of unchanged_attrs and itemize into report_ATTR functions. >--- > generator.c | 144 ++++++++++++++++++++++++++-------------------------------- > xattrs.c | 11 +++-- > 2 files changed, 71 insertions(+), 84 deletions(-) > >diff --git a/generator.c b/generator.c >index 8491300..d5dc85f 100644 >--- a/generator.c >+++ b/generator.c >@@ -377,13 +377,30 @@ static void do_delete_pass(void) > rprintf(FINFO, " \r"); > } > >-static inline int time_differs(struct file_struct *file, stat_x *sxp) >+static BOOL preserve_time_of(struct file_struct *file) > { >- return cmp_time(sxp->st.st_mtime, file->modtime); >+ if (S_ISDIR(file->mode)) >+ return preserve_times & PRESERVE_DIR_TIMES; >+ else if (S_ISLNK(file->mode)) >+ /* PRESERVE_LINK_TIMES will only be set if CAN_SET_SYMLINK_TIMES. */ >+ return preserve_times & PRESERVE_LINK_TIMES; >+ else >+ return preserve_times; >+} >+ >+static BOOL report_time(struct file_struct *file, stat_x *sxp) >+{ >+ return preserve_time_of(file) && >+ cmp_time(sxp->st.st_mtime, file->modtime); > } > >-static inline int perms_differ(struct file_struct *file, stat_x *sxp) >+static BOOL report_perms(struct file_struct *file, stat_x *sxp) > { >+#ifndef CAN_CHMOD_SYMLINK >+ if (S_ISLNK(file->mode)) >+ return 0; >+#endif >+ > if (preserve_perms) > return !BITS_EQUAL(sxp->st.st_mode, file->mode, CHMOD_BITS); > >@@ -393,20 +410,34 @@ static inline int perms_differ(struct file_struct *file, stat_x *sxp) > return 0; > } > >-static inline int ownership_differs(struct file_struct *file, stat_x *sxp) >+static BOOL report_owner(struct file_struct *file, stat_x *sxp) > { >- if (am_root && uid_ndx && sxp->st.st_uid != (uid_t)F_OWNER(file)) >- return 1; >+#ifndef CAN_CHOWN_SYMLINK >+ if (S_ISLNK(file->mode)) >+ return 0; >+#endif > >- if (gid_ndx && !(file->flags & FLAG_SKIP_GROUP) && sxp->st.st_gid != (gid_t)F_GROUP(file)) >- return 1; >+ return uid_ndx && am_root && sxp->st.st_uid != (uid_t)F_OWNER(file); >+} > >- return 0; >+static BOOL report_group(struct file_struct *file, stat_x *sxp) >+{ >+#ifndef CAN_CHOWN_SYMLINK >+ if (S_ISLNK(file->mode)) >+ return 0; >+#endif >+ >+ return gid_ndx && !(file->flags & FLAG_SKIP_GROUP) && sxp->st.st_gid != (gid_t)F_GROUP(file); > } > > #ifdef SUPPORT_ACLS >-static inline int acls_differ(const char *fname, struct file_struct *file, stat_x *sxp) >+static BOOL report_acls(const char *fname, struct file_struct *file, stat_x *sxp) > { >+#ifndef CAN_SET_SYMLINK_ACLS /* not currently */ >+ if (S_ISLNK(file->mode)) >+ return 0; >+#endif >+ > if (preserve_acls) { > if (!ACL_READY(*sxp)) > get_acl(fname, sxp); >@@ -419,12 +450,18 @@ static inline int acls_differ(const char *fname, struct file_struct *file, stat_ > #endif > > #ifdef SUPPORT_XATTRS >-static inline int xattrs_differ(const char *fname, struct file_struct *file, stat_x *sxp) >+static BOOL report_xattrs(const char *fname, struct file_struct *file, stat_x *sxp, >+ BOOL mark_needed) > { >+#ifdef NO_SYMLINK_XATTRS >+ if (S_ISLNK(file->mode)) >+ return 0; >+#endif >+ > if (preserve_xattrs) { > if (!XATTR_READY(*sxp)) > get_xattr(fname, sxp); >- if (xattr_diff(file, sxp, 0)) >+ if (xattr_diff(file, sxp, mark_needed)) > return 1; > } > >@@ -434,45 +471,17 @@ static inline int xattrs_differ(const char *fname, struct file_struct *file, sta > > int unchanged_attrs(const char *fname, struct file_struct *file, stat_x *sxp) > { >- if (S_ISLNK(file->mode)) { >-#ifdef CAN_SET_SYMLINK_TIMES >- if (preserve_times & PRESERVE_LINK_TIMES && time_differs(file, sxp)) >- return 0; >-#endif >-#ifdef CAN_CHMOD_SYMLINK >- if (perms_differ(file, sxp)) >- return 0; >-#endif >-#ifndef CAN_CHOWN_SYMLINK >- if (ownership_differs(file, sxp)) >- return 0; >-#endif >-#if defined SUPPORT_ACLS && 0 /* no current symlink-ACL support */ >- if (acls_differ(fname, file, sxp)) >- return 0; >-#endif >-#if defined SUPPORT_XATTRS && !defined NO_SYMLINK_XATTRS >- if (xattrs_differ(fname, file, sxp)) >- return 0; >-#endif >- } else { >- if (preserve_times && time_differs(file, sxp)) >- return 0; >- if (perms_differ(file, sxp)) >- return 0; >- if (ownership_differs(file, sxp)) >- return 0; >+ return !(report_time(file, sxp) >+ || report_perms(file, sxp) >+ || report_owner(file, sxp) >+ || report_group(file, sxp) > #ifdef SUPPORT_ACLS >- if (acls_differ(fname, file, sxp)) >- return 0; >+ || report_acls(fname, file, sxp) > #endif > #ifdef SUPPORT_XATTRS >- if (xattrs_differ(fname, file, sxp)) >- return 0; >+ || report_xattrs(fname, file, sxp, False) > #endif >- } >- >- return 1; >+ ); > } > > void itemize(const char *fnamecmp, struct file_struct *file, int ndx, int statret, >@@ -480,56 +489,33 @@ void itemize(const char *fnamecmp, struct file_struct *file, int ndx, int statre > const char *xname) > { > if (statret >= 0) { /* A from-dest-dir statret can == 1! */ >- int keep_time = !preserve_times ? 0 >- : S_ISDIR(file->mode) ? preserve_times & PRESERVE_DIR_TIMES >- : S_ISLNK(file->mode) ? preserve_times & PRESERVE_LINK_TIMES >- : 1; >- > if (S_ISREG(file->mode) && F_LENGTH(file) != sxp->st.st_size) > iflags |= ITEM_REPORT_SIZE; > if (file->flags & FLAG_TIME_FAILED) { /* symlinks only */ > if (iflags & ITEM_LOCAL_CHANGE) > iflags |= symlink_timeset_failed_flags; >- } else if (keep_time >+ } else if (preserve_time_of(file) > ? cmp_time(file->modtime, sxp->st.st_mtime) != 0 > : iflags & (ITEM_TRANSFER|ITEM_LOCAL_CHANGE) && !(iflags & ITEM_MATCHED) > && (!(iflags & ITEM_XNAME_FOLLOWS) || *xname)) > iflags |= ITEM_REPORT_TIME; >-#if !defined HAVE_LCHMOD && !defined HAVE_SETATTRLIST >- if (S_ISLNK(file->mode)) { >- ; >- } else >-#endif >- if (preserve_perms) { >- if (!BITS_EQUAL(sxp->st.st_mode, file->mode, CHMOD_BITS)) >- iflags |= ITEM_REPORT_PERMS; >- } else if (preserve_executability >- && ((sxp->st.st_mode & 0111 ? 1 : 0) ^ (file->mode & 0111 ? 1 : 0))) >+ if (report_perms(file, sxp)) > iflags |= ITEM_REPORT_PERMS; >- if (uid_ndx && am_root && (uid_t)F_OWNER(file) != sxp->st.st_uid) >+ if (report_owner(file, sxp)) > iflags |= ITEM_REPORT_OWNER; >- if (gid_ndx && !(file->flags & FLAG_SKIP_GROUP) >- && sxp->st.st_gid != (gid_t)F_GROUP(file)) >+ if (report_group(file, sxp)) > iflags |= ITEM_REPORT_GROUP; > #ifdef SUPPORT_ACLS >- if (preserve_acls && !S_ISLNK(file->mode)) { >- if (!ACL_READY(*sxp)) >- get_acl(fnamecmp, sxp); >- if (set_acl(NULL, file, sxp, file->mode)) >- iflags |= ITEM_REPORT_ACL; >- } >+ if (report_acls(fnamecmp, file, sxp)) >+ iflags |= ITEM_REPORT_ACL; > #endif > #ifdef SUPPORT_XATTRS >- if (preserve_xattrs) { >- if (!XATTR_READY(*sxp)) >- get_xattr(fnamecmp, sxp); >- if (xattr_diff(file, sxp, 1)) >- iflags |= ITEM_REPORT_XATTR; >- } >+ if (report_xattrs(fnamecmp, file, sxp, True)) >+ iflags |= ITEM_REPORT_XATTR; > #endif > } else { > #ifdef SUPPORT_XATTRS >- if (preserve_xattrs && xattr_diff(file, NULL, 1)) >+ if (preserve_xattrs && xattr_diff(file, NULL, True)) > iflags |= ITEM_REPORT_XATTR; > #endif > iflags |= ITEM_IS_NEW; >diff --git a/xattrs.c b/xattrs.c >index 3a7cb25..009da9b 100644 >--- a/xattrs.c >+++ b/xattrs.c >@@ -458,9 +458,9 @@ int send_xattr(int f, stat_x *sxp) > } > > /* Return a flag indicating if we need to change a file's xattrs. If >- * "find_all" is specified, also mark any abbreviated xattrs that we >+ * "mark_needed" is specified, also mark any abbreviated xattrs that we > * need so that send_xattr_request() can tell the sender about them. */ >-int xattr_diff(struct file_struct *file, stat_x *sxp, int find_all) >+int xattr_diff(struct file_struct *file, stat_x *sxp, BOOL mark_needed) > { > item_list *lst = rsync_xal_l.items; > rsync_xa *snd_rxa, *rec_rxa; >@@ -486,7 +486,8 @@ int xattr_diff(struct file_struct *file, stat_x *sxp, int find_all) > /* If the count of the sender's xattrs is different from our > * (receiver's) xattrs, the lists are not the same. */ > if (snd_cnt != rec_cnt) { >- if (!find_all) >+ if (!mark_needed) >+ /* We can return as soon as we find a difference. */ > return 1; > xattrs_equal = 0; > } >@@ -500,7 +501,7 @@ int xattr_diff(struct file_struct *file, stat_x *sxp, int find_all) > && memcmp(snd_rxa->datum + 1, rec_rxa->datum + 1, > MAX_DIGEST_LEN) == 0; > /* Flag unrequested items that we need. */ >- if (!same && find_all && snd_rxa->datum[0] == XSTATE_ABBREV) >+ if (!same && mark_needed && snd_rxa->datum[0] == XSTATE_ABBREV) > snd_rxa->datum[0] = XSTATE_TODO; > } else { > same = cmp == 0 && snd_rxa->datum_len == rec_rxa->datum_len >@@ -508,7 +509,7 @@ int xattr_diff(struct file_struct *file, stat_x *sxp, int find_all) > snd_rxa->datum_len) == 0; > } > if (!same) { >- if (!find_all) >+ if (!mark_needed) > return 1; > xattrs_equal = 0; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 7622
: 6630