- if (info_script_option)
- {
- if (volno_file_option)
- closeout_volume_number ();
- system (info_script_option);
- }
- else
- while (1)
- {
- char input_buffer[80];
-
- fputc ('\007', stderr);
- fprintf (stderr,
- _("Prepare volume #%d for %s and hit return: "),
- global_volno, *archive_name_cursor);
- fflush (stderr);
-
- if (fgets (input_buffer, sizeof (input_buffer), read_file) == 0)
- {
- fprintf (stderr, _("EOF where user reply was expected"));
-
- if (subcommand_option != EXTRACT_SUBCOMMAND
- && subcommand_option != LIST_SUBCOMMAND
- && subcommand_option != DIFF_SUBCOMMAND)
- WARN ((0, 0, _("WARNING: Archive is incomplete")));
-
- exit (TAREXIT_FAILURE);
- }
- if (input_buffer[0] == '\n'
- || input_buffer[0] == 'y'
- || input_buffer[0] == 'Y')
- break;
-
- switch (input_buffer[0])
- {
- case '?':
- {
- fprintf (stderr, _("\
- n [name] Give a new file name for the next (and subsequent) volume(s)\n\
- q Abort tar\n\
- ! Spawn a subshell\n\
- ? Print this list\n"));
- }
- break;
-
- case 'q':
- /* Quit. */
-
- fprintf (stdlis, _("No new volume; exiting.\n"));
-
- if (subcommand_option != EXTRACT_SUBCOMMAND
- && subcommand_option != LIST_SUBCOMMAND
- && subcommand_option != DIFF_SUBCOMMAND)
- WARN ((0, 0, _("WARNING: Archive is incomplete")));
-
- exit (TAREXIT_FAILURE);
-
- case 'n':
- /* Get new file name. */
-
- {
- char *name = &input_buffer[1];
- char *cursor;
-
- while (*name == ' ' || *name == '\t')
- name++;
- cursor = name;
- while (*cursor && *cursor != '\n')
- cursor++;
- *cursor = '\0';
-
- /* FIXME: the following allocation is never reclaimed. */
- *archive_name_cursor = xstrdup (name);
- }
- break;
-
- case '!':
-#if MSDOS
- spawnl (P_WAIT, getenv ("COMSPEC"), "-", 0);
-#else /* not MSDOS */
- switch (fork ())
- {
- case -1:
- WARN ((0, errno, _("Cannot fork!")));
- break;
-
- case 0:
- {
- const char *shell = getenv ("SHELL");
-
- if (shell == NULL)
- shell = "/bin/sh";
- execlp (shell, "-sh", "-i", 0);
- FATAL_ERROR ((0, errno, _("Cannot exec a shell %s"),
- shell));
- }
-
- default:
- {
- WAIT_T wait_status;
-
- wait (&wait_status);
- }
- break;
- }
-
- /* FIXME: I'm not sure if that's all that has to be done
- here. (jk) */
-
-#endif /* not MSDOS */
- break;
- }
- }
+ if (map)
+ add_multi_volume_header (map);
+
+ write_extended (true, &dummy, find_next_block ());
+ tar_stat_destroy (&dummy);
+
+ if (map)
+ add_chunk_header (map);
+ header = find_next_block ();
+ bufmap_reset (map, header - record_start);
+ bufsize = available_space_after (header);
+ inhibit_map = 0;
+ while (bufsize < copy_size)
+ {
+ memcpy (header->buffer, copy_ptr, bufsize);
+ copy_ptr += bufsize;
+ copy_size -= bufsize;
+ set_next_block_after (header + (bufsize - 1) / BLOCKSIZE);
+ header = find_next_block ();
+ bufsize = available_space_after (header);