static tarlong bytes_written; /* bytes written on this volume */
static void *record_buffer[2]; /* allocated memory */
static bool record_index;
+static idx_t short_read_slop; /* excess bytes at end of short read */
/* FIXME: The following variables should ideally be static to this
module. However, this cannot be done yet. The cleanup continues! */
= (! (multi_volume_option || use_compress_program_option)
&& (seek_option < 0
? (_isrmt (archive)
- || S_ISREG (archive_stat.st_mode)
- || S_ISBLK (archive_stat.st_mode))
- : seek_option));
+ || ! (S_ISFIFO (archive_stat.st_mode)
+ || S_ISSOCK (archive_stat.st_mode)))
+ : seek_option != 0));
if (wanted_access == ACCESS_READ)
{
- if (archive == STDIN_FILENO && seekable_archive)
+ if (seekable_archive)
{
- start_offset = lseek (archive, 0, SEEK_CUR);
- if (start_offset == -1)
+ start_offset = (lseek (archive, 0, SEEK_CUR)
+ - (record_end - record_start) * BLOCKSIZE
+ - short_read_slop);
+ if (start_offset < 0)
seekable_archive = false;
- else
- start_offset -= (record_end - record_start) * BLOCKSIZE;
}
- else
- start_offset = 0;
}
else
sys_detect_dev_null_output ();
paxfatal (0, ngettext ("Unaligned block (%td byte) in archive",
"Unaligned block (%td bytes) in archive",
- rest),
+ rest),
rest);
}
}
record_end = record_start + (record_size - left) / BLOCKSIZE;
+ short_read_slop = (record_size - left) % BLOCKSIZE;
records_read++;
}
< 0)
archive_read_error ();
+ short_read_slop = 0;
if (status != record_size)
short_read (status);
ptrdiff_t nread;
while ((nread = rmtread (archive, record_start->buffer, record_size)) < 0)
archive_read_error ();
+ short_read_slop = 0;
if (nread == record_size)
records_read++;
else
/* Necessary for blocking_factor == 1 */
flush_archive ();
}
- else if (nread == record_size)
- records_read++;
else
- short_read (nread);
+ {
+ short_read_slop = 0;
+ if (nread == record_size)
+ records_read++;
+ else
+ short_read (nread);
+ }
}
static void