1 /* List a tar archive, with support routines for reading a tar archive.
2 Copyright 1988,92,93,94,96,97,98,1999 Free Software Foundation, Inc.
3 Written by John Gilmore, on 1985-08-26.
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 2, or (at your option) any later
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
13 Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19 /* Define to non-zero for forcing old ctime() instead of isotime(). */
29 union block
*current_header
; /* points to current archive header */
30 struct stat current_stat
; /* stat struct corresponding */
31 enum archive_format current_format
; /* recognized format */
33 static uintmax_t from_chars
PARAMS ((const char *, size_t, const char *,
34 uintmax_t, uintmax_t));
36 /* Table of base 64 digit values indexed by unsigned chars.
37 The value is 64 for unsigned chars that are not base 64 digits. */
38 static char base64_map
[1 + (unsigned char) -1];
44 memset (base64_map
, 64, sizeof base64_map
);
45 for (i
= 0; i
< 64; i
++)
46 base64_map
[(int) base_64_digits
[i
]] = i
;
49 /*-----------------------------------.
50 | Main loop for reading an archive. |
51 `-----------------------------------*/
54 read_and (void (*do_something
) ())
56 enum read_header status
= HEADER_STILL_UNREAD
;
57 enum read_header prev_status
;
61 open_archive (ACCESS_READ
);
66 status
= read_header ();
69 case HEADER_STILL_UNREAD
:
74 /* Valid header. We should decode next field (mode) first.
75 Ensure incoming names are null terminated. */
77 /* FIXME: This is a quick kludge before 1.12 goes out. */
79 = TIME_FROM_CHARS (current_header
->header
.mtime
);
81 if (!name_match (current_file_name
)
82 || current_stat
.st_mtime
< newer_mtime_option
83 || excluded_name (current_file_name
))
87 if (current_header
->header
.typeflag
== GNUTYPE_VOLHDR
88 || current_header
->header
.typeflag
== GNUTYPE_MULTIVOL
89 || current_header
->header
.typeflag
== GNUTYPE_NAMES
)
94 if (show_omitted_dirs_option
95 && current_header
->header
.typeflag
== DIRTYPE
)
96 WARN ((0, 0, _("Omitting %s"), current_file_name
));
98 /* Skip past it in the archive. */
100 save_typeflag
= current_header
->header
.typeflag
;
101 set_next_block_after (current_header
);
102 if (current_header
->oldgnu_header
.isextended
)
103 skip_extended_headers ();
105 /* Skip to the next header on the archive. */
107 if (save_typeflag
!= DIRTYPE
)
108 skip_file (current_stat
.st_size
);
115 case HEADER_ZERO_BLOCK
:
116 if (block_number_option
)
118 char buf
[UINTMAX_STRSIZE_BOUND
];
119 fprintf (stdlis
, _("block %s: ** Block of NULs **\n"),
120 STRINGIFY_BIGINT (current_block_ordinal (), buf
));
123 set_next_block_after (current_header
);
124 status
= prev_status
;
125 if (ignore_zeros_option
)
129 case HEADER_END_OF_FILE
:
130 if (block_number_option
)
132 char buf
[UINTMAX_STRSIZE_BOUND
];
133 fprintf (stdlis
, _("block %s: ** End of File **\n"),
134 STRINGIFY_BIGINT (current_block_ordinal (), buf
));
139 /* If the previous header was good, tell them that we are
140 skipping bad ones. */
141 set_next_block_after (current_header
);
144 case HEADER_STILL_UNREAD
:
145 WARN ((0, 0, _("Hmm, this doesn't look like a tar archive")));
148 case HEADER_ZERO_BLOCK
:
150 WARN ((0, 0, _("Skipping to next file header")));
153 case HEADER_END_OF_FILE
:
155 /* We are in the middle of a cascade of errors. */
163 apply_delayed_set_stat ();
165 names_notfound (); /* print names not found */
168 /*---------------------------------------------.
169 | Print a header block, based on tar options. |
170 `---------------------------------------------*/
175 /* Print the header block. */
179 if (verbose_option
> 1)
180 decode_header (current_header
, ¤t_stat
, ¤t_format
, 0);
184 if (incremental_option
&& current_header
->header
.typeflag
== GNUTYPE_DUMPDIR
)
187 size_t written
, check
;
188 union block
*data_block
;
190 set_next_block_after (current_header
);
191 if (multi_volume_option
)
193 assign_string (&save_name
, current_file_name
);
194 save_totsize
= current_stat
.st_size
;
196 for (size
= current_stat
.st_size
; size
> 0; size
-= written
)
198 if (multi_volume_option
)
199 save_sizeleft
= size
;
200 data_block
= find_next_block ();
203 ERROR ((0, 0, _("EOF in archive file")));
204 break; /* FIXME: What happens, then? */
206 written
= available_space_after (data_block
);
209 errno
= 0; /* FIXME: errno should be read-only */
210 check
= fwrite (data_block
->buffer
, sizeof (char), written
, stdlis
);
211 set_next_block_after ((union block
*)
212 (data_block
->buffer
+ written
- 1));
213 if (check
!= written
)
215 ERROR ((0, errno
, _("Only wrote %lu of %lu bytes to file %s"),
216 (unsigned long) check
,
217 (unsigned long) written
, current_file_name
));
218 skip_file (size
- written
);
222 if (multi_volume_option
)
223 assign_string (&save_name
, NULL
);
224 fputc ('\n', stdlis
);
230 /* Skip past the header in the archive, and past any extended headers. */
232 set_next_block_after (current_header
);
233 if (current_header
->oldgnu_header
.isextended
)
234 skip_extended_headers ();
236 if (multi_volume_option
)
237 assign_string (&save_name
, current_file_name
);
239 /* Skip to the next header on the archive. */
241 skip_file (current_stat
.st_size
);
243 if (multi_volume_option
)
244 assign_string (&save_name
, NULL
);
247 /*-----------------------------------------------------------------------.
248 | Read a block that's supposed to be a header block. Return its address |
249 | in "current_header", and if it is good, the file's size in |
250 | current_stat.st_size. |
252 | Return 1 for success, 0 if the checksum is bad, EOF on eof, 2 for a |
253 | block full of zeros (EOF marker). |
255 | You must always set_next_block_after(current_header) to skip past the |
256 | header which this routine reads. |
257 `-----------------------------------------------------------------------*/
259 /* The standard BSD tar sources create the checksum by adding up the
260 bytes in the header as type char. I think the type char was unsigned
261 on the PDP-11, but it's signed on the Next and Sun. It looks like the
262 sources to BSD tar were never changed to compute the checksum
263 currectly, so both the Sun and Next add the bytes of the header as
264 signed chars. This doesn't cause a problem until you get a file with
265 a name containing characters with the high bit set. So read_header
266 computes two checksums -- signed and unsigned. */
272 int unsigned_sum
; /* the POSIX one :-) */
273 int signed_sum
; /* the Sun one :-( */
275 uintmax_t parsed_sum
;
280 union block
*data_block
;
281 size_t size
, written
;
282 static char *next_long_name
, *next_long_link
;
286 header
= find_next_block ();
287 current_header
= header
;
289 return HEADER_END_OF_FILE
;
294 for (i
= sizeof (*header
); i
-- != 0;)
296 unsigned_sum
+= (unsigned char) *p
;
297 signed_sum
+= signed_char (*p
++);
300 if (unsigned_sum
== 0)
301 return HEADER_ZERO_BLOCK
;
303 /* Adjust checksum to count the "chksum" field as blanks. */
305 for (i
= sizeof (header
->header
.chksum
); i
-- != 0;)
307 unsigned_sum
-= (unsigned char) header
->header
.chksum
[i
];
308 signed_sum
-= signed_char (header
->header
.chksum
[i
]);
310 unsigned_sum
+= ' ' * sizeof header
->header
.chksum
;
311 signed_sum
+= ' ' * sizeof header
->header
.chksum
;
313 parsed_sum
= from_chars (header
->header
.chksum
,
314 sizeof header
->header
.chksum
,
315 (char *) 0, (uintmax_t) 0,
316 (uintmax_t) TYPE_MAXIMUM (int));
317 if (parsed_sum
== (uintmax_t) -1)
318 return HEADER_FAILURE
;
320 recorded_sum
= parsed_sum
;
322 if (unsigned_sum
!= recorded_sum
&& signed_sum
!= recorded_sum
)
323 return HEADER_FAILURE
;
325 /* Good block. Decode file size and return. */
327 if (header
->header
.typeflag
== LNKTYPE
)
328 current_stat
.st_size
= 0; /* links 0 size on tape */
330 current_stat
.st_size
= OFF_FROM_CHARS (header
->header
.size
);
332 if (header
->header
.typeflag
== GNUTYPE_LONGNAME
333 || header
->header
.typeflag
== GNUTYPE_LONGLINK
)
335 longp
= ((header
->header
.typeflag
== GNUTYPE_LONGNAME
)
339 set_next_block_after (header
);
342 size
= current_stat
.st_size
;
343 if (size
!= current_stat
.st_size
)
344 FATAL_ERROR ((0, 0, _("Memory exhausted")));
345 bp
= *longp
= (char *) xmalloc (size
);
347 for (; size
> 0; size
-= written
)
349 data_block
= find_next_block ();
350 if (data_block
== NULL
)
352 ERROR ((0, 0, _("Unexpected EOF on archive file")));
355 written
= available_space_after (data_block
);
359 memcpy (bp
, data_block
->buffer
, written
);
361 set_next_block_after ((union block
*)
362 (data_block
->buffer
+ written
- 1));
371 struct posix_header
*h
= ¤t_header
->header
;
372 char namebuf
[sizeof h
->prefix
+ 1 + NAME_FIELD_SIZE
+ 1];
374 name
= next_long_name
;
377 /* Accept file names as specified by POSIX.1-1996
379 int posix_header
= strcmp (h
->magic
, TMAGIC
) == 0;
382 if (posix_header
&& h
->prefix
[0])
384 memcpy (np
, h
->prefix
, sizeof h
->prefix
);
385 np
[sizeof h
->prefix
] = '\0';
389 memcpy (np
, h
->name
, sizeof h
->name
);
390 np
[sizeof h
->name
] = '\0';
393 assign_string (¤t_file_name
, name
);
396 free (next_long_name
);
400 name
= next_long_link
;
403 memcpy (namebuf
, h
->linkname
, sizeof h
->linkname
);
404 namebuf
[sizeof h
->linkname
] = '\0';
407 assign_string (¤t_link_name
, name
);
410 free (next_long_link
);
414 return HEADER_SUCCESS
;
419 /*-------------------------------------------------------------------------.
420 | Decode things from a file HEADER block into STAT_INFO, also setting |
421 | *FORMAT_POINTER depending on the header block format. If DO_USER_GROUP, |
422 | decode the user/group information (this is useful for extraction, but |
423 | waste time when merely listing). |
425 | read_header() has already decoded the checksum and length, so we don't. |
427 | This routine should *not* be called twice for the same block, since the |
428 | two calls might use different DO_USER_GROUP values and thus might end up |
429 | with different uid/gid for the two calls. If anybody wants the uid/gid |
430 | they should decode it first, and other callers should decode it without |
431 | uid/gid before calling a routine, e.g. print_header, that assumes |
433 `-------------------------------------------------------------------------*/
436 decode_header (union block
*header
, struct stat
*stat_info
,
437 enum archive_format
*format_pointer
, int do_user_group
)
439 enum archive_format format
;
441 if (strcmp (header
->header
.magic
, TMAGIC
) == 0)
442 format
= POSIX_FORMAT
;
443 else if (strcmp (header
->header
.magic
, OLDGNU_MAGIC
) == 0)
444 format
= OLDGNU_FORMAT
;
447 *format_pointer
= format
;
449 stat_info
->st_mode
= MODE_FROM_CHARS (header
->header
.mode
);
450 stat_info
->st_mtime
= TIME_FROM_CHARS (header
->header
.mtime
);
452 if (format
== OLDGNU_FORMAT
&& incremental_option
)
454 stat_info
->st_atime
= TIME_FROM_CHARS (header
->oldgnu_header
.atime
);
455 stat_info
->st_ctime
= TIME_FROM_CHARS (header
->oldgnu_header
.ctime
);
458 if (format
== V7_FORMAT
)
460 stat_info
->st_uid
= UID_FROM_CHARS (header
->header
.uid
);
461 stat_info
->st_gid
= GID_FROM_CHARS (header
->header
.gid
);
462 stat_info
->st_rdev
= 0;
468 /* FIXME: Decide if this should somewhat depend on -p. */
470 if (numeric_owner_option
471 || !*header
->header
.uname
472 || !uname_to_uid (header
->header
.uname
, &stat_info
->st_uid
))
473 stat_info
->st_uid
= UID_FROM_CHARS (header
->header
.uid
);
475 if (numeric_owner_option
476 || !*header
->header
.gname
477 || !gname_to_gid (header
->header
.gname
, &stat_info
->st_gid
))
478 stat_info
->st_gid
= GID_FROM_CHARS (header
->header
.gid
);
480 switch (header
->header
.typeflag
)
484 = makedev (MAJOR_FROM_CHARS (header
->header
.devmajor
),
485 MINOR_FROM_CHARS (header
->header
.devminor
));
490 = makedev (MAJOR_FROM_CHARS (header
->header
.devmajor
),
491 MINOR_FROM_CHARS (header
->header
.devminor
));
495 stat_info
->st_rdev
= 0;
500 /*------------------------------------------------------------------------.
501 | Convert buffer at WHERE0 of size DIGS from external format to uintmax_t.|
502 | The data is of type TYPE. The buffer must represent a value in the |
503 | range -MINUS_MINVAL through MAXVAL. |
504 `------------------------------------------------------------------------*/
507 from_chars (char const *where0
, size_t digs
, char const *type
,
508 uintmax_t minus_minval
, uintmax_t maxval
)
511 char const *where
= where0
;
512 char const *lim
= where
+ digs
;
515 /* Accommodate older tars, which output leading spaces, and at least one
516 buggy tar, which outputs leading NUL if the previous field overflows. */
523 _("Empty header where numeric %s value expected"),
527 if (!ISSPACE ((unsigned char) *where
) && *where
)
533 if (ISODIGIT (*where
))
537 if (value
<< LG_8
>> LG_8
!= value
)
539 value
= (value
<< LG_8
) | (*where
++ - '0');
541 while (where
!= lim
&& ISODIGIT (*where
));
543 /* Parse the output of older tars, which output negative values
544 in two's complement octal. This method works only if the
545 type has the same number of bits as it did on the host that
546 created the tar file, but that's the best we can do. */
547 if (maxval
< value
&& value
- maxval
<= minus_minval
)
549 value
= minus_minval
- (value
- maxval
);
553 else if (*where
== '-' || *where
== '+')
556 negative
= *where
++ == '-';
558 && (dig
= base64_map
[(unsigned char) *where
]) < 64)
560 if (value
<< LG_64
>> LG_64
!= value
)
562 value
= (value
<< LG_64
) | dig
;
567 if (where
!= lim
&& *where
&& !ISSPACE ((unsigned char) *where
))
571 char buf
[1000]; /* Big enough to represent any header. */
572 static struct quoting_options
*o
;
576 o
= clone_quoting_options ((struct quoting_options
*) 0);
577 set_quoting_style (o
, c_quoting_style
);
580 while (where0
!= lim
&& ! lim
[-1])
582 quotearg_buffer (buf
, sizeof buf
, where0
, lim
- where
, o
);
584 _("Header contains `%.*s' where numeric %s value expected"),
585 (int) sizeof buf
, buf
, type
));
591 if (value
<= (negative
? minus_minval
: maxval
))
592 return negative
? -value
: value
;
596 ERROR ((0, 0, _("Numeric value `%.*s' is out of range for %s"),
597 (int) digs
, where0
, type
));
602 gid_from_chars (const char *p
, size_t s
)
604 return from_chars (p
, s
, "gid_t",
605 - (uintmax_t) TYPE_MINIMUM (gid_t
),
606 (uintmax_t) TYPE_MAXIMUM (gid_t
));
610 major_from_chars (const char *p
, size_t s
)
612 return from_chars (p
, s
, "major_t",
613 - (uintmax_t) TYPE_MINIMUM (major_t
),
614 (uintmax_t) TYPE_MAXIMUM (major_t
));
618 minor_from_chars (const char *p
, size_t s
)
620 return from_chars (p
, s
, "minor_t",
621 - (uintmax_t) TYPE_MINIMUM (minor_t
),
622 (uintmax_t) TYPE_MAXIMUM (minor_t
));
626 mode_from_chars (const char *p
, size_t s
)
628 /* Do not complain about unrecognized mode bits. */
629 unsigned u
= from_chars (p
, s
, "mode_t",
630 - (uintmax_t) TYPE_MINIMUM (mode_t
),
631 TYPE_MAXIMUM (uintmax_t));
632 return ((u
& TSUID
? S_ISUID
: 0)
633 | (u
& TSGID
? S_ISGID
: 0)
634 | (u
& TSVTX
? S_ISVTX
: 0)
635 | (u
& TUREAD
? S_IRUSR
: 0)
636 | (u
& TUWRITE
? S_IWUSR
: 0)
637 | (u
& TUEXEC
? S_IXUSR
: 0)
638 | (u
& TGREAD
? S_IRGRP
: 0)
639 | (u
& TGWRITE
? S_IWGRP
: 0)
640 | (u
& TGEXEC
? S_IXGRP
: 0)
641 | (u
& TOREAD
? S_IROTH
: 0)
642 | (u
& TOWRITE
? S_IWOTH
: 0)
643 | (u
& TOEXEC
? S_IXOTH
: 0));
647 off_from_chars (const char *p
, size_t s
)
649 return from_chars (p
, s
, "off_t",
650 - (uintmax_t) TYPE_MINIMUM (off_t
),
651 (uintmax_t) TYPE_MAXIMUM (off_t
));
655 size_from_chars (const char *p
, size_t s
)
657 return from_chars (p
, s
, "size_t", (uintmax_t) 0,
658 (uintmax_t) TYPE_MAXIMUM (size_t));
662 time_from_chars (const char *p
, size_t s
)
664 return from_chars (p
, s
, "time_t",
665 - (uintmax_t) TYPE_MINIMUM (time_t),
666 (uintmax_t) TYPE_MAXIMUM (time_t));
670 uid_from_chars (const char *p
, size_t s
)
672 return from_chars (p
, s
, "uid_t", (uintmax_t) 0,
673 (uintmax_t) TYPE_MAXIMUM (uid_t
));
677 uintmax_from_chars (const char *p
, size_t s
)
679 return from_chars (p
, s
, "uintmax_t", (uintmax_t) 0,
680 TYPE_MAXIMUM (uintmax_t));
684 /*----------------------------------------------------------------------.
685 | Format O as a null-terminated decimal string into BUF _backwards_; |
686 | return pointer to start of result. |
687 `----------------------------------------------------------------------*/
689 stringify_uintmax_t_backwards (uintmax_t o
, char *buf
)
693 *--buf
= '0' + (int) (o
% 10);
694 while ((o
/= 10) != 0);
700 /*-------------------------------------------.
701 | Return the time formatted along ISO 8601. |
702 `-------------------------------------------*/
704 /* Also, see http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html. */
707 isotime (const time_t *time
)
709 static char buffer
[INT_STRLEN_BOUND (int) + 16];
710 struct tm
*tm
= localtime (time
);
712 sprintf (buffer
, "%04d-%02d-%02d %02d:%02d:%02d",
713 tm
->tm_year
+ 1900, tm
->tm_mon
+ 1, tm
->tm_mday
,
714 tm
->tm_hour
, tm
->tm_min
, tm
->tm_sec
);
716 /* Interpose %s between ?? and - to avoid ANSI C trigraph brain damage. */
717 sprintf (buffer
, "????%s-??%s-?? ??:??:??", "", "");
722 #endif /* not USE_OLD_CTIME */
724 /*-------------------------------------------------------------------------.
725 | Decode MODE from its binary form in a stat structure, and encode it into |
726 | a 9 characters string STRING, terminated with a NUL. |
727 `-------------------------------------------------------------------------*/
730 decode_mode (mode_t mode
, char *string
)
732 *string
++ = mode
& S_IRUSR
? 'r' : '-';
733 *string
++ = mode
& S_IWUSR
? 'w' : '-';
734 *string
++ = (mode
& S_ISUID
735 ? (mode
& S_IXUSR
? 's' : 'S')
736 : (mode
& S_IXUSR
? 'x' : '-'));
737 *string
++ = mode
& S_IRGRP
? 'r' : '-';
738 *string
++ = mode
& S_IWGRP
? 'w' : '-';
739 *string
++ = (mode
& S_ISGID
740 ? (mode
& S_IXGRP
? 's' : 'S')
741 : (mode
& S_IXGRP
? 'x' : '-'));
742 *string
++ = mode
& S_IROTH
? 'r' : '-';
743 *string
++ = mode
& S_IWOTH
? 'w' : '-';
744 *string
++ = (mode
& S_ISVTX
745 ? (mode
& S_IXOTH
? 't' : 'T')
746 : (mode
& S_IXOTH
? 'x' : '-'));
750 /*-------------------------------------------------------------------------.
751 | Actually print it. |
753 | Plain and fancy file header block logging. Non-verbose just prints the |
754 | name, e.g. for "tar t" or "tar x". This should just contain file names, |
755 | so it can be fed back into tar with xargs or the "-T" option. The |
756 | verbose option can give a bunch of info, one line per file. I doubt |
757 | anybody tries to parse its format, or if they do, they shouldn't. Unix |
758 | tar is pretty random here anyway. |
759 `-------------------------------------------------------------------------*/
761 /* FIXME: Note that print_header uses the globals HEAD, HSTAT, and
762 HEAD_STANDARD, which must be set up in advance. Not very clean... */
764 /* UGSWIDTH starts with 18, so with user and group names <= 8 chars, the
765 columns never shift during the listing. */
767 static int ugswidth
= UGSWIDTH
; /* maximum width encountered so far */
769 /* DATEWIDTH is the number of columns taken by the date and time fields. */
771 # define DATEWIDTH 19
773 # define DATEWIDTH 18
780 char const *timestamp
;
781 /* These hold formatted ints. */
782 char uform
[UINTMAX_STRSIZE_BOUND
], gform
[UINTMAX_STRSIZE_BOUND
];
784 char size
[2 * UINTMAX_STRSIZE_BOUND
];
785 /* holds formatted size or major,minor */
786 char uintbuf
[UINTMAX_STRSIZE_BOUND
];
787 time_t longie
; /* to make ctime() call portable */
791 if (block_number_option
)
793 char buf
[UINTMAX_STRSIZE_BOUND
];
794 fprintf (stdlis
, _("block %s: "),
795 STRINGIFY_BIGINT (current_block_ordinal (), buf
));
798 if (verbose_option
<= 1)
800 /* Just the fax, mam. */
802 char *quoted_name
= quote_copy_string (current_file_name
);
806 fprintf (stdlis
, "%s\n", quoted_name
);
810 fprintf (stdlis
, "%s\n", current_file_name
);
814 /* File type and modes. */
817 switch (current_header
->header
.typeflag
)
823 case GNUTYPE_MULTIVOL
:
831 case GNUTYPE_LONGNAME
:
832 case GNUTYPE_LONGLINK
:
833 ERROR ((0, 0, _("Visible longname error")));
841 if (current_file_name
[strlen (current_file_name
) - 1] == '/')
844 case GNUTYPE_DUMPDIR
:
867 decode_mode (current_stat
.st_mode
, modes
+ 1);
871 longie
= current_stat
.st_mtime
;
874 char *ct
= ctime (&longie
);
878 for (ct
+= 16; ct
[4] != '\n'; ct
++)
883 timestamp
= "??? ?? ??:?? ????";
886 timestamp
= isotime (&longie
);
889 /* User and group names. */
891 if (*current_header
->header
.uname
&& current_format
!= V7_FORMAT
892 && !numeric_owner_option
)
893 user
= current_header
->header
.uname
;
895 user
= STRINGIFY_BIGINT (UINTMAX_FROM_CHARS
896 (current_header
->header
.uid
),
899 if (*current_header
->header
.gname
&& current_format
!= V7_FORMAT
900 && !numeric_owner_option
)
901 group
= current_header
->header
.gname
;
903 group
= STRINGIFY_BIGINT (UINTMAX_FROM_CHARS
904 (current_header
->header
.gid
),
907 /* Format the file size or major/minor device numbers. */
909 switch (current_header
->header
.typeflag
)
913 sprintf (size
, "%lu,%lu",
914 (unsigned long) major (current_stat
.st_rdev
),
915 (unsigned long) minor (current_stat
.st_rdev
));
920 (UINTMAX_FROM_CHARS (current_header
->oldgnu_header
.realsize
),
924 strcpy (size
, STRINGIFY_BIGINT (current_stat
.st_size
, uintbuf
));
928 /* Figure out padding and print the whole line. */
930 pad
= strlen (user
) + strlen (group
) + strlen (size
) + 1;
934 fprintf (stdlis
, "%s %s/%s %*s%s %s",
935 modes
, user
, group
, ugswidth
- pad
, "", size
, timestamp
);
937 name
= quote_copy_string (current_file_name
);
940 fprintf (stdlis
, " %s", name
);
944 fprintf (stdlis
, " %s", current_file_name
);
946 switch (current_header
->header
.typeflag
)
949 name
= quote_copy_string (current_link_name
);
952 fprintf (stdlis
, " -> %s\n", name
);
956 fprintf (stdlis
, " -> %s\n", current_link_name
);
960 name
= quote_copy_string (current_link_name
);
963 fprintf (stdlis
, _(" link to %s\n"), name
);
967 fprintf (stdlis
, _(" link to %s\n"), current_link_name
);
971 fprintf (stdlis
, _(" unknown file type `%c'\n"),
972 current_header
->header
.typeflag
);
983 case GNUTYPE_DUMPDIR
:
988 fprintf (stdlis
, _("--Volume Header--\n"));
991 case GNUTYPE_MULTIVOL
:
994 (UINTMAX_FROM_CHARS (current_header
->oldgnu_header
.offset
),
996 fprintf (stdlis
, _("--Continued at byte %s--\n"), size
);
1000 fprintf (stdlis
, _("--Mangled file names--\n"));
1007 /*--------------------------------------------------------------.
1008 | Print a similar line when we make a directory automatically. |
1009 `--------------------------------------------------------------*/
1012 print_for_mkdir (char *pathname
, int length
, mode_t mode
)
1017 if (verbose_option
> 1)
1019 /* File type and modes. */
1022 decode_mode (mode
, modes
+ 1);
1024 if (block_number_option
)
1026 char buf
[UINTMAX_STRSIZE_BOUND
];
1027 fprintf (stdlis
, _("block %s: "),
1028 STRINGIFY_BIGINT (current_block_ordinal (), buf
));
1030 name
= quote_copy_string (pathname
);
1033 fprintf (stdlis
, "%s %*s %.*s\n", modes
, ugswidth
+ DATEWIDTH
,
1034 _("Creating directory:"), length
, name
);
1038 fprintf (stdlis
, "%s %*s %.*s\n", modes
, ugswidth
+ DATEWIDTH
,
1039 _("Creating directory:"), length
, pathname
);
1043 /*--------------------------------------------------------.
1044 | Skip over SIZE bytes of data in blocks in the archive. |
1045 `--------------------------------------------------------*/
1048 skip_file (off_t size
)
1052 if (multi_volume_option
)
1054 save_totsize
= size
;
1055 save_sizeleft
= size
;
1060 x
= find_next_block ();
1062 FATAL_ERROR ((0, 0, _("Unexpected EOF on archive file")));
1064 set_next_block_after (x
);
1066 if (multi_volume_option
)
1067 save_sizeleft
-= BLOCKSIZE
;
1076 skip_extended_headers (void)
1082 exhdr
= find_next_block ();
1084 FATAL_ERROR ((0, 0, _("Unexpected EOF on archive file")));
1085 set_next_block_after (exhdr
);
1087 while (exhdr
->sparse_header
.isextended
);