+
+ return 0;
+ }
+
+ return -1;
+}
+
+static int
+extract_link (char *file_name, int typeflag)
+{
+ bool interdir_made = false;
+ char const *link_name;
+ int rc;
+
+ link_name = current_stat_info.link_name;
+
+ if (! absolute_names_option && contains_dot_dot (link_name))
+ return create_placeholder_file (file_name, false, &interdir_made);
+
+ do
+ {
+ struct stat st1, st2;
+ int e;
+ int status = link (link_name, file_name);
+ e = errno;
+
+ if (status == 0)
+ {
+ struct delayed_link *ds = delayed_link_head;
+ if (ds && lstat (link_name, &st1) == 0)
+ for (; ds; ds = ds->next)
+ if (ds->dev == st1.st_dev
+ && ds->ino == st1.st_ino
+ && timespec_cmp (ds->mtime, get_stat_mtime (&st1)) == 0)
+ {
+ struct string_list *p = xmalloc (offsetof (struct string_list, string)
+ + strlen (file_name) + 1);
+ strcpy (p->string, file_name);
+ p->next = ds->sources;
+ ds->sources = p;
+ break;
+ }
+ return 0;
+ }
+ else if ((e == EEXIST && strcmp (link_name, file_name) == 0)
+ || (lstat (link_name, &st1) == 0
+ && lstat (file_name, &st2) == 0
+ && st1.st_dev == st2.st_dev
+ && st1.st_ino == st2.st_ino))
+ return 0;
+
+ errno = e;
+ }
+ while ((rc = maybe_recoverable (file_name, &interdir_made)) == RECOVER_OK);
+
+ if (rc == RECOVER_SKIP)
+ return 0;
+ if (!(incremental_option && errno == EEXIST))
+ {
+ link_error (link_name, file_name);
+ return 1;
+ }
+ return 0;
+}
+
+static int
+extract_symlink (char *file_name, int typeflag)
+{
+#ifdef HAVE_SYMLINK
+ bool interdir_made = false;
+
+ if (! absolute_names_option
+ && (IS_ABSOLUTE_FILE_NAME (current_stat_info.link_name)
+ || contains_dot_dot (current_stat_info.link_name)))
+ return create_placeholder_file (file_name, true, &interdir_made);
+
+ while (symlink (current_stat_info.link_name, file_name))
+ switch (maybe_recoverable (file_name, &interdir_made))
+ {
+ case RECOVER_OK:
+ continue;
+
+ case RECOVER_SKIP:
+ return 0;
+
+ case RECOVER_NO:
+ symlink_error (current_stat_info.link_name, file_name);
+ return -1;
+ }
+
+ set_stat (file_name, ¤t_stat_info, NULL, 0, 0, SYMTYPE);
+ return 0;