1 /* POSIX extended headers for tar.
3 Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
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 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
31 #if !HAVE_DECL_STRTOIMAX && !defined strtoimax
32 intmax_t strtoimax ();
34 #if !HAVE_DECL_STRTOUMAX && !defined strtoumax
35 uintmax_t strtoumax ();
38 static bool xheader_protected_pattern_p (char const *pattern
);
39 static bool xheader_protected_keyword_p (char const *keyword
);
40 static void xheader_set_single_keyword (char *) __attribute__ ((noreturn
));
42 /* Used by xheader_finish() */
43 static void code_string (char const *string
, char const *keyword
,
44 struct xheader
*xhdr
);
45 static void extended_header_init (void);
47 /* Number of global headers written so far. */
48 static size_t global_header_count
;
49 /* FIXME: Possibly it should be reset after changing the volume.
50 POSIX %n specification says that it is expanded to the sequence
51 number of current global header in *the* archive. However, for
52 multi-volume archives this will yield duplicate header names
53 in different volumes, which I'd like to avoid. The best way
54 to solve this would be to use per-archive header count as required
55 by POSIX *and* set globexthdr.name to, say,
56 $TMPDIR/GlobalHead.%p.$NUMVOLUME.%n.
58 However it should wait until buffer.c is finally rewritten */
65 struct keyword_list
*next
;
71 /* List of keyword patterns set by delete= option */
72 static struct keyword_list
*keyword_pattern_list
;
74 /* List of keyword/value pairs set by `keyword=value' option */
75 static struct keyword_list
*keyword_global_override_list
;
77 /* List of keyword/value pairs set by `keyword:=value' option */
78 static struct keyword_list
*keyword_override_list
;
80 /* List of keyword/value pairs decoded from the last 'g' type header */
81 static struct keyword_list
*global_header_override_list
;
83 /* Template for the name field of an 'x' type header */
84 static char *exthdr_name
;
86 /* Template for the name field of a 'g' type header */
87 static char *globexthdr_name
;
90 xheader_keyword_deleted_p (const char *kw
)
92 struct keyword_list
*kp
;
94 for (kp
= keyword_pattern_list
; kp
; kp
= kp
->next
)
95 if (fnmatch (kp
->pattern
, kw
, 0) == 0)
101 xheader_keyword_override_p (const char *keyword
)
103 struct keyword_list
*kp
;
105 for (kp
= keyword_override_list
; kp
; kp
= kp
->next
)
106 if (strcmp (kp
->pattern
, keyword
) == 0)
112 xheader_list_append (struct keyword_list
**root
, char const *kw
,
115 struct keyword_list
*kp
= xmalloc (sizeof *kp
);
116 kp
->pattern
= xstrdup (kw
);
117 kp
->value
= value
? xstrdup (value
) : NULL
;
123 xheader_list_destroy (struct keyword_list
**root
)
127 struct keyword_list
*kw
= *root
;
130 struct keyword_list
*next
= kw
->next
;
141 xheader_set_single_keyword (char *kw
)
143 USAGE_ERROR ((0, 0, _("Keyword %s is unknown or not yet imlemented"), kw
));
147 xheader_set_keyword_equal (char *kw
, char *eq
)
158 while (p
> kw
&& isspace (*p
))
163 for (p
= eq
+ 1; *p
&& isspace (*p
); p
++)
166 if (strcmp (kw
, "delete") == 0)
168 if (xheader_protected_pattern_p (p
))
169 USAGE_ERROR ((0, 0, _("Pattern %s cannot be used"), quote (p
)));
170 xheader_list_append (&keyword_pattern_list
, p
, NULL
);
172 else if (strcmp (kw
, "exthdr.name") == 0)
173 assign_string (&exthdr_name
, p
);
174 else if (strcmp (kw
, "globexthdr.name") == 0)
175 assign_string (&globexthdr_name
, p
);
178 if (xheader_protected_keyword_p (kw
))
179 USAGE_ERROR ((0, 0, _("Keyword %s cannot be overridden"), kw
));
181 xheader_list_append (&keyword_global_override_list
, kw
, p
);
183 xheader_list_append (&keyword_override_list
, kw
, p
);
188 xheader_set_option (char *string
)
191 for (token
= strtok (string
, ","); token
; token
= strtok (NULL
, ","))
193 char *p
= strchr (token
, '=');
195 xheader_set_single_keyword (token
);
197 xheader_set_keyword_equal (token
, p
);
202 string Includes: Replaced By:
203 %d The directory name of the file,
204 equivalent to the result of the
205 dirname utility on the translated
207 %f The filename of the file, equivalent
208 to the result of the basename
209 utility on the translated file name.
210 %p The process ID of the pax process.
211 %% A '%' character. */
214 xheader_format_name (struct tar_stat_info
*st
, const char *fmt
, bool allow_n
)
217 size_t len
= strlen (fmt
);
222 char pidbuf
[UINTMAX_STRSIZE_BOUND
];
224 char nbuf
[UINTMAX_STRSIZE_BOUND
];
225 char const *nptr
= NULL
;
227 for (p
= fmt
; *p
&& (p
= strchr (p
, '%')); )
238 dir
= safer_name_suffix (dir_name (st
->orig_file_name
),
239 false, absolute_names_option
);
240 len
+= strlen (dir
) - 1;
247 base
= base_name (st
->orig_file_name
);
248 len
+= strlen (base
) - 1;
253 pptr
= umaxtostr (getpid (), pidbuf
);
254 len
+= pidbuf
+ sizeof pidbuf
- 1 - pptr
- 1;
260 nptr
= umaxtostr (global_header_count
+ 1, nbuf
);
261 len
+= nbuf
+ sizeof nbuf
- 1 - nptr
- 1;
268 buf
= xmalloc (len
+ 1);
269 for (q
= buf
, p
= fmt
; *p
; )
288 q
= stpcpy (q
, base
);
293 q
= stpcpy (q
, pptr
);
300 q
= stpcpy (q
, nptr
);
303 /* else fall through */
315 /* Do not allow it to end in a slash */
316 while (q
> buf
&& ISSLASH (q
[-1]))
323 xheader_xhdr_name (struct tar_stat_info
*st
)
326 assign_string (&exthdr_name
, "%d/PaxHeaders.%p/%f");
327 return xheader_format_name (st
, exthdr_name
, false);
330 #define GLOBAL_HEADER_TEMPLATE "/GlobalHead.%p.%n"
333 xheader_ghdr_name (void)
335 if (!globexthdr_name
)
338 const char *tmp
= getenv ("TMPDIR");
341 len
= strlen (tmp
) + sizeof (GLOBAL_HEADER_TEMPLATE
); /* Includes nul */
342 globexthdr_name
= xmalloc (len
);
343 strcpy(globexthdr_name
, tmp
);
344 strcat(globexthdr_name
, GLOBAL_HEADER_TEMPLATE
);
347 return xheader_format_name (NULL
, globexthdr_name
, true);
351 xheader_write (char type
, char *name
, struct xheader
*xhdr
)
358 header
= start_private_header (name
, size
);
359 header
->header
.typeflag
= type
;
361 simple_finish_header (header
);
369 header
= find_next_block ();
373 memcpy (header
->buffer
, p
, len
);
375 memset (header
->buffer
+ len
, 0, BLOCKSIZE
- len
);
378 set_next_block_after (header
);
381 xheader_destroy (xhdr
);
385 xheader_write_global (void)
388 struct keyword_list
*kp
;
390 if (!keyword_global_override_list
)
393 extended_header_init ();
394 for (kp
= keyword_global_override_list
; kp
; kp
= kp
->next
)
395 code_string (kp
->value
, kp
->pattern
, &extended_header
);
396 xheader_finish (&extended_header
);
397 xheader_write (XGLTYPE
, name
= xheader_ghdr_name (),
400 global_header_count
++;
404 /* General Interface */
409 void (*coder
) (struct tar_stat_info
const *, char const *,
410 struct xheader
*, void *data
);
411 void (*decoder
) (struct tar_stat_info
*, char const *);
415 /* This declaration must be extern, because ISO C99 section 6.9.2
416 prohibits a tentative definition that has both internal linkage and
417 incomplete type. If we made it static, we'd have to declare its
418 size which would be a maintenance pain; if we put its initializer
419 here, we'd need a boatload of forward declarations, which would be
420 even more of a pain. */
421 extern struct xhdr_tab
const xhdr_tab
[];
423 static struct xhdr_tab
const *
424 locate_handler (char const *keyword
)
426 struct xhdr_tab
const *p
;
428 for (p
= xhdr_tab
; p
->keyword
; p
++)
429 if (strcmp (p
->keyword
, keyword
) == 0)
435 xheader_protected_pattern_p (const char *pattern
)
437 struct xhdr_tab
const *p
;
439 for (p
= xhdr_tab
; p
->keyword
; p
++)
440 if (p
->protect
&& fnmatch (pattern
, p
->keyword
, 0) == 0)
446 xheader_protected_keyword_p (const char *keyword
)
448 struct xhdr_tab
const *p
;
450 for (p
= xhdr_tab
; p
->keyword
; p
++)
451 if (p
->protect
&& strcmp (p
->keyword
, keyword
) == 0)
456 /* Decode a single extended header record, advancing *PTR to the next record.
457 Return true on success, false otherwise. */
459 decode_record (char **ptr
,
460 void (*handler
) (void *, char const *, char const *),
465 unsigned long int len
;
469 size_t len_max
= extended_header
.buffer
+ extended_header
.size
- start
;
471 while (*p
== ' ' || *p
== '\t')
477 ERROR ((0, 0, _("Malformed extended header: missing length")));
482 len
= strtoul (p
, &len_lim
, 10);
486 int len_len
= len_lim
- p
;
487 ERROR ((0, 0, _("Extended header length %*s is out of range"),
494 for (p
= len_lim
; *p
== ' ' || *p
== '\t'; p
++)
499 _("Malformed extended header: missing blank after length")));
505 if (! (p
&& p
< nextp
))
507 ERROR ((0, 0, _("Malformed extended header: missing equal sign")));
511 if (nextp
[-1] != '\n')
513 ERROR ((0, 0, _("Malformed extended header: missing newline")));
517 *p
= nextp
[-1] = '\0';
518 handler (data
, keyword
, p
+ 1);
526 run_override_list (struct keyword_list
*kp
, struct tar_stat_info
*st
)
528 for (; kp
; kp
= kp
->next
)
530 struct xhdr_tab
const *t
= locate_handler (kp
->pattern
);
532 t
->decoder (st
, kp
->value
);
537 decx (void *data
, char const *keyword
, char const *value
)
539 struct xhdr_tab
const *t
;
540 struct tar_stat_info
*st
= data
;
542 if (xheader_keyword_deleted_p (keyword
)
543 || xheader_keyword_override_p (keyword
))
546 t
= locate_handler (keyword
);
548 t
->decoder (st
, value
);
552 xheader_decode (struct tar_stat_info
*st
)
554 run_override_list (keyword_global_override_list
, st
);
555 run_override_list (global_header_override_list
, st
);
557 if (extended_header
.size
)
559 char *p
= extended_header
.buffer
+ BLOCKSIZE
;
560 while (decode_record (&p
, decx
, st
))
563 run_override_list (keyword_override_list
, st
);
567 decg (void *data
, char const *keyword
, char const *value
)
569 struct keyword_list
**kwl
= data
;
570 xheader_list_append (kwl
, keyword
, value
);
574 xheader_decode_global (void)
576 if (extended_header
.size
)
578 char *p
= extended_header
.buffer
+ BLOCKSIZE
;
580 xheader_list_destroy (&global_header_override_list
);
581 while (decode_record (&p
, decg
, &global_header_override_list
))
587 extended_header_init (void)
589 if (!extended_header
.stk
)
591 extended_header
.stk
= xmalloc (sizeof *extended_header
.stk
);
592 obstack_init (extended_header
.stk
);
597 xheader_store (char const *keyword
, struct tar_stat_info
const *st
, void *data
)
599 struct xhdr_tab
const *t
;
601 if (extended_header
.buffer
)
603 t
= locate_handler (keyword
);
606 if (xheader_keyword_deleted_p (keyword
)
607 || xheader_keyword_override_p (keyword
))
609 extended_header_init ();
610 t
->coder (st
, keyword
, &extended_header
, data
);
614 xheader_read (union block
*p
, size_t size
)
619 free (extended_header
.buffer
);
621 extended_header
.size
= size
;
622 nblocks
= (size
+ BLOCKSIZE
- 1) / BLOCKSIZE
;
623 extended_header
.buffer
= xmalloc (size
+ 1);
624 extended_header
.buffer
[size
] = '\0';
633 memcpy (&extended_header
.buffer
[j
], p
->buffer
, len
);
634 set_next_block_after (p
);
636 p
= find_next_block ();
645 xheader_print (struct xheader
*xhdr
, char const *keyword
, char const *value
)
647 size_t len
= strlen (keyword
) + strlen (value
) + 3; /* ' ' + '=' + '\n' */
650 char nbuf
[UINTMAX_STRSIZE_BOUND
];
656 np
= umaxtostr (len
+ p
, nbuf
);
657 n
= nbuf
+ sizeof nbuf
- 1 - np
;
661 obstack_grow (xhdr
->stk
, np
, n
);
662 obstack_1grow (xhdr
->stk
, ' ');
663 obstack_grow (xhdr
->stk
, keyword
, strlen (keyword
));
664 obstack_1grow (xhdr
->stk
, '=');
665 obstack_grow (xhdr
->stk
, value
, strlen (value
));
666 obstack_1grow (xhdr
->stk
, '\n');
670 xheader_finish (struct xheader
*xhdr
)
672 struct keyword_list
*kp
;
674 for (kp
= keyword_override_list
; kp
; kp
= kp
->next
)
675 code_string (kp
->value
, kp
->pattern
, xhdr
);
677 obstack_1grow (xhdr
->stk
, 0);
678 xhdr
->buffer
= obstack_finish (xhdr
->stk
);
679 xhdr
->size
= strlen (xhdr
->buffer
);
683 xheader_destroy (struct xheader
*xhdr
)
687 obstack_free (xhdr
->stk
, NULL
);
698 /* Implementations */
701 out_of_range_header (char const *keyword
, char const *value
,
702 uintmax_t minus_minval
, uintmax_t maxval
)
704 char minval_buf
[UINTMAX_STRSIZE_BOUND
+ 1];
705 char maxval_buf
[UINTMAX_STRSIZE_BOUND
];
706 char *minval_string
= umaxtostr (minus_minval
, minval_buf
+ 1);
707 char *maxval_string
= umaxtostr (maxval
, maxval_buf
);
709 *--minval_string
= '-';
711 /* TRANSLATORS: The first %s is the pax extended header keyword
712 (atime, gid, etc.). */
713 ERROR ((0, 0, _("Extended header %s=%s is out of range %s..%s"),
714 keyword
, value
, minval_string
, maxval_string
));
718 code_string (char const *string
, char const *keyword
, struct xheader
*xhdr
)
721 if (!utf8_convert (true, string
, &outstr
))
723 /* FIXME: report error */
724 outstr
= xstrdup (string
);
726 xheader_print (xhdr
, keyword
, outstr
);
731 decode_string (char **string
, char const *arg
)
738 if (!utf8_convert (false, arg
, string
))
740 /* FIXME: report error and act accordingly to --pax invalid=UTF-8 */
741 assign_string (string
, arg
);
746 code_time (struct timespec t
, char const *keyword
, struct xheader
*xhdr
)
748 char buf
[TIMESPEC_STRSIZE_BOUND
];
749 xheader_print (xhdr
, keyword
, code_timespec (t
, buf
));
753 decode_time (struct timespec
*ts
, char const *arg
, char const *keyword
)
756 unsigned long int ns
= 0;
759 bool negative
= *arg
== '-';
763 if (ISDIGIT (arg
[negative
]))
767 intmax_t i
= strtoimax (arg
, &arg_lim
, 10);
768 if (TYPE_SIGNED (time_t) ? i
< TYPE_MINIMUM (time_t) : i
< 0)
774 uintmax_t i
= strtoumax (arg
, &arg_lim
, 10);
775 if (TYPE_MAXIMUM (time_t) < i
)
788 bool trailing_nonzero
= false;
790 while (ISDIGIT (*++p
))
791 if (digits
< LOG10_BILLION
)
793 ns
= 10 * ns
+ (*p
- '0');
797 trailing_nonzero
|= *p
!= '0';
799 while (digits
++ < LOG10_BILLION
)
804 /* Convert "-1.10000000000001" to s == -2, ns == 89999999.
805 I.e., truncate time stamps towards minus infinity while
806 converting them to internal form. */
807 ns
+= trailing_nonzero
;
810 if (s
== TYPE_MINIMUM (time_t))
826 ERROR ((0, 0, _("Malformed extended header: invalid %s=%s"),
831 out_of_range_header (keyword
, arg
, - (uintmax_t) TYPE_MINIMUM (time_t),
832 TYPE_MAXIMUM (time_t));
837 code_num (uintmax_t value
, char const *keyword
, struct xheader
*xhdr
)
839 char sbuf
[UINTMAX_STRSIZE_BOUND
];
840 xheader_print (xhdr
, keyword
, umaxtostr (value
, sbuf
));
844 decode_num (uintmax_t *num
, char const *arg
, uintmax_t maxval
,
850 if (! (ISDIGIT (*arg
)
851 && (errno
= 0, u
= strtoumax (arg
, &arg_lim
, 10), !*arg_lim
)))
853 ERROR ((0, 0, _("Malformed extended header: invalid %s=%s"),
858 if (! (u
<= maxval
&& errno
!= ERANGE
))
860 out_of_range_header (keyword
, arg
, 0, maxval
);
869 dummy_coder (struct tar_stat_info
const *st
__attribute__ ((unused
)),
870 char const *keyword
__attribute__ ((unused
)),
871 struct xheader
*xhdr
__attribute__ ((unused
)),
872 void *data
__attribute__ ((unused
)))
877 dummy_decoder (struct tar_stat_info
*st
__attribute__ ((unused
)),
878 char const *arg
__attribute__ ((unused
)))
883 atime_coder (struct tar_stat_info
const *st
, char const *keyword
,
884 struct xheader
*xhdr
, void *data
__attribute__ ((unused
)))
886 code_time (st
->atime
, keyword
, xhdr
);
890 atime_decoder (struct tar_stat_info
*st
, char const *arg
)
893 if (decode_time (&ts
, arg
, "atime"))
898 gid_coder (struct tar_stat_info
const *st
, char const *keyword
,
899 struct xheader
*xhdr
, void *data
__attribute__ ((unused
)))
901 code_num (st
->stat
.st_gid
, keyword
, xhdr
);
905 gid_decoder (struct tar_stat_info
*st
, char const *arg
)
908 if (decode_num (&u
, arg
, TYPE_MAXIMUM (gid_t
), "gid"))
913 gname_coder (struct tar_stat_info
const *st
, char const *keyword
,
914 struct xheader
*xhdr
, void *data
__attribute__ ((unused
)))
916 code_string (st
->gname
, keyword
, xhdr
);
920 gname_decoder (struct tar_stat_info
*st
, char const *arg
)
922 decode_string (&st
->gname
, arg
);
926 linkpath_coder (struct tar_stat_info
const *st
, char const *keyword
,
927 struct xheader
*xhdr
, void *data
__attribute__ ((unused
)))
929 code_string (st
->link_name
, keyword
, xhdr
);
933 linkpath_decoder (struct tar_stat_info
*st
, char const *arg
)
935 decode_string (&st
->link_name
, arg
);
939 ctime_coder (struct tar_stat_info
const *st
, char const *keyword
,
940 struct xheader
*xhdr
, void *data
__attribute__ ((unused
)))
942 code_time (st
->ctime
, keyword
, xhdr
);
946 ctime_decoder (struct tar_stat_info
*st
, char const *arg
)
949 if (decode_time (&ts
, arg
, "ctime"))
954 mtime_coder (struct tar_stat_info
const *st
, char const *keyword
,
955 struct xheader
*xhdr
, void *data
__attribute__ ((unused
)))
957 code_time (st
->mtime
, keyword
, xhdr
);
961 mtime_decoder (struct tar_stat_info
*st
, char const *arg
)
964 if (decode_time (&ts
, arg
, "mtime"))
969 path_coder (struct tar_stat_info
const *st
, char const *keyword
,
970 struct xheader
*xhdr
, void *data
__attribute__ ((unused
)))
972 code_string (st
->file_name
, keyword
, xhdr
);
976 path_decoder (struct tar_stat_info
*st
, char const *arg
)
978 decode_string (&st
->orig_file_name
, arg
);
979 decode_string (&st
->file_name
, arg
);
980 st
->had_trailing_slash
= strip_trailing_slashes (st
->file_name
);
984 size_coder (struct tar_stat_info
const *st
, char const *keyword
,
985 struct xheader
*xhdr
, void *data
__attribute__ ((unused
)))
987 code_num (st
->stat
.st_size
, keyword
, xhdr
);
991 size_decoder (struct tar_stat_info
*st
, char const *arg
)
994 if (decode_num (&u
, arg
, TYPE_MAXIMUM (off_t
), "size"))
995 st
->stat
.st_size
= u
;
999 uid_coder (struct tar_stat_info
const *st
, char const *keyword
,
1000 struct xheader
*xhdr
, void *data
__attribute__ ((unused
)))
1002 code_num (st
->stat
.st_uid
, keyword
, xhdr
);
1006 uid_decoder (struct tar_stat_info
*st
, char const *arg
)
1009 if (decode_num (&u
, arg
, TYPE_MAXIMUM (uid_t
), "uid"))
1010 st
->stat
.st_uid
= u
;
1014 uname_coder (struct tar_stat_info
const *st
, char const *keyword
,
1015 struct xheader
*xhdr
, void *data
__attribute__ ((unused
)))
1017 code_string (st
->uname
, keyword
, xhdr
);
1021 uname_decoder (struct tar_stat_info
*st
, char const *arg
)
1023 decode_string (&st
->uname
, arg
);
1027 sparse_size_coder (struct tar_stat_info
const *st
, char const *keyword
,
1028 struct xheader
*xhdr
, void *data
)
1030 size_coder (st
, keyword
, xhdr
, data
);
1034 sparse_size_decoder (struct tar_stat_info
*st
, char const *arg
)
1037 if (decode_num (&u
, arg
, TYPE_MAXIMUM (off_t
), "GNU.sparse.size"))
1038 st
->stat
.st_size
= u
;
1042 sparse_numblocks_coder (struct tar_stat_info
const *st
, char const *keyword
,
1043 struct xheader
*xhdr
,
1044 void *data
__attribute__ ((unused
)))
1046 code_num (st
->sparse_map_avail
, keyword
, xhdr
);
1050 sparse_numblocks_decoder (struct tar_stat_info
*st
, char const *arg
)
1053 if (decode_num (&u
, arg
, SIZE_MAX
, "GNU.sparse.numblocks"))
1055 st
->sparse_map_size
= u
;
1056 st
->sparse_map
= xcalloc (u
, sizeof st
->sparse_map
[0]);
1057 st
->sparse_map_avail
= 0;
1062 sparse_offset_coder (struct tar_stat_info
const *st
, char const *keyword
,
1063 struct xheader
*xhdr
, void *data
)
1066 code_num (st
->sparse_map
[*pi
].offset
, keyword
, xhdr
);
1070 sparse_offset_decoder (struct tar_stat_info
*st
, char const *arg
)
1073 if (decode_num (&u
, arg
, TYPE_MAXIMUM (off_t
), "GNU.sparse.offset"))
1075 if (st
->sparse_map_avail
< st
->sparse_map_size
)
1076 st
->sparse_map
[st
->sparse_map_avail
].offset
= u
;
1078 ERROR ((0, 0, _("Malformed extended header: excess %s=%s"),
1079 "GNU.sparse.offset", arg
));
1084 sparse_numbytes_coder (struct tar_stat_info
const *st
, char const *keyword
,
1085 struct xheader
*xhdr
, void *data
)
1088 code_num (st
->sparse_map
[*pi
].numbytes
, keyword
, xhdr
);
1092 sparse_numbytes_decoder (struct tar_stat_info
*st
, char const *arg
)
1095 if (decode_num (&u
, arg
, SIZE_MAX
, "GNU.sparse.numbytes"))
1097 if (st
->sparse_map_avail
< st
->sparse_map_size
)
1098 st
->sparse_map
[st
->sparse_map_avail
++].numbytes
= u
;
1100 ERROR ((0, 0, _("Malformed extended header: excess %s=%s"),
1101 "GNU.sparse.numbytes", arg
));
1105 struct xhdr_tab
const xhdr_tab
[] = {
1106 { "atime", atime_coder
, atime_decoder
, false },
1107 { "comment", dummy_coder
, dummy_decoder
, false },
1108 { "charset", dummy_coder
, dummy_decoder
, false },
1109 { "ctime", ctime_coder
, ctime_decoder
, false },
1110 { "gid", gid_coder
, gid_decoder
, false },
1111 { "gname", gname_coder
, gname_decoder
, false },
1112 { "linkpath", linkpath_coder
, linkpath_decoder
, false },
1113 { "mtime", mtime_coder
, mtime_decoder
, false },
1114 { "path", path_coder
, path_decoder
, false },
1115 { "size", size_coder
, size_decoder
, false },
1116 { "uid", uid_coder
, uid_decoder
, false },
1117 { "uname", uname_coder
, uname_decoder
, false },
1119 /* Sparse file handling */
1120 { "GNU.sparse.size", sparse_size_coder
, sparse_size_decoder
, true },
1121 { "GNU.sparse.numblocks", sparse_numblocks_coder
, sparse_numblocks_decoder
,
1123 { "GNU.sparse.offset", sparse_offset_coder
, sparse_offset_decoder
,
1125 { "GNU.sparse.numbytes", sparse_numbytes_coder
, sparse_numbytes_decoder
,
1128 #if 0 /* GNU private keywords (not yet implemented) */
1130 /* The next directory entry actually contains the names of files
1131 that were in the directory at the time the dump was made.
1132 Supersedes GNUTYPE_DUMPDIR header type. */
1133 { "GNU.dump.name", dump_name_coder
, dump_name_decoder
, false },
1134 { "GNU.dump.status", dump_status_coder
, dump_status_decoder
, false },
1136 /* Keeps the tape/volume header. May be present only in the global headers.
1137 Equivalent to GNUTYPE_VOLHDR. */
1138 { "GNU.volume.header", volume_header_coder
, volume_header_decoder
, false },
1140 /* These may be present in a first global header of the archive.
1141 They provide the same functionality as GNUTYPE_MULTIVOL header.
1142 The GNU.volume.size keeps the real_s_sizeleft value, which is
1143 otherwise kept in the size field of a multivolume header. The
1144 GNU.volume.offset keeps the offset of the start of this volume,
1145 otherwise kept in oldgnu_header.offset. */
1146 { "GNU.volume.size", volume_size_coder
, volume_size_decoder
, false },
1147 { "GNU.volume.offset", volume_offset_coder
, volume_offset_decoder
, false },
1150 { NULL
, NULL
, NULL
, false }