X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Flist.c;h=cd63064df05b23c44b8d9c17319271cce1b6005e;hb=61f44c936102dfd397a076e749333b658973ca48;hp=cb14c79bb8ee01240844e0931185e916f9d4903d;hpb=defde325338f14d5a25d113141e8e03d19a7fbe8;p=chaz%2Ftar diff --git a/src/list.c b/src/list.c index cb14c79..cd63064 100644 --- a/src/list.c +++ b/src/list.c @@ -20,7 +20,7 @@ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Define to non-zero for forcing old ctime format instead of ISO format. */ -#undef USE_OLD_CTIME +#undef USE_OLD_CTIME #include "system.h" #include @@ -130,10 +130,20 @@ read_and (void (*do_something) (void)) } set_next_block_after (current_header); + + if (!ignore_zeros_option) + { + char buf[UINTMAX_STRSIZE_BOUND]; + + status = read_header (false); + if (status == HEADER_ZERO_BLOCK) + break; + WARN ((0, 0, _("A lone zero block at %s"), + STRINGIFY_BIGINT (current_block_ordinal (), buf))); + break; + } status = prev_status; - if (ignore_zeros_option) - continue; - break; + continue; case HEADER_END_OF_FILE: if (block_number_option) @@ -386,9 +396,13 @@ read_header (bool raw_extended_headers) *bp = '\0'; } - else if (header->header.typeflag == XHDTYPE - || header->header.typeflag == XGLTYPE) + else if (header->header.typeflag == XHDTYPE) xheader_read (header, OFF_FROM_HEADER (header->header.size)); + else if (header->header.typeflag == XGLTYPE) + { + xheader_read (header, OFF_FROM_HEADER (header->header.size)); + xheader_decode_global (); + } /* Loop! */ @@ -550,7 +564,8 @@ decode_header (union block *header, struct tar_stat_info *stat_info, { case BLKTYPE: case CHRTYPE: - stat_info->stat.st_rdev = makedev (stat_info->devmajor, stat_info->devminor); + stat_info->stat.st_rdev = makedev (stat_info->devmajor, + stat_info->devminor); break; default: @@ -558,9 +573,14 @@ decode_header (union block *header, struct tar_stat_info *stat_info, } } - current_stat_info.archive_file_size = current_stat_info.stat.st_size; - if (extended_header.size) - xheader_decode (stat_info); + stat_info->archive_file_size = stat_info->stat.st_size; + xheader_decode (stat_info); + + if (sparse_member_p (stat_info)) + { + sparse_fixup_header (stat_info); + stat_info->is_sparse = true; + } } /* Convert buffer at WHERE0 of size DIGS from external format to @@ -887,7 +907,7 @@ tartime (time_t t) #else /* Use ISO 8610 format. See: http://www.cl.cam.ac.uk/~mgk25/iso-time.html */ - struct tm *tm = localtime (&t); + struct tm *tm = utc_option ? gmtime (&t) : localtime (&t); if (tm) { sprintf (buffer, "%04ld-%02d-%02d %02d:%02d:%02d", @@ -1088,14 +1108,9 @@ print_header (struct tar_stat_info *st, off_t block_ordinal) strcat (size, STRINGIFY_BIGINT (minor (st->stat.st_rdev), uintbuf)); break; - case GNUTYPE_SPARSE: - strcpy (size, - STRINGIFY_BIGINT - (UINTMAX_FROM_HEADER (current_header - ->oldgnu_header.realsize), - uintbuf)); - break; + default: + /* st->stat.st_size keeps stored file size */ strcpy (size, STRINGIFY_BIGINT (st->stat.st_size, uintbuf)); break; } @@ -1228,20 +1243,10 @@ skip_member (void) char save_typeflag = current_header->header.typeflag; set_next_block_after (current_header); - if (current_format == OLDGNU_FORMAT - && current_header->oldgnu_header.isextended) - { - union block *exhdr; - do - { - exhdr = find_next_block (); - if (!exhdr) - FATAL_ERROR ((0, 0, _("Unexpected EOF in archive"))); - set_next_block_after (exhdr); - } - while (exhdr->sparse_header.isextended); - } + assign_string (&save_name, current_stat_info.file_name); - if (save_typeflag != DIRTYPE) + if (sparse_member_p (¤t_stat_info)) + sparse_skip_file (¤t_stat_info); + else if (save_typeflag != DIRTYPE) skip_file (current_stat_info.stat.st_size); }