153b7c3eecc257f78235effe2cbab847a3fb2602
[platform/upstream/libarchive.git] / doc / man / tar.5
1 .TH TAR 5 "December 27, 2016" ""
2 .SH NAME
3 .ad l
4 \fB\%tar\fP
5 \- format of tape archive files
6 .SH DESCRIPTION
7 .ad l
8 The
9 \fB\%tar\fP
10 archive format collects any number of files, directories, and other
11 file system objects (symbolic links, device nodes, etc.) into a single
12 stream of bytes.
13 The format was originally designed to be used with
14 tape drives that operate with fixed-size blocks, but is widely used as
15 a general packaging mechanism.
16 .SS General Format
17 A
18 \fB\%tar\fP
19 archive consists of a series of 512-byte records.
20 Each file system object requires a header record which stores basic metadata
21 (pathname, owner, permissions, etc.) and zero or more records containing any
22 file data.
23 The end of the archive is indicated by two records consisting
24 entirely of zero bytes.
25 .PP
26 For compatibility with tape drives that use fixed block sizes,
27 programs that read or write tar files always read or write a fixed
28 number of records with each I/O operation.
29 These
30 ``blocks''
31 are always a multiple of the record size.
32 The maximum block size supported by early
33 implementations was 10240 bytes or 20 records.
34 This is still the default for most implementations
35 although block sizes of 1MiB (2048 records) or larger are
36 commonly used with modern high-speed tape drives.
37 (Note: the terms
38 ``block''
39 and
40 ``record''
41 here are not entirely standard; this document follows the
42 convention established by John Gilmore in documenting
43 \fB\%pdtar\fP.)
44 .SS Old-Style Archive Format
45 The original tar archive format has been extended many times to
46 include additional information that various implementors found
47 necessary.
48 This section describes the variant implemented by the tar command
49 included in
50 At v7,
51 which seems to be the earliest widely-used version of the tar program.
52 .PP
53 The header record for an old-style
54 \fB\%tar\fP
55 archive consists of the following:
56 .RS 4
57 .nf
58 struct header_old_tar {
59         char name[100];
60         char mode[8];
61         char uid[8];
62         char gid[8];
63         char size[12];
64         char mtime[12];
65         char checksum[8];
66         char linkflag[1];
67         char linkname[100];
68         char pad[255];
69 };
70 .RE
71 All unused bytes in the header record are filled with nulls.
72 .RS 5
73 .TP
74 \fIname\fP
75 Pathname, stored as a null-terminated string.
76 Early tar implementations only stored regular files (including
77 hardlinks to those files).
78 One common early convention used a trailing "/" character to indicate
79 a directory name, allowing directory permissions and owner information
80 to be archived and restored.
81 .TP
82 \fImode\fP
83 File mode, stored as an octal number in ASCII.
84 .TP
85 \fIuid\fP, \fIgid\fP
86 User id and group id of owner, as octal numbers in ASCII.
87 .TP
88 \fIsize\fP
89 Size of file, as octal number in ASCII.
90 For regular files only, this indicates the amount of data
91 that follows the header.
92 In particular, this field was ignored by early tar implementations
93 when extracting hardlinks.
94 Modern writers should always store a zero length for hardlink entries.
95 .TP
96 \fImtime\fP
97 Modification time of file, as an octal number in ASCII.
98 This indicates the number of seconds since the start of the epoch,
99 00:00:00 UTC January 1, 1970.
100 Note that negative values should be avoided
101 here, as they are handled inconsistently.
102 .TP
103 \fIchecksum\fP
104 Header checksum, stored as an octal number in ASCII.
105 To compute the checksum, set the checksum field to all spaces,
106 then sum all bytes in the header using unsigned arithmetic.
107 This field should be stored as six octal digits followed by a null and a space
108 character.
109 Note that many early implementations of tar used signed arithmetic
110 for the checksum field, which can cause interoperability problems
111 when transferring archives between systems.
112 Modern robust readers compute the checksum both ways and accept the
113 header if either computation matches.
114 .TP
115 \fIlinkflag\fP, \fIlinkname\fP
116 In order to preserve hardlinks and conserve tape, a file
117 with multiple links is only written to the archive the first
118 time it is encountered.
119 The next time it is encountered, the
120 \fIlinkflag\fP
121 is set to an ASCII
122 Sq 1
123 and the
124 \fIlinkname\fP
125 field holds the first name under which this file appears.
126 (Note that regular files have a null value in the
127 \fIlinkflag\fP
128 field.)
129 .RE
130 .PP
131 Early tar implementations varied in how they terminated these fields.
132 The tar command in
133 At v7
134 used the following conventions (this is also documented in early BSD manpages):
135 the pathname must be null-terminated;
136 the mode, uid, and gid fields must end in a space and a null byte;
137 the size and mtime fields must end in a space;
138 the checksum is terminated by a null and a space.
139 Early implementations filled the numeric fields with leading spaces.
140 This seems to have been common practice until the
141 IEEE Std 1003.1-1988 (``POSIX.1'')
142 standard was released.
143 For best portability, modern implementations should fill the numeric
144 fields with leading zeros.
145 .SS Pre-POSIX Archives
146 An early draft of
147 IEEE Std 1003.1-1988 (``POSIX.1'')
148 served as the basis for John Gilmore's
149 \fB\%pdtar\fP
150 program and many system implementations from the late 1980s
151 and early 1990s.
152 These archives generally follow the POSIX ustar
153 format described below with the following variations:
154 .RS 5
155 .IP \(bu
156 The magic value consists of the five characters
157 ``ustar''
158 followed by a space.
159 The version field contains a space character followed by a null.
160 .IP \(bu
161 The numeric fields are generally filled with leading spaces
162 (not leading zeros as recommended in the final standard).
163 .IP \(bu
164 The prefix field is often not used, limiting pathnames to
165 the 100 characters of old-style archives.
166 .RE
167 .SS POSIX ustar Archives
168 IEEE Std 1003.1-1988 (``POSIX.1'')
169 defined a standard tar file format to be read and written
170 by compliant implementations of
171 \fBtar\fP(1).
172 This format is often called the
173 ``ustar''
174 format, after the magic value used
175 in the header.
176 (The name is an acronym for
177 ``Unix Standard TAR''.)
178 It extends the historic format with new fields:
179 .RS 4
180 .nf
181 struct header_posix_ustar {
182         char name[100];
183         char mode[8];
184         char uid[8];
185         char gid[8];
186         char size[12];
187         char mtime[12];
188         char checksum[8];
189         char typeflag[1];
190         char linkname[100];
191         char magic[6];
192         char version[2];
193         char uname[32];
194         char gname[32];
195         char devmajor[8];
196         char devminor[8];
197         char prefix[155];
198         char pad[12];
199 };
200 .RE
201 .RS 5
202 .TP
203 \fItypeflag\fP
204 Type of entry.
205 POSIX extended the earlier
206 \fIlinkflag\fP
207 field with several new type values:
208 .RS 5
209 .TP
210 ``0''
211 Regular file.
212 NUL should be treated as a synonym, for compatibility purposes.
213 .TP
214 ``1''
215 Hard link.
216 .TP
217 ``2''
218 Symbolic link.
219 .TP
220 ``3''
221 Character device node.
222 .TP
223 ``4''
224 Block device node.
225 .TP
226 ``5''
227 Directory.
228 .TP
229 ``6''
230 FIFO node.
231 .TP
232 ``7''
233 Reserved.
234 .TP
235 Other
236 A POSIX-compliant implementation must treat any unrecognized typeflag value
237 as a regular file.
238 In particular, writers should ensure that all entries
239 have a valid filename so that they can be restored by readers that do not
240 support the corresponding extension.
241 Uppercase letters "A" through "Z" are reserved for custom extensions.
242 Note that sockets and whiteout entries are not archivable.
243 .RE
244 It is worth noting that the
245 \fIsize\fP
246 field, in particular, has different meanings depending on the type.
247 For regular files, of course, it indicates the amount of data
248 following the header.
249 For directories, it may be used to indicate the total size of all
250 files in the directory, for use by operating systems that pre-allocate
251 directory space.
252 For all other types, it should be set to zero by writers and ignored
253 by readers.
254 .TP
255 \fImagic\fP
256 Contains the magic value
257 ``ustar''
258 followed by a NUL byte to indicate that this is a POSIX standard archive.
259 Full compliance requires the uname and gname fields be properly set.
260 .TP
261 \fIversion\fP
262 Version.
263 This should be
264 ``00''
265 (two copies of the ASCII digit zero) for POSIX standard archives.
266 .TP
267 \fIuname\fP, \fIgname\fP
268 User and group names, as null-terminated ASCII strings.
269 These should be used in preference to the uid/gid values
270 when they are set and the corresponding names exist on
271 the system.
272 .TP
273 \fIdevmajor\fP, \fIdevminor\fP
274 Major and minor numbers for character device or block device entry.
275 .TP
276 \fIname\fP, \fIprefix\fP
277 If the pathname is too long to fit in the 100 bytes provided by the standard
278 format, it can be split at any
279 \fI/\fP
280 character with the first portion going into the prefix field.
281 If the prefix field is not empty, the reader will prepend
282 the prefix value and a
283 \fI/\fP
284 character to the regular name field to obtain the full pathname.
285 The standard does not require a trailing
286 \fI/\fP
287 character on directory names, though most implementations still
288 include this for compatibility reasons.
289 .RE
290 .PP
291 Note that all unused bytes must be set to
292 .BR NUL.
293 .PP
294 Field termination is specified slightly differently by POSIX
295 than by previous implementations.
296 The
297 \fImagic\fP,
298 \fIuname\fP,
299 and
300 \fIgname\fP
301 fields must have a trailing
302 .BR NUL.
303 The
304 \fIpathname\fP,
305 \fIlinkname\fP,
306 and
307 \fIprefix\fP
308 fields must have a trailing
309 .BR NUL
310 unless they fill the entire field.
311 (In particular, it is possible to store a 256-character pathname if it
312 happens to have a
313 \fI/\fP
314 as the 156th character.)
315 POSIX requires numeric fields to be zero-padded in the front, and requires
316 them to be terminated with either space or
317 .BR NUL
318 characters.
319 .PP
320 Currently, most tar implementations comply with the ustar
321 format, occasionally extending it by adding new fields to the
322 blank area at the end of the header record.
323 .SS Numeric Extensions
324 There have been several attempts to extend the range of sizes
325 or times supported by modifying how numbers are stored in the
326 header.
327 .PP
328 One obvious extension to increase the size of files is to
329 eliminate the terminating characters from the various
330 numeric fields.
331 For example, the standard only allows the size field to contain
332 11 octal digits, reserving the twelfth byte for a trailing
333 NUL character.
334 Allowing 12 octal digits allows file sizes up to 64 GB.
335 .PP
336 Another extension, utilized by GNU tar, star, and other newer
337 \fB\%tar\fP
338 implementations, permits binary numbers in the standard numeric fields.
339 This is flagged by setting the high bit of the first byte.
340 The remainder of the field is treated as a signed twos-complement
341 value.
342 This permits 95-bit values for the length and time fields
343 and 63-bit values for the uid, gid, and device numbers.
344 In particular, this provides a consistent way to handle
345 negative time values.
346 GNU tar supports this extension for the
347 length, mtime, ctime, and atime fields.
348 Joerg Schilling's star program and the libarchive library support
349 this extension for all numeric fields.
350 Note that this extension is largely obsoleted by the extended
351 attribute record provided by the pax interchange format.
352 .PP
353 Another early GNU extension allowed base-64 values rather than octal.
354 This extension was short-lived and is no longer supported by any
355 implementation.
356 .SS Pax Interchange Format
357 There are many attributes that cannot be portably stored in a
358 POSIX ustar archive.
359 IEEE Std 1003.1-2001 (``POSIX.1'')
360 defined a
361 ``pax interchange format''
362 that uses two new types of entries to hold text-formatted
363 metadata that applies to following entries.
364 Note that a pax interchange format archive is a ustar archive in every
365 respect.
366 The new data is stored in ustar-compatible archive entries that use the
367 ``x''
368 or
369 ``g''
370 typeflag.
371 In particular, older implementations that do not fully support these
372 extensions will extract the metadata into regular files, where the
373 metadata can be examined as necessary.
374 .PP
375 An entry in a pax interchange format archive consists of one or
376 two standard ustar entries, each with its own header and data.
377 The first optional entry stores the extended attributes
378 for the following entry.
379 This optional first entry has an "x" typeflag and a size field that
380 indicates the total size of the extended attributes.
381 The extended attributes themselves are stored as a series of text-format
382 lines encoded in the portable UTF-8 encoding.
383 Each line consists of a decimal number, a space, a key string, an equals
384 sign, a value string, and a new line.
385 The decimal number indicates the length of the entire line, including the
386 initial length field and the trailing newline.
387 An example of such a field is:
388 .RS 4
389 25 ctime=1084839148.1212\en
390 .RE
391 Keys in all lowercase are standard keys.
392 Vendors can add their own keys by prefixing them with an all uppercase
393 vendor name and a period.
394 Note that, unlike the historic header, numeric values are stored using
395 decimal, not octal.
396 A description of some common keys follows:
397 .RS 5
398 .TP
399 \fBatime\fP, \fBctime\fP, \fBmtime\fP
400 File access, inode change, and modification times.
401 These fields can be negative or include a decimal point and a fractional value.
402 .TP
403 \fBhdrcharset\fP
404 The character set used by the pax extension values.
405 By default, all textual values in the pax extended attributes
406 are assumed to be in UTF-8, including pathnames, user names,
407 and group names.
408 In some cases, it is not possible to translate local
409 conventions into UTF-8.
410 If this key is present and the value is the six-character ASCII string
411 ``BINARY'',
412 then all textual values are assumed to be in a platform-dependent
413 multi-byte encoding.
414 Note that there are only two valid values for this key:
415 ``BINARY''
416 or
417 ``ISO-IR\ 10646\ 2000\ UTF-8''.
418 No other values are permitted by the standard, and
419 the latter value should generally not be used as it is the
420 default when this key is not specified.
421 In particular, this flag should not be used as a general
422 mechanism to allow filenames to be stored in arbitrary
423 encodings.
424 .TP
425 \fBuname\fP, \fBuid\fP, \fBgname\fP, \fBgid\fP
426 User name, group name, and numeric UID and GID values.
427 The user name and group name stored here are encoded in UTF8
428 and can thus include non-ASCII characters.
429 The UID and GID fields can be of arbitrary length.
430 .TP
431 \fBlinkpath\fP
432 The full path of the linked-to file.
433 Note that this is encoded in UTF8 and can thus include non-ASCII characters.
434 .TP
435 \fBpath\fP
436 The full pathname of the entry.
437 Note that this is encoded in UTF8 and can thus include non-ASCII characters.
438 .TP
439 \fBrealtime.*\fP, \fBsecurity.*\fP
440 These keys are reserved and may be used for future standardization.
441 .TP
442 \fBsize\fP
443 The size of the file.
444 Note that there is no length limit on this field, allowing conforming
445 archives to store files much larger than the historic 8GB limit.
446 .TP
447 \fBSCHILY.*\fP
448 Vendor-specific attributes used by Joerg Schilling's
449 \fB\%star\fP
450 implementation.
451 .TP
452 \fBSCHILY.acl.access\fP, \fBSCHILY.acl.default,\fP \fBSCHILY.acl.ace\fP
453 Stores the access, default and NFSv4 ACLs as textual strings in a format
454 that is an extension of the format specified by POSIX.1e draft 17.
455 In particular, each user or group access specification can include
456 an additional colon-separated field with the numeric UID or GID.
457 This allows ACLs to be restored on systems that may not have complete
458 user or group information available (such as when NIS/YP or LDAP services
459 are temporarily unavailable).
460 .TP
461 \fBSCHILY.devminor\fP, \fBSCHILY.devmajor\fP
462 The full minor and major numbers for device nodes.
463 .TP
464 \fBSCHILY.fflags\fP
465 The file flags.
466 .TP
467 \fBSCHILY.realsize\fP
468 The full size of the file on disk.
469 XXX explain? XXX
470 .TP
471 \fBSCHILY.dev,\fP \fBSCHILY.ino\fP, \fBSCHILY.nlinks\fP
472 The device number, inode number, and link count for the entry.
473 In particular, note that a pax interchange format archive using Joerg
474 Schilling's
475 \fBSCHILY.*\fP
476 extensions can store all of the data from
477 \fIstruct\fP stat.
478 .TP
479 \fBLIBARCHIVE.*\fP
480 Vendor-specific attributes used by the
481 \fB\%libarchive\fP
482 library and programs that use it.
483 .TP
484 \fBLIBARCHIVE.creationtime\fP
485 The time when the file was created.
486 (This should not be confused with the POSIX
487 ``ctime''
488 attribute, which refers to the time when the file
489 metadata was last changed.)
490 .TP
491 \fBLIBARCHIVE.xattr.\fP \fInamespace\fP.\fIkey\fP
492 Libarchive stores POSIX.1e-style extended attributes using
493 keys of this form.
494 The
495 \fIkey\fP
496 value is URL-encoded:
497 All non-ASCII characters and the two special characters
498 ``=''
499 and
500 ``%''
501 are encoded as
502 ``%''
503 followed by two uppercase hexadecimal digits.
504 The value of this key is the extended attribute value
505 encoded in base 64.
506 XXX Detail the base-64 format here XXX
507 .TP
508 \fBVENDOR.*\fP
509 XXX document other vendor-specific extensions XXX
510 .RE
511 .PP
512 Any values stored in an extended attribute override the corresponding
513 values in the regular tar header.
514 Note that compliant readers should ignore the regular fields when they
515 are overridden.
516 This is important, as existing archivers are known to store non-compliant
517 values in the standard header fields in this situation.
518 There are no limits on length for any of these fields.
519 In particular, numeric fields can be arbitrarily large.
520 All text fields are encoded in UTF8.
521 Compliant writers should store only portable 7-bit ASCII characters in
522 the standard ustar header and use extended
523 attributes whenever a text value contains non-ASCII characters.
524 .PP
525 In addition to the
526 \fBx\fP
527 entry described above, the pax interchange format
528 also supports a
529 \fBg\fP
530 entry.
531 The
532 \fBg\fP
533 entry is identical in format, but specifies attributes that serve as
534 defaults for all subsequent archive entries.
535 The
536 \fBg\fP
537 entry is not widely used.
538 .PP
539 Besides the new
540 \fBx\fP
541 and
542 \fBg\fP
543 entries, the pax interchange format has a few other minor variations
544 from the earlier ustar format.
545 The most troubling one is that hardlinks are permitted to have
546 data following them.
547 This allows readers to restore any hardlink to a file without
548 having to rewind the archive to find an earlier entry.
549 However, it creates complications for robust readers, as it is no longer
550 clear whether or not they should ignore the size field for hardlink entries.
551 .SS GNU Tar Archives
552 The GNU tar program started with a pre-POSIX format similar to that
553 described earlier and has extended it using several different mechanisms:
554 It added new fields to the empty space in the header (some of which was later
555 used by POSIX for conflicting purposes);
556 it allowed the header to be continued over multiple records;
557 and it defined new entries that modify following entries
558 (similar in principle to the
559 \fBx\fP
560 entry described above, but each GNU special entry is single-purpose,
561 unlike the general-purpose
562 \fBx\fP
563 entry).
564 As a result, GNU tar archives are not POSIX compatible, although
565 more lenient POSIX-compliant readers can successfully extract most
566 GNU tar archives.
567 .RS 4
568 .nf
569 struct header_gnu_tar {
570         char name[100];
571         char mode[8];
572         char uid[8];
573         char gid[8];
574         char size[12];
575         char mtime[12];
576         char checksum[8];
577         char typeflag[1];
578         char linkname[100];
579         char magic[6];
580         char version[2];
581         char uname[32];
582         char gname[32];
583         char devmajor[8];
584         char devminor[8];
585         char atime[12];
586         char ctime[12];
587         char offset[12];
588         char longnames[4];
589         char unused[1];
590         struct {
591                 char offset[12];
592                 char numbytes[12];
593         } sparse[4];
594         char isextended[1];
595         char realsize[12];
596         char pad[17];
597 };
598 .RE
599 .RS 5
600 .TP
601 \fItypeflag\fP
602 GNU tar uses the following special entry types, in addition to
603 those defined by POSIX:
604 .RS 5
605 .TP
606 7
607 GNU tar treats type "7" records identically to type "0" records,
608 except on one obscure RTOS where they are used to indicate the
609 pre-allocation of a contiguous file on disk.
610 .TP
611 D
612 This indicates a directory entry.
613 Unlike the POSIX-standard "5"
614 typeflag, the header is followed by data records listing the names
615 of files in this directory.
616 Each name is preceded by an ASCII "Y"
617 if the file is stored in this archive or "N" if the file is not
618 stored in this archive.
619 Each name is terminated with a null, and
620 an extra null marks the end of the name list.
621 The purpose of this
622 entry is to support incremental backups; a program restoring from
623 such an archive may wish to delete files on disk that did not exist
624 in the directory when the archive was made.
625 .PP
626 Note that the "D" typeflag specifically violates POSIX, which requires
627 that unrecognized typeflags be restored as normal files.
628 In this case, restoring the "D" entry as a file could interfere
629 with subsequent creation of the like-named directory.
630 .TP
631 K
632 The data for this entry is a long linkname for the following regular entry.
633 .TP
634 L
635 The data for this entry is a long pathname for the following regular entry.
636 .TP
637 M
638 This is a continuation of the last file on the previous volume.
639 GNU multi-volume archives guarantee that each volume begins with a valid
640 entry header.
641 To ensure this, a file may be split, with part stored at the end of one volume,
642 and part stored at the beginning of the next volume.
643 The "M" typeflag indicates that this entry continues an existing file.
644 Such entries can only occur as the first or second entry
645 in an archive (the latter only if the first entry is a volume label).
646 The
647 \fIsize\fP
648 field specifies the size of this entry.
649 The
650 \fIoffset\fP
651 field at bytes 369-380 specifies the offset where this file fragment
652 begins.
653 The
654 \fIrealsize\fP
655 field specifies the total size of the file (which must equal
656 \fIsize\fP
657 plus
658 \fIoffset\fP).
659 When extracting, GNU tar checks that the header file name is the one it is
660 expecting, that the header offset is in the correct sequence, and that
661 the sum of offset and size is equal to realsize.
662 .TP
663 N
664 Type "N" records are no longer generated by GNU tar.
665 They contained a
666 list of files to be renamed or symlinked after extraction; this was
667 originally used to support long names.
668 The contents of this record
669 are a text description of the operations to be done, in the form
670 ``Rename %s to %s\en''
671 or
672 ``Symlink %s to %s\en ;''
673 in either case, both
674 filenames are escaped using K&R C syntax.
675 Due to security concerns, "N" records are now generally ignored
676 when reading archives.
677 .TP
678 S
679 This is a
680 ``sparse''
681 regular file.
682 Sparse files are stored as a series of fragments.
683 The header contains a list of fragment offset/length pairs.
684 If more than four such entries are required, the header is
685 extended as necessary with
686 ``extra''
687 header extensions (an older format that is no longer used), or
688 ``sparse''
689 extensions.
690 .TP
691 V
692 The
693 \fIname\fP
694 field should be interpreted as a tape/volume header name.
695 This entry should generally be ignored on extraction.
696 .RE
697 .TP
698 \fImagic\fP
699 The magic field holds the five characters
700 ``ustar''
701 followed by a space.
702 Note that POSIX ustar archives have a trailing null.
703 .TP
704 \fIversion\fP
705 The version field holds a space character followed by a null.
706 Note that POSIX ustar archives use two copies of the ASCII digit
707 ``0''.
708 .TP
709 \fIatime\fP, \fIctime\fP
710 The time the file was last accessed and the time of
711 last change of file information, stored in octal as with
712 \fImtime\fP.
713 .TP
714 \fIlongnames\fP
715 This field is apparently no longer used.
716 .TP
717 Sparse \fIoffset\fP / \fInumbytes\fP
718 Each such structure specifies a single fragment of a sparse
719 file.
720 The two fields store values as octal numbers.
721 The fragments are each padded to a multiple of 512 bytes
722 in the archive.
723 On extraction, the list of fragments is collected from the
724 header (including any extension headers), and the data
725 is then read and written to the file at appropriate offsets.
726 .TP
727 \fIisextended\fP
728 If this is set to non-zero, the header will be followed by additional
729 ``sparse header''
730 records.
731 Each such record contains information about as many as 21 additional
732 sparse blocks as shown here:
733 .RS 4
734 .nf
735 struct gnu_sparse_header {
736         struct {
737                 char offset[12];
738                 char numbytes[12];
739         } sparse[21];
740         char    isextended[1];
741         char    padding[7];
742 };
743 .RE
744 .TP
745 \fIrealsize\fP
746 A binary representation of the file's complete size, with a much larger range
747 than the POSIX file size.
748 In particular, with
749 \fBM\fP
750 type files, the current entry is only a portion of the file.
751 In that case, the POSIX size field will indicate the size of this
752 entry; the
753 \fIrealsize\fP
754 field will indicate the total size of the file.
755 .RE
756 .SS GNU tar pax archives
757 GNU tar 1.14 (XXX check this XXX) and later will write
758 pax interchange format archives when you specify the
759 \fB\--posix\fP
760 flag.
761 This format follows the pax interchange format closely,
762 using some
763 \fBSCHILY\fP
764 tags and introducing new keywords to store sparse file information.
765 There have been three iterations of the sparse file support, referred to
766 as
767 ``0.0'',
768 ``0.1'',
769 and
770 ``1.0''.
771 .RS 5
772 .TP
773 \fBGNU.sparse.numblocks\fP, \fBGNU.sparse.offset\fP, \fBGNU.sparse.numbytes\fP, \fBGNU.sparse.size\fP
774 The
775 ``0.0''
776 format used an initial
777 \fBGNU.sparse.numblocks\fP
778 attribute to indicate the number of blocks in the file, a pair of
779 \fBGNU.sparse.offset\fP
780 and
781 \fBGNU.sparse.numbytes\fP
782 to indicate the offset and size of each block,
783 and a single
784 \fBGNU.sparse.size\fP
785 to indicate the full size of the file.
786 This is not the same as the size in the tar header because the
787 latter value does not include the size of any holes.
788 This format required that the order of attributes be preserved and
789 relied on readers accepting multiple appearances of the same attribute
790 names, which is not officially permitted by the standards.
791 .TP
792 \fBGNU.sparse.map\fP
793 The
794 ``0.1''
795 format used a single attribute that stored a comma-separated
796 list of decimal numbers.
797 Each pair of numbers indicated the offset and size, respectively,
798 of a block of data.
799 This does not work well if the archive is extracted by an archiver
800 that does not recognize this extension, since many pax implementations
801 simply discard unrecognized attributes.
802 .TP
803 \fBGNU.sparse.major\fP, \fBGNU.sparse.minor\fP, \fBGNU.sparse.name\fP, \fBGNU.sparse.realsize\fP
804 The
805 ``1.0''
806 format stores the sparse block map in one or more 512-byte blocks
807 prepended to the file data in the entry body.
808 The pax attributes indicate the existence of this map
809 (via the
810 \fBGNU.sparse.major\fP
811 and
812 \fBGNU.sparse.minor\fP
813 fields)
814 and the full size of the file.
815 The
816 \fBGNU.sparse.name\fP
817 holds the true name of the file.
818 To avoid confusion, the name stored in the regular tar header
819 is a modified name so that extraction errors will be apparent
820 to users.
821 .RE
822 .SS Solaris Tar
823 XXX More Details Needed XXX
824 .PP
825 Solaris tar (beginning with SunOS XXX 5.7 ?? XXX) supports an
826 ``extended''
827 format that is fundamentally similar to pax interchange format,
828 with the following differences:
829 .RS 5
830 .IP \(bu
831 Extended attributes are stored in an entry whose type is
832 \fBX\fP,
833 not
834 \fBx\fP,
835 as used by pax interchange format.
836 The detailed format of this entry appears to be the same
837 as detailed above for the
838 \fBx\fP
839 entry.
840 .IP \(bu
841 An additional
842 \fBA\fP
843 header is used to store an ACL for the following regular entry.
844 The body of this entry contains a seven-digit octal number
845 followed by a zero byte, followed by the
846 textual ACL description.
847 The octal value is the number of ACL entries
848 plus a constant that indicates the ACL type: 01000000
849 for POSIX.1e ACLs and 03000000 for NFSv4 ACLs.
850 .RE
851 .SS AIX Tar
852 XXX More details needed XXX
853 .PP
854 AIX Tar uses a ustar-formatted header with the type
855 \fBA\fP
856 for storing coded ACL information.
857 Unlike the Solaris format, AIX tar writes this header after the
858 regular file body to which it applies.
859 The pathname in this header is either
860 \fBNFS4\fP
861 or
862 \fBAIXC\fP
863 to indicate the type of ACL stored.
864 The actual ACL is stored in platform-specific binary format.
865 .SS Mac OS X Tar
866 The tar distributed with Apple's Mac OS X stores most regular files
867 as two separate files in the tar archive.
868 The two files have the same name except that the first
869 one has
870 ``._''
871 prepended to the last path element.
872 This special file stores an AppleDouble-encoded
873 binary blob with additional metadata about the second file,
874 including ACL, extended attributes, and resources.
875 To recreate the original file on disk, each
876 separate file can be extracted and the Mac OS X
877 \fB\%copyfile\fP()
878 function can be used to unpack the separate
879 metadata file and apply it to th regular file.
880 Conversely, the same function provides a
881 ``pack''
882 option to encode the extended metadata from
883 a file into a separate file whose contents
884 can then be put into a tar archive.
885 .PP
886 Note that the Apple extended attributes interact
887 badly with long filenames.
888 Since each file is stored with the full name,
889 a separate set of extensions needs to be included
890 in the archive for each one, doubling the overhead
891 required for files with long names.
892 .SS Summary of tar type codes
893 The following list is a condensed summary of the type codes
894 used in tar header records generated by different tar implementations.
895 More details about specific implementations can be found above:
896 .RS 5
897 .TP
898 NUL
899 Early tar programs stored a zero byte for regular files.
900 .TP
901 \fB0\fP
902 POSIX standard type code for a regular file.
903 .TP
904 \fB1\fP
905 POSIX standard type code for a hard link description.
906 .TP
907 \fB2\fP
908 POSIX standard type code for a symbolic link description.
909 .TP
910 \fB3\fP
911 POSIX standard type code for a character device node.
912 .TP
913 \fB4\fP
914 POSIX standard type code for a block device node.
915 .TP
916 \fB5\fP
917 POSIX standard type code for a directory.
918 .TP
919 \fB6\fP
920 POSIX standard type code for a FIFO.
921 .TP
922 \fB7\fP
923 POSIX reserved.
924 .TP
925 \fB7\fP
926 GNU tar used for pre-allocated files on some systems.
927 .TP
928 \fBA\fP
929 Solaris tar ACL description stored prior to a regular file header.
930 .TP
931 \fBA\fP
932 AIX tar ACL description stored after the file body.
933 .TP
934 \fBD\fP
935 GNU tar directory dump.
936 .TP
937 \fBK\fP
938 GNU tar long linkname for the following header.
939 .TP
940 \fBL\fP
941 GNU tar long pathname for the following header.
942 .TP
943 \fBM\fP
944 GNU tar multivolume marker, indicating the file is a continuation of a file from the previous volume.
945 .TP
946 \fBN\fP
947 GNU tar long filename support.  Deprecated.
948 .TP
949 \fBS\fP
950 GNU tar sparse regular file.
951 .TP
952 \fBV\fP
953 GNU tar tape/volume header name.
954 .TP
955 \fBX\fP
956 Solaris tar general-purpose extension header.
957 .TP
958 \fBg\fP
959 POSIX pax interchange format global extensions.
960 .TP
961 \fBx\fP
962 POSIX pax interchange format per-file extensions.
963 .RE
964 .SH SEE ALSO
965 .ad l
966 \fBar\fP(1),
967 \fBpax\fP(1),
968 \fBtar\fP(1)
969 .SH STANDARDS
970 .ad l
971 The
972 \fB\%tar\fP
973 utility is no longer a part of POSIX or the Single Unix Standard.
974 It last appeared in
975 Version 2 of the Single UNIX Specification (``SUSv2'').
976 It has been supplanted in subsequent standards by
977 \fBpax\fP(1).
978 The ustar format is currently part of the specification for the
979 \fBpax\fP(1)
980 utility.
981 The pax interchange file format is new with
982 IEEE Std 1003.1-2001 (``POSIX.1'').
983 .SH HISTORY
984 .ad l
985 A
986 \fB\%tar\fP
987 command appeared in Seventh Edition Unix, which was released in January, 1979.
988 It replaced the
989 \fB\%tp\fP
990 program from Fourth Edition Unix which in turn replaced the
991 \fB\%tap\fP
992 program from First Edition Unix.
993 John Gilmore's
994 \fB\%pdtar\fP
995 public-domain implementation (circa 1987) was highly influential
996 and formed the basis of
997 \fB\%GNU\fP tar
998 (circa 1988).
999 Joerg Shilling's
1000 \fB\%star\fP
1001 archiver is another open-source (CDDL) archiver (originally developed
1002 circa 1985) which features complete support for pax interchange
1003 format.
1004 .PP
1005 This documentation was written as part of the
1006 \fB\%libarchive\fP
1007 and
1008 \fB\%bsdtar\fP
1009 project by
1010 Tim Kientzle \%<kientzle@FreeBSD.org.>