-#ifdef SUPPORT_HARD_LINKS
- char hlink1[MAXPATHLEN];
- char *hlink2;
- STRUCT_STAT st1, st2;
- int statret, ndx = master;
-
- if (link_stat(f_name_to(file, hlink1), &st1, 0) < 0)
- return;
- if (!(file->flags & FLAG_HLINK_TOL)) {
- while (!(file->flags & FLAG_HLINK_EOL)) {
- ndx = file->F_NEXT;
- file = FPTR(ndx);
- }
- }
- do {
- ndx = file->F_NEXT;
- file = FPTR(ndx);
- if (ndx == master)
- continue;
- hlink2 = f_name(file);
- if ((statret = link_stat(hlink2, &st2, 0)) == 0) {
- if (st2.st_dev == st1.st_dev
- && st2.st_ino == st1.st_ino) {
- if (itemizing) {
- itemize(file, ndx, statret, &st2,
- ITEM_LOCAL_CHANGE | ITEM_XNAME_FOLLOWS,
- 0, "");
+ 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. */
+ if (DEBUG_GTE(HLINK, 2)) {
+ rprintf(FINFO, "hlink for %d (%s,%d): virtual first\n",
+ ndx, f_name(file, NULL), gnum);
+ }
+ 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++;
+ if (DEBUG_GTE(HLINK, 2)) {
+ rprintf(FINFO, "hlink for %d (%s,%d): waiting for %d\n",
+ ndx, f_name(file, NULL), gnum, F_HL_PREV(file));