Avoid an dry-run error trying to stat a prior hard-link
authorWayne Davison <wayned@samba.org>
Sat, 5 Sep 2009 15:16:22 +0000 (08:16 -0700)
committerWayne Davison <wayned@samba.org>
Sat, 5 Sep 2009 15:18:35 +0000 (08:18 -0700)
file that hasn't really been created.

hlink.c

diff --git a/hlink.c b/hlink.c
index 291c5ce..70f9d8c 100644 (file)
--- a/hlink.c
+++ b/hlink.c
@@ -377,9 +377,13 @@ int hard_link_check(struct file_struct *file, int ndx, char *fname,
        }
 
        if (link_stat(prev_name, &prev_st, 0) < 0) {
-               rsyserr(FERROR_XFER, errno, "stat %s failed",
-                       full_fname(prev_name));
-               return -1;
+               if (!dry_run || errno != ENOENT) {
+                       rsyserr(FERROR_XFER, errno, "stat %s failed", full_fname(prev_name));
+                       return -1;
+               }
+               /* A new hard-link will get a new dev & inode, so approximate
+                * those values in dry-run mode by zeroing them. */
+               memset(&prev_st, 0, sizeof prev_st);
        }
 
        if (statret < 0 && basis_dir[0] != NULL) {