X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2Fbuffer.c;h=d788b167fed142a4b308413ab1a8b3fbadacf580;hb=939d63b92d23e43324ef53055f6a4027cecbe2e2;hp=9b6a11a8c6e59ba48f20d066bf355802086bc73e;hpb=588f444efea17a7746d07fbd39510ec842eb4137;p=chaz%2Ftar diff --git a/src/buffer.c b/src/buffer.c index 9b6a11a..d788b16 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -20,11 +20,13 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include +#include #include #include #include +#include #include #include @@ -42,6 +44,7 @@ static tarlong prev_written; /* bytes written on previous volumes */ static tarlong bytes_written; /* bytes written on this volume */ static void *record_buffer[2]; /* allocated memory */ +union block *record_buffer_aligned[2]; static int record_index; /* FIXME: The following variables should ideally be static to this @@ -367,10 +370,11 @@ xclose (int fd) static void init_buffer () { - if (!record_buffer[record_index]) - page_aligned_alloc (&record_buffer[record_index], record_size); + if (! record_buffer_aligned[record_index]) + record_buffer_aligned[record_index] = + page_aligned_alloc (&record_buffer[record_index], record_size); - record_start = record_buffer[record_index]; + record_start = record_buffer_aligned[record_index]; current_block = record_start; record_end = record_start + blocking_factor; } @@ -449,7 +453,7 @@ _open_archive (enum access_mode wanted_access) archive = STDIN_FILENO; - type = check_compressed_archive (archive); + type = check_compressed_archive (); if (type != ct_none) FATAL_ERROR ((0, 0, _("Archive is compressed. Use %s option"), @@ -966,6 +970,7 @@ new_volume (enum access_mode mode) { static FILE *read_file; static int looped; + int prompt; if (!read_file && !info_script_option) /* FIXME: if fopen is used, it will never be closed. */ @@ -989,9 +994,10 @@ new_volume (enum access_mode mode) archive_name_cursor = archive_name_array; looped = 1; } + prompt = looped; tryagain: - if (looped) + if (prompt) { /* We have to prompt from now on. */ @@ -1041,6 +1047,7 @@ new_volume (enum access_mode mode) open_warn (*archive_name_cursor); if (!verify_option && mode == ACCESS_WRITE && backup_option) undo_last_backup (); + prompt = 1; goto tryagain; } @@ -1050,10 +1057,12 @@ new_volume (enum access_mode mode) } static bool -read_header0 () +read_header0 (struct tar_stat_info *info) { - enum read_header rc = read_header (false); + enum read_header rc; + tar_stat_init (info); + rc = read_header_primitive (false, info); if (rc == HEADER_SUCCESS) { set_next_block_after (current_header); @@ -1068,7 +1077,8 @@ try_new_volume () { size_t status; union block *header; - + struct tar_stat_info dummy; + switch (subcommand_option) { case APPEND_SUBCOMMAND: @@ -1094,14 +1104,13 @@ try_new_volume () header = find_next_block (); if (!header) return false; + switch (header->header.typeflag) { case XGLTYPE: { - struct tar_stat_info dummy; - if (!read_header0 ()) + if (!read_header0 (&dummy)) return false; - tar_stat_init (&dummy); xheader_decode (&dummy); /* decodes values from the global header */ tar_stat_destroy (&dummy); if (!real_s_name) @@ -1115,8 +1124,9 @@ try_new_volume () } case GNUTYPE_VOLHDR: - if (!read_header0 ()) + if (!read_header0 (&dummy)) return false; + tar_stat_destroy (&dummy); assign_string (&volume_label, current_header->header.name); set_next_block_after (header); header = find_next_block (); @@ -1125,8 +1135,9 @@ try_new_volume () /* FALL THROUGH */ case GNUTYPE_MULTIVOL: - if (!read_header0 ()) + if (!read_header0 (&dummy)) return false; + tar_stat_destroy (&dummy); assign_string (&continued_file_name, current_header->header.name); continued_file_size = UINTMAX_FROM_HEADER (current_header->header.size); @@ -1144,9 +1155,19 @@ try_new_volume () if (!continued_file_name || strcmp (continued_file_name, real_s_name)) { - WARN ((0, 0, _("%s is not continued on this volume"), - quote (real_s_name))); - return false; + if ((archive_format == GNU_FORMAT || archive_format == OLDGNU_FORMAT) + && strlen (real_s_name) >= NAME_FIELD_SIZE + && strncmp (continued_file_name, real_s_name, + NAME_FIELD_SIZE) == 0) + WARN ((0, 0, + _("%s is possibly continued on this volume: header contains truncated name"), + quote (real_s_name))); + else + { + WARN ((0, 0, _("%s is not continued on this volume"), + quote (real_s_name))); + return false; + } } s = continued_file_size + continued_file_offset;