Index: src/buffer.c =================================================================== RCS file: /cvsroot/tar/tar/src/buffer.c,v retrieving revision 1.72 diff -p -u -r1.72 buffer.c --- src/buffer.c 6 Sep 2004 14:28:56 -0000 1.72 +++ src/buffer.c 26 Nov 2004 16:46:32 -0000 @@ -67,11 +67,14 @@ static pid_t child_pid; static int read_error_count; /* Have we hit EOF yet? */ -static int hit_eof; +static bool hit_eof; /* Checkpointing counter */ static int checkpoint; +static bool read_full_records = false; +static bool reading_from_pipe = false; + /* We're reading, but we just read the last block and it's time to update. Declared in update.c @@ -178,7 +181,7 @@ reset_eof (void) { if (hit_eof) { - hit_eof = 0; + hit_eof = false; current_block = record_start; record_end = record_start + blocking_factor; access_mode = ACCESS_WRITE; @@ -198,7 +201,7 @@ find_next_block (void) flush_archive (); if (current_block == record_end) { - hit_eof = 1; + hit_eof = true; return 0; } } @@ -304,12 +307,16 @@ open_archive (enum access_mode wanted_ac /* When updating the archive, we start with reading. */ access_mode = wanted_access == ACCESS_UPDATE ? ACCESS_READ : wanted_access; + read_full_records = read_full_records_option; + reading_from_pipe = false; + if (use_compress_program_option) { switch (wanted_access) { case ACCESS_READ: child_pid = sys_child_open_for_uncompress (); + read_full_records = reading_from_pipe = true; break; case ACCESS_WRITE: @@ -327,7 +334,7 @@ open_archive (enum access_mode wanted_ac } else if (strcmp (archive_name_array[0], "-") == 0) { - read_full_records_option = true; /* could be a pipe, be safe */ + read_full_records = true; /* could be a pipe, be safe */ if (verify_option) FATAL_ERROR ((0, 0, _("Cannot verify stdin/stdout archive"))); @@ -544,9 +551,11 @@ flush_write (void) strncpy (record_start->header.name, real_s_name, NAME_FIELD_SIZE); record_start->header.typeflag = GNUTYPE_MULTIVOL; + OFF_TO_CHARS (real_s_sizeleft, record_start->header.size); OFF_TO_CHARS (real_s_totsize - real_s_sizeleft, record_start->oldgnu_header.offset); + tmp = verbose_option; verbose_option = 0; finish_header (¤t_stat_info, record_start, -1); @@ -630,7 +639,7 @@ short_read (size_t status) left = record_size - status; while (left % BLOCKSIZE != 0 - || (left && status && read_full_records_option)) + || (left && status && read_full_records)) { if (status) while ((status = rmtread (archive, more, left)) == SAFE_READ_ERROR) @@ -638,15 +647,18 @@ short_read (size_t status) if (status == 0) { - char buf[UINTMAX_STRSIZE_BOUND]; + if (!reading_from_pipe) + { + char buf[UINTMAX_STRSIZE_BOUND]; - WARN((0, 0, _("Read %s bytes from %s"), - STRINGIFY_BIGINT (record_size - left, buf), - *archive_name_cursor)); + WARN((0, 0, _("Read %s bytes from %s"), + STRINGIFY_BIGINT (record_size - left, buf), + *archive_name_cursor)); + } break; } - if (! read_full_records_option) + if (! read_full_records) { unsigned long rest = record_size - left; @@ -666,7 +678,7 @@ short_read (size_t status) /* FIXME: for size=0, multi-volume support. On the first record, warn about the problem. */ - if (!read_full_records_option && verbose_option > 1 + if (!read_full_records && verbose_option > 1 && record_start_block == 0 && status != 0) { unsigned long rsize = (record_size - left) / BLOCKSIZE; @@ -728,7 +740,7 @@ flush_read (void) } /* The condition below used to include - || (status > 0 && !read_full_records_option) + || (status > 0 && !read_full_records) This is incorrect since even if new_volume() succeeds, the subsequent call to rmtread will overwrite the chunk of data already read in the buffer, so the processing will fail */ @@ -1137,7 +1149,7 @@ new_volume (enum access_mode mode) if (strcmp (archive_name_cursor[0], "-") == 0) { - read_full_records_option = true; + read_full_records = true; archive = STDIN_FILENO; } else if (verify_option)