- if (head_file->F_HLINDEX == FINISHED_LINK) {
- STRUCT_STAT st2, st3;
- char *toname = f_name(head_file, NULL);
- if (link_stat(toname, &st2, 0) < 0) {
- rsyserr(FERROR, errno, "stat %s failed",
- full_fname(toname));
- return -1;
- }
- if (statret < 0 && basis_dir[0] != NULL) {
- char cmpbuf[MAXPATHLEN];
- int j = 0;
- do {
- pathjoin(cmpbuf, MAXPATHLEN, basis_dir[j], fname);
- if (link_stat(cmpbuf, &st3, 0) < 0)
- continue;
- if (link_dest) {
- if (st2.st_dev != st3.st_dev
- || st2.st_ino != st3.st_ino)
- continue;
- statret = 1;
- st = &st3;
- if (verbose < 2 || !stdout_format_has_i)
- itemizing = code = 0;
- break;
- }
- if (!unchanged_file(cmpbuf, file, &st3))
- continue;
- statret = 1;
- st = &st3;
- if (unchanged_attrs(file, &st3))
- break;
- } while (basis_dir[++j] != NULL);
+ F_HL_PREV(file) = prev_ndx = F_HL_PREV(fp);
+ }
+
+ if (inc_recurse
+ && (node = hashtable_find(prior_hlinks, gnum, 0)) != NULL) {
+ assert(node->data != NULL);
+ if (CVAL(node->data, 0) != 0) {
+ *prev_ndx_p = -1;
+ *flist_p = NULL;
+ return node->data;
+ }
+ /* The prior file must have been skipped. */
+ F_HL_PREV(file) = -1;
+ }
+
+ *prev_ndx_p = -1;
+ *flist_p = NULL;
+ return NULL;
+}
+
+/* Only called if FLAG_HLINKED is set and FLAG_HLINK_FIRST is not. Returns:
+ * 0 = process the file, 1 = skip the file, -1 = error occurred. */
+int hard_link_check(struct file_struct *file, int ndx, const char *fname,
+ int statret, stat_x *sxp, int itemizing,
+ enum logcode code)
+{
+ STRUCT_STAT prev_st;
+ char namebuf[MAXPATHLEN], altbuf[MAXPATHLEN];
+ char *realname, *prev_name;
+ struct file_list *flist;
+ int gnum = inc_recurse ? F_HL_GNUM(file) : -1;
+ int prev_ndx;
+
+ prev_name = realname = check_prior(file, gnum, &prev_ndx, &flist);
+
+ if (!prev_name) {
+ struct file_struct *prev_file;
+
+ if (!flist) {
+ /* The previous file was skipped, so this one is
+ * treated as if it were the first in its group. */
+ return 0;
+ }
+
+ prev_file = flist->files[prev_ndx - flist->ndx_start];
+
+ /* Is the previous link not complete yet? */
+ if (!(prev_file->flags & FLAG_HLINK_DONE)) {
+ /* Is the previous link being transferred? */
+ if (prev_file->flags & FLAG_FILE_SENT) {
+ /* Add ourselves to the list of files that will
+ * be updated when the transfer completes, and
+ * mark ourself as waiting for the transfer. */
+ F_HL_PREV(file) = F_HL_PREV(prev_file);
+ F_HL_PREV(prev_file) = ndx;
+ file->flags |= FLAG_FILE_SENT;
+ cur_flist->in_progress++;
+ return 1;