- ERROR ((0, errno, _("%s: Could not create symlink to `%s'"),
- CURRENT_FILE_NAME, current_link_name));
- if (backup_option)
- undo_last_backup ();
+ /* 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
+ {
+ size_t filelen = strlen (CURRENT_FILE_NAME);
+ size_t linklen = strlen (current_link_name);
+ struct delayed_symlink *p =
+ xmalloc (sizeof *p + filelen + linklen + 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;
+ memcpy (p->names, CURRENT_FILE_NAME, filelen + 1);
+ memcpy (p->names + filelen + 1, current_link_name, linklen + 1);
+ status = 0;
+ }