(tar_get_next_block): use file descriptor from archive descriptor.

(tar_skip_n_records): likewise.
(tar_read_header): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2020-10-07 14:56:42 +03:00
parent 74c16acf6a
commit 96ebde8d68

View File

@ -602,13 +602,11 @@ uintmax_from_header (const char *p, size_t s)
/* --------------------------------------------------------------------------------------------- */
static union block *
tar_get_next_block (struct vfs_s_super *archive, int tard)
tar_get_next_block (tar_super_t * archive)
{
int n;
(void) archive;
n = mc_read (tard, block_buf.buffer, sizeof (block_buf.buffer));
n = mc_read (archive->fd, block_buf.buffer, sizeof (block_buf.buffer));
if (n != sizeof (block_buf.buffer))
return NULL; /* An error has occurred */
current_tar_position += sizeof (block_buf.buffer);
@ -618,11 +616,9 @@ tar_get_next_block (struct vfs_s_super *archive, int tard)
/* --------------------------------------------------------------------------------------------- */
static void
tar_skip_n_records (struct vfs_s_super *archive, int tard, off_t n)
tar_skip_n_records (tar_super_t * archive, off_t n)
{
(void) archive;
mc_lseek (tard, n * sizeof (block_buf.buffer), SEEK_CUR);
mc_lseek (archive->fd, n * sizeof (block_buf.buffer), SEEK_CUR);
current_tar_position += n * sizeof (block_buf.buffer);
}
@ -808,7 +804,7 @@ tar_fill_stat (struct vfs_s_super *archive, struct stat *st, union block *header
/* --------------------------------------------------------------------------------------------- */
static read_header
tar_read_header (struct vfs_class *me, struct vfs_s_super *archive, int tard, size_t * h_size)
tar_read_header (struct vfs_class *me, struct vfs_s_super *archive, size_t * h_size)
{
tar_super_t *arch = TAR_SUPER (archive);
read_header checksum_status;
@ -818,7 +814,7 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive, int tard, si
while (TRUE)
{
header = tar_get_next_block (archive, tard);
header = tar_get_next_block (arch);
if (header == NULL)
return HEADER_END_OF_FILE;
@ -868,7 +864,7 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive, int tard, si
for (size = *h_size; size > 0; size -= written)
{
data = tar_get_next_block (archive, tard)->buffer;
data = tar_get_next_block (arch)->buffer;
if (data == NULL)
{
MC_PTR_FREE (*longp);
@ -1017,7 +1013,7 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive, int tard, si
if (arch->type == TAR_GNU && header->oldgnu_header.isextended)
{
while (tar_get_next_block (archive, tard)->sparse_header.isextended != 0)
while (tar_get_next_block (arch)->sparse_header.isextended != 0)
;
if (inode != NULL)
@ -1148,7 +1144,7 @@ tar_open_archive (struct vfs_s_super *archive, const vfs_path_t * vpath,
read_header prev_status;
prev_status = status;
status = tar_read_header (vpath_element->class, archive, arch->fd, &h_size);
status = tar_read_header (vpath_element->class, archive, &h_size);
switch (status)
{
@ -1158,7 +1154,7 @@ tar_open_archive (struct vfs_s_super *archive, const vfs_path_t * vpath,
return -1;
case HEADER_SUCCESS:
tar_skip_n_records (archive, arch->fd, (h_size + BLOCKSIZE - 1) / BLOCKSIZE);
tar_skip_n_records (archive, (h_size + BLOCKSIZE - 1) / BLOCKSIZE);
continue;
/*