-#ifdef SUPPORT_HARD_LINKS
- int head;
- if (skip && !(file->flags & FLAG_HLINK_EOL))
- head = hlink_list[file->F_HLINDEX] = file->F_NEXT;
- else
- head = hlink_list[file->F_HLINDEX];
- if (ndx != head) {
- struct file_struct *head_file = FPTR(head);
- if (!log_format_has_i && verbose > 1) {
- rprintf(FINFO, "\"%s\" is a hard link\n",
- safe_fname(f_name(file)));
- }
- if (head_file->F_HLINDEX == FINISHED_LINK) {
- STRUCT_STAT st2;
- char *toname = f_name(head_file);
- if (link_stat(toname, &st2, 0) < 0) {
- rsyserr(FERROR, errno, "stat %s failed",
- full_fname(toname));
- return -1;
+ struct file_list *flist = flist_for_ndx(prev_ndx);
+ struct ht_int32_node *node;
+
+ if (flist) {
+ hlink_flist = flist;
+ return NULL;
+ }
+
+ node = hashtable_find(prior_hlinks, gnum, 0);
+ assert(node != NULL && node->data);
+ assert(CVAL(node->data, 0) != 0);
+ return node->data;
+}
+
+/* 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, statx *sxp, int itemizing,
+ enum logcode code)
+{
+ STRUCT_STAT prev_st;
+ char namebuf[MAXPATHLEN], altbuf[MAXPATHLEN];
+ char *realname, *prev_name;
+ int gnum = F_HL_GNUM(file);
+ int prev_ndx = F_HL_PREV(file);
+
+ prev_name = realname = check_prior(prev_ndx, gnum);
+
+ if (!prev_name) {
+ struct file_struct *prev_file = hlink_flist->files[prev_ndx - hlink_flist->ndx_start];
+
+ /* Is the previous link is 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;