[SCM] The rsync repository. - branch master updated
Rsync CVS commit messages
rsync-cvs at lists.samba.org
Sat Jan 19 11:32:05 MST 2013
The branch, master has been updated
via bd7d36c Free ACL/xattr info in try_dests_reg() loop.
via d42e718 Add free_stat_x() inline function.
via c03bb3d Further improve non-empty-destination --link-dest behavior: - Avoid relinking a file that is already linked correctly. - Avoid trashing the stat buffer of an existing file in try_dests_reg().
via cee3264 Remove -3 return from try_dests_reg() again -- let it do a local copy when the dest file is unlinked and the hard link fails.
from 0ae9256 Align fileio's map_ptr() reads. Fixes bug 8177.
;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit bd7d36cc6c85b821a772b54377654d3a3d1535f4
Author: Wayne Davison <wayned at samba.org>
Date: Sat Jan 19 10:20:49 2013 -0800
Free ACL/xattr info in try_dests_reg() loop.
commit d42e7181d5d864767a893e88628d97470caa5c0a
Author: Wayne Davison <wayned at samba.org>
Date: Sat Jan 19 10:20:49 2013 -0800
Add free_stat_x() inline function.
commit c03bb3d181b300a30a45e043d5aa075af5e8e3f8
Author: Wayne Davison <wayned at samba.org>
Date: Sat Jan 19 09:52:56 2013 -0800
Further improve non-empty-destination --link-dest behavior:
- Avoid relinking a file that is already linked correctly.
- Avoid trashing the stat buffer of an existing file in try_dests_reg().
commit cee326436c5f2b41c2f10e4e1176cca0a786a368
Author: Wayne Davison <wayned at samba.org>
Date: Sat Jan 19 09:08:36 2013 -0800
Remove -3 return from try_dests_reg() again -- let it do a local copy
when the dest file is unlinked and the hard link fails.
-----------------------------------------------------------------------
Summary of changes:
generator.c | 50 ++++++++++++++++++++------------------------------
hlink.c | 21 +++------------------
ifuncs.h | 14 ++++++++++++++
rsync.c | 12 ++----------
4 files changed, 39 insertions(+), 58 deletions(-)
Changeset truncated at 500 lines:
diff --git a/generator.c b/generator.c
index f95e57f..25435af 100644
--- a/generator.c
+++ b/generator.c
@@ -847,12 +847,12 @@ static int copy_altdest_file(const char *src, const char *dest, struct file_stru
* value if we found an alternate basis file. If we're called with the
* find_exact_for_existing flag, the destination file already exists, so
* we only try to find an exact alt-dest match. In this case, the returns
- * can be -2 & -1 (both as above) as well as -3, which means that we
- * removed the dest file but failed to create a hard link for it. */
+ * are only -2 & -1 (both as above). */
static int try_dests_reg(struct file_struct *file, char *fname, int ndx,
char *cmpbuf, stat_x *sxp, int find_exact_for_existing,
int itemizing, enum logcode code)
{
+ STRUCT_STAT real_st = sxp->st;
int best_match = -1;
int match_level = 0;
int j = 0;
@@ -873,8 +873,10 @@ static int try_dests_reg(struct file_struct *file, char *fname, int ndx,
match_level = 2;
/* FALL THROUGH */
case 2:
- if (!unchanged_attrs(cmpbuf, file, sxp))
+ if (!unchanged_attrs(cmpbuf, file, sxp)) {
+ free_stat_x(sxp);
continue;
+ }
best_match = j;
match_level = 3;
break;
@@ -894,16 +896,17 @@ static int try_dests_reg(struct file_struct *file, char *fname, int ndx,
if (match_level == 3 && !copy_dest) {
if (find_exact_for_existing) {
- if (do_unlink(fname) < 0 && errno != ENOENT)
+ if (link_dest && real_st.st_dev == sxp->st.st_dev && real_st.st_ino == sxp->st.st_ino)
+ return -1;
+ if (do_unlink(fname) < 0 && errno != ENOENT) {
+ sxp->st = real_st;
return -1;
+ }
}
#ifdef SUPPORT_HARD_LINKS
if (link_dest) {
- if (!hard_link_one(file, fname, cmpbuf, 1)) {
- if (find_exact_for_existing)
- return -3;
+ if (!hard_link_one(file, fname, cmpbuf, 1))
goto try_a_copy;
- }
if (preserve_hard_links && F_IS_HLINKED(file))
finish_hard_link(file, fname, ndx, &sxp->st, itemizing, code, j);
if (!maybe_ATTRS_REPORT && (INFO_GTE(NAME, 2) || stdout_format_has_i > 1)) {
@@ -922,15 +925,20 @@ static int try_dests_reg(struct file_struct *file, char *fname, int ndx,
return -2;
}
- if (find_exact_for_existing)
+ if (find_exact_for_existing) {
+ sxp->st = real_st;
return -1;
+ }
if (match_level >= 2) {
#ifdef SUPPORT_HARD_LINKS
try_a_copy: /* Copy the file locally. */
#endif
- if (!dry_run && copy_altdest_file(cmpbuf, fname, file) < 0)
+ if (!dry_run && copy_altdest_file(cmpbuf, fname, file) < 0) {
+ if (find_exact_for_existing) /* Can get here via hard-link failure */
+ sxp->st = real_st;
return -1;
+ }
if (itemizing)
itemize(cmpbuf, file, ndx, 0, sxp, ITEM_LOCAL_CHANGE, 0, NULL);
if (maybe_ATTRS_REPORT
@@ -1668,9 +1676,6 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
fnamecmp = fnamecmpbuf;
fnamecmp_type = j;
statret = 0;
- } else if (j == -3) {
- statret = -1;
- stat_errno = ENOENT;
}
}
@@ -1850,14 +1855,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
iflags |= ITEM_XNAME_FOLLOWS;
itemize(fnamecmp, file, -1, real_ret, &real_sx, iflags, fnamecmp_type,
fuzzy_file ? fuzzy_file->basename : NULL);
-#ifdef SUPPORT_ACLS
- if (preserve_acls)
- free_acl(&real_sx);
-#endif
-#ifdef SUPPORT_XATTRS
- if (preserve_xattrs)
- free_xattr(&real_sx);
-#endif
+ free_stat_x(&real_sx);
}
if (!do_xfers) {
@@ -1905,15 +1903,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
unmake_file(back_file);
}
-#ifdef SUPPORT_ACLS
- if (preserve_acls)
- free_acl(&sx);
-#endif
-#ifdef SUPPORT_XATTRS
- if (preserve_xattrs)
- free_xattr(&sx);
-#endif
- return;
+ free_stat_x(&sx);
}
/* If we are replacing an existing hard link, symlink, device, or special file,
diff --git a/hlink.c b/hlink.c
index f192e3a..3ecc52b 100644
--- a/hlink.c
+++ b/hlink.c
@@ -441,16 +441,8 @@ int hard_link_check(struct file_struct *file, int ndx, char *fname,
}
}
#endif
- } else {
-#ifdef SUPPORT_ACLS
- if (preserve_acls)
- free_acl(&alt_sx);
-#endif
-#ifdef SUPPORT_XATTRS
- if (preserve_xattrs)
- free_xattr(&alt_sx);
-#endif
- }
+ } else
+ free_stat_x(&alt_sx);
}
if (maybe_hard_link(file, ndx, fname, statret, sxp, prev_name, &prev_st,
@@ -527,14 +519,7 @@ void finish_hard_link(struct file_struct *file, const char *fname, int fin_ndx,
val = maybe_hard_link(file, ndx, prev_name, prev_statret, &prev_sx,
our_name, stp, fname, itemizing, code);
flist->in_progress--;
-#ifdef SUPPORT_ACLS
- if (preserve_acls)
- free_acl(&prev_sx);
-#endif
-#ifdef SUPPORT_XATTRS
- if (preserve_xattrs)
- free_xattr(&prev_sx);
-#endif
+ free_stat_x(&prev_sx);
if (val < 0)
continue;
if (remove_source_files == 1 && do_xfers)
diff --git a/ifuncs.h b/ifuncs.h
index 656597e..4e031ae 100644
--- a/ifuncs.h
+++ b/ifuncs.h
@@ -85,3 +85,17 @@ init_stat_x(stat_x *sx_p)
sx_p->xattr = NULL;
#endif
}
+
+static inline void
+free_stat_x(stat_x *sx_p)
+{
+ extern int preserve_acls, preserve_xattrs;
+#ifdef SUPPORT_ACLS
+ if (preserve_acls)
+ free_acl(sx_p);
+#endif
+#ifdef SUPPORT_XATTRS
+ if (preserve_xattrs)
+ free_xattr(sx_p);
+#endif
+}
diff --git a/rsync.c b/rsync.c
index 93f6b98..4868a19 100644
--- a/rsync.c
+++ b/rsync.c
@@ -587,16 +587,8 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
rprintf(FCLIENT, "%s is uptodate\n", fname);
}
cleanup:
- if (sxp == &sx2) {
-#ifdef SUPPORT_ACLS
- if (preserve_acls)
- free_acl(&sx2);
-#endif
-#ifdef SUPPORT_XATTRS
- if (preserve_xattrs)
- free_xattr(&sx2);
-#endif
- }
+ if (sxp == &sx2)
+ free_stat_x(&sx2);
return updated;
}
--
The rsync repository.
More information about the rsync-cvs
mailing list