X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2Flist.c;h=869f2d0aac145b3d08aa3c7767dbf0f1bc18a95a;hb=cedd9d6e81e0d0451429c9b14b2298e419f2b052;hp=0c8095e4d991dcd426c221c52eba8c2a72e8f769;hpb=80e5de931058de5cebdf162785069ae3f8db5887;p=chaz%2Ftar diff --git a/src/list.c b/src/list.c index 0c8095e..869f2d0 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,19 @@ 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))); + } status = prev_status; - if (ignore_zeros_option) - continue; - break; + continue; case HEADER_END_OF_FILE: if (block_number_option) @@ -386,9 +395,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! */ @@ -489,8 +502,10 @@ decode_header (union block *header, struct tar_stat_info *stat_info, && ISOCTAL (header->star_header.ctime[0]) && header->star_header.ctime[11] == ' ') format = STAR_FORMAT; - else + else if (extended_header.size) format = POSIX_FORMAT; + else + format = USTAR_FORMAT; } else if (strcmp (header->header.magic, OLDGNU_MAGIC) == 0) format = OLDGNU_FORMAT; @@ -548,7 +563,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: @@ -556,8 +572,8 @@ decode_header (union block *header, struct tar_stat_info *stat_info, } } - if (extended_header.size) - xheader_decode (stat_info); + xheader_decode (stat_info); + current_stat_info.archive_file_size = current_stat_info.stat.st_size; } /* Convert buffer at WHERE0 of size DIGS from external format to @@ -884,7 +900,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", @@ -1093,7 +1109,8 @@ print_header (struct tar_stat_info *st, off_t block_ordinal) uintbuf)); break; default: - strcpy (size, STRINGIFY_BIGINT (st->stat.st_size, uintbuf)); + /* st->stat.st_size keeps stored file size */ + strcpy (size, STRINGIFY_BIGINT (st->archive_file_size, uintbuf)); break; }