+ set_next_block_after ((union block *)
+ (data_block->buffer + written - 1));
+ if (count != written)
+ {
+ if (!to_command_option)
+ write_error_details (file_name, count, written);
+ /* FIXME: shouldn't we restore from backup? */
+ break;
+ }
+ }
+
+ skip_file (size);
+
+ mv_end ();
+
+ /* 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)
+ return 0;
+
+ if (! to_command_option)
+ set_stat (file_name, ¤t_stat_info, fd,
+ current_mode, current_mode_mask, typeflag, false,
+ (old_files_option == OVERWRITE_OLD_FILES
+ ? 0 : AT_SYMLINK_NOFOLLOW));
+
+ status = close (fd);
+ if (status < 0)
+ close_error (file_name);
+
+ if (to_command_option)
+ sys_wait_command ();
+
+ return status;
+}
+
+/* Create a placeholder file with name FILE_NAME, which will be
+ replaced after other extraction is done by a symbolic link if
+ IS_SYMLINK is true, and by a hard link otherwise. Set
+ *INTERDIR_MADE if an intermediate directory is made in the
+ process. */
+
+static int
+create_placeholder_file (char *file_name, bool is_symlink, bool *interdir_made)
+{
+ int fd;
+ struct stat st;
+
+ while ((fd = openat (chdir_fd, file_name, O_WRONLY | O_CREAT | O_EXCL, 0)) < 0)
+ {
+ switch (maybe_recoverable (file_name, false, interdir_made))