+ if (multi_volume_option)
+ assign_string (&save_name, 0);
+
+ /* If writing to stdout, don't try to do anything to the filename;
+ it doesn't exist, or we don't want to touch it anyway. */
+
+ if (to_stdout_option)
+ break;
+
+ status = close (fd);
+ if (status < 0)
+ {
+ close_error (CURRENT_FILE_NAME);
+ if (backup_option)
+ undo_last_backup ();
+ }
+
+ set_stat (CURRENT_FILE_NAME, ¤t_stat, 0, 0,
+ (old_files_option == OVERWRITE_OLD_FILES
+ ? UNKNOWN_PERMSTATUS
+ : ARCHIVED_PERMSTATUS),
+ typeflag);
+ break;
+
+ case SYMTYPE:
+#ifdef HAVE_SYMLINK
+ if (! prepare_to_extract (CURRENT_FILE_NAME))
+ break;
+
+ if (absolute_names_option
+ || ! (ISSLASH (current_link_name
+ [FILESYSTEM_PREFIX_LEN (current_link_name)])
+ || contains_dot_dot (current_link_name)))
+ {
+ while (status = symlink (current_link_name, CURRENT_FILE_NAME),
+ status != 0)
+ if (!maybe_recoverable (CURRENT_FILE_NAME, &interdir_made))
+ break;
+
+ if (status == 0)
+ set_stat (CURRENT_FILE_NAME, ¤t_stat, 0, 0, 0, SYMTYPE);
+ else
+ symlink_error (current_link_name, CURRENT_FILE_NAME);
+ }
+ else
+ {
+ /* This symbolic link is potentially dangerous. Don't
+ create it now; instead, create a placeholder file, which
+ will be replaced after other extraction is done. */
+ struct stat st;
+
+ while (fd = open (CURRENT_FILE_NAME, O_WRONLY | O_CREAT | O_EXCL, 0),
+ fd < 0)
+ if (! maybe_recoverable (CURRENT_FILE_NAME, &interdir_made))
+ break;
+
+ status = -1;
+ if (fd < 0)
+ open_error (CURRENT_FILE_NAME);
+ else if (fstat (fd, &st) != 0)
+ {
+ stat_error (CURRENT_FILE_NAME);
+ close (fd);
+ }
+ else if (close (fd) != 0)
+ close_error (CURRENT_FILE_NAME);
+ else
+ {
+ struct delayed_set_stat *h;
+ struct delayed_symlink *p =
+ xmalloc (offsetof (struct delayed_symlink, target)
+ + strlen (current_link_name) + 1);
+ p->next = delayed_symlink_head;
+ delayed_symlink_head = p;
+ p->dev = st.st_dev;
+ p->ino = st.st_ino;
+ p->mtime = st.st_mtime;
+ p->uid = current_stat.st_uid;
+ p->gid = current_stat.st_gid;
+ p->sources = xmalloc (offsetof (struct string_list, string)
+ + strlen (CURRENT_FILE_NAME) + 1);
+ p->sources->next = 0;
+ strcpy (p->sources->string, CURRENT_FILE_NAME);
+ strcpy (p->target, current_link_name);
+
+ h = delayed_set_stat_head;
+ if (h && ! h->after_symlinks
+ && strncmp (CURRENT_FILE_NAME, h->file_name, h->file_name_len) == 0
+ && ISSLASH (CURRENT_FILE_NAME[h->file_name_len])
+ && (base_name (CURRENT_FILE_NAME)
+ == CURRENT_FILE_NAME + h->file_name_len + 1))
+ {
+ do
+ {
+ h->after_symlinks = 1;
+
+ if (stat (h->file_name, &st) != 0)
+ stat_error (h->file_name);
+ else
+ {
+ h->stat_info.st_dev = st.st_dev;
+ h->stat_info.st_ino = st.st_ino;
+ }
+ }
+ while ((h = h->next) && ! h->after_symlinks);
+ }
+
+ status = 0;
+ }
+ }
+
+ if (status != 0 && backup_option)
+ undo_last_backup ();
+ break;
+
+#else
+ {
+ static int warned_once;
+
+ if (!warned_once)
+ {
+ warned_once = 1;
+ WARN ((0, 0,
+ _("Attempting extraction of symbolic links as hard links")));
+ }
+ }
+ typeflag = LNKTYPE;
+ /* Fall through. */