xref: /dflybsd-src/contrib/libarchive/libarchive/tar.5 (revision 085658de3b7b6902c031532118aeb6a4246171ae)
19c82a63eSPeter Avalos.\" Copyright (c) 2003-2009 Tim Kientzle
2e95abc47Szrj.\" Copyright (c) 2016 Martin Matuska
360b4ad09SPeter Avalos.\" All rights reserved.
460b4ad09SPeter Avalos.\"
560b4ad09SPeter Avalos.\" Redistribution and use in source and binary forms, with or without
660b4ad09SPeter Avalos.\" modification, are permitted provided that the following conditions
760b4ad09SPeter Avalos.\" are met:
860b4ad09SPeter Avalos.\" 1. Redistributions of source code must retain the above copyright
960b4ad09SPeter Avalos.\"    notice, this list of conditions and the following disclaimer.
1060b4ad09SPeter Avalos.\" 2. Redistributions in binary form must reproduce the above copyright
1160b4ad09SPeter Avalos.\"    notice, this list of conditions and the following disclaimer in the
1260b4ad09SPeter Avalos.\"    documentation and/or other materials provided with the distribution.
1360b4ad09SPeter Avalos.\"
1460b4ad09SPeter Avalos.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1560b4ad09SPeter Avalos.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1660b4ad09SPeter Avalos.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1760b4ad09SPeter Avalos.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1860b4ad09SPeter Avalos.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1960b4ad09SPeter Avalos.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2060b4ad09SPeter Avalos.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2160b4ad09SPeter Avalos.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2260b4ad09SPeter Avalos.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2360b4ad09SPeter Avalos.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2460b4ad09SPeter Avalos.\" SUCH DAMAGE.
2560b4ad09SPeter Avalos.\"
2659bf7050SPeter Avalos.\" $FreeBSD$
2760b4ad09SPeter Avalos.\"
28e95abc47Szrj.Dd December 27, 2016
29c09f92d2SPeter Avalos.Dt TAR 5
3060b4ad09SPeter Avalos.Os
3160b4ad09SPeter Avalos.Sh NAME
3260b4ad09SPeter Avalos.Nm tar
3360b4ad09SPeter Avalos.Nd format of tape archive files
3460b4ad09SPeter Avalos.Sh DESCRIPTION
3560b4ad09SPeter AvalosThe
3660b4ad09SPeter Avalos.Nm
3760b4ad09SPeter Avalosarchive format collects any number of files, directories, and other
3860b4ad09SPeter Avalosfile system objects (symbolic links, device nodes, etc.) into a single
3960b4ad09SPeter Avalosstream of bytes.
4060b4ad09SPeter AvalosThe format was originally designed to be used with
4160b4ad09SPeter Avalostape drives that operate with fixed-size blocks, but is widely used as
4260b4ad09SPeter Avalosa general packaging mechanism.
4360b4ad09SPeter Avalos.Ss General Format
4460b4ad09SPeter AvalosA
4560b4ad09SPeter Avalos.Nm
4660b4ad09SPeter Avalosarchive consists of a series of 512-byte records.
4760b4ad09SPeter AvalosEach file system object requires a header record which stores basic metadata
4860b4ad09SPeter Avalos(pathname, owner, permissions, etc.) and zero or more records containing any
4960b4ad09SPeter Avalosfile data.
5060b4ad09SPeter AvalosThe end of the archive is indicated by two records consisting
5160b4ad09SPeter Avalosentirely of zero bytes.
5260b4ad09SPeter Avalos.Pp
5360b4ad09SPeter AvalosFor compatibility with tape drives that use fixed block sizes,
5460b4ad09SPeter Avalosprograms that read or write tar files always read or write a fixed
5560b4ad09SPeter Avalosnumber of records with each I/O operation.
5660b4ad09SPeter AvalosThese
5760b4ad09SPeter Avalos.Dq blocks
5860b4ad09SPeter Avalosare always a multiple of the record size.
599c82a63eSPeter AvalosThe maximum block size supported by early
609c82a63eSPeter Avalosimplementations was 10240 bytes or 20 records.
619c82a63eSPeter AvalosThis is still the default for most implementations
629c82a63eSPeter Avalosalthough block sizes of 1MiB (2048 records) or larger are
639c82a63eSPeter Avaloscommonly used with modern high-speed tape drives.
6460b4ad09SPeter Avalos(Note: the terms
6560b4ad09SPeter Avalos.Dq block
6660b4ad09SPeter Avalosand
6760b4ad09SPeter Avalos.Dq record
6860b4ad09SPeter Avaloshere are not entirely standard; this document follows the
6960b4ad09SPeter Avalosconvention established by John Gilmore in documenting
7060b4ad09SPeter Avalos.Nm pdtar . )
7160b4ad09SPeter Avalos.Ss Old-Style Archive Format
7260b4ad09SPeter AvalosThe original tar archive format has been extended many times to
7360b4ad09SPeter Avalosinclude additional information that various implementors found
7460b4ad09SPeter Avalosnecessary.
7560b4ad09SPeter AvalosThis section describes the variant implemented by the tar command
7660b4ad09SPeter Avalosincluded in
7760b4ad09SPeter Avalos.At v7 ,
789c82a63eSPeter Avaloswhich seems to be the earliest widely-used version of the tar program.
7960b4ad09SPeter Avalos.Pp
8060b4ad09SPeter AvalosThe header record for an old-style
8160b4ad09SPeter Avalos.Nm
8260b4ad09SPeter Avalosarchive consists of the following:
8360b4ad09SPeter Avalos.Bd -literal -offset indent
8460b4ad09SPeter Avalosstruct header_old_tar {
8560b4ad09SPeter Avalos	char name[100];
8660b4ad09SPeter Avalos	char mode[8];
8760b4ad09SPeter Avalos	char uid[8];
8860b4ad09SPeter Avalos	char gid[8];
8960b4ad09SPeter Avalos	char size[12];
9060b4ad09SPeter Avalos	char mtime[12];
9160b4ad09SPeter Avalos	char checksum[8];
9260b4ad09SPeter Avalos	char linkflag[1];
9360b4ad09SPeter Avalos	char linkname[100];
9460b4ad09SPeter Avalos	char pad[255];
9560b4ad09SPeter Avalos};
9660b4ad09SPeter Avalos.Ed
9760b4ad09SPeter AvalosAll unused bytes in the header record are filled with nulls.
9860b4ad09SPeter Avalos.Bl -tag -width indent
9960b4ad09SPeter Avalos.It Va name
10060b4ad09SPeter AvalosPathname, stored as a null-terminated string.
10160b4ad09SPeter AvalosEarly tar implementations only stored regular files (including
10260b4ad09SPeter Avaloshardlinks to those files).
10360b4ad09SPeter AvalosOne common early convention used a trailing "/" character to indicate
10460b4ad09SPeter Avalosa directory name, allowing directory permissions and owner information
10560b4ad09SPeter Avalosto be archived and restored.
10660b4ad09SPeter Avalos.It Va mode
10760b4ad09SPeter AvalosFile mode, stored as an octal number in ASCII.
10860b4ad09SPeter Avalos.It Va uid , Va gid
10960b4ad09SPeter AvalosUser id and group id of owner, as octal numbers in ASCII.
11060b4ad09SPeter Avalos.It Va size
11160b4ad09SPeter AvalosSize of file, as octal number in ASCII.
11260b4ad09SPeter AvalosFor regular files only, this indicates the amount of data
11360b4ad09SPeter Avalosthat follows the header.
11460b4ad09SPeter AvalosIn particular, this field was ignored by early tar implementations
11560b4ad09SPeter Avaloswhen extracting hardlinks.
11660b4ad09SPeter AvalosModern writers should always store a zero length for hardlink entries.
11760b4ad09SPeter Avalos.It Va mtime
11860b4ad09SPeter AvalosModification time of file, as an octal number in ASCII.
11960b4ad09SPeter AvalosThis indicates the number of seconds since the start of the epoch,
12060b4ad09SPeter Avalos00:00:00 UTC January 1, 1970.
12160b4ad09SPeter AvalosNote that negative values should be avoided
12260b4ad09SPeter Avaloshere, as they are handled inconsistently.
12360b4ad09SPeter Avalos.It Va checksum
12460b4ad09SPeter AvalosHeader checksum, stored as an octal number in ASCII.
12560b4ad09SPeter AvalosTo compute the checksum, set the checksum field to all spaces,
12660b4ad09SPeter Avalosthen sum all bytes in the header using unsigned arithmetic.
12760b4ad09SPeter AvalosThis field should be stored as six octal digits followed by a null and a space
12860b4ad09SPeter Avaloscharacter.
12960b4ad09SPeter AvalosNote that many early implementations of tar used signed arithmetic
13060b4ad09SPeter Avalosfor the checksum field, which can cause interoperability problems
13160b4ad09SPeter Avaloswhen transferring archives between systems.
13260b4ad09SPeter AvalosModern robust readers compute the checksum both ways and accept the
13360b4ad09SPeter Avalosheader if either computation matches.
13460b4ad09SPeter Avalos.It Va linkflag , Va linkname
13560b4ad09SPeter AvalosIn order to preserve hardlinks and conserve tape, a file
13660b4ad09SPeter Avaloswith multiple links is only written to the archive the first
13760b4ad09SPeter Avalostime it is encountered.
13860b4ad09SPeter AvalosThe next time it is encountered, the
13960b4ad09SPeter Avalos.Va linkflag
14060b4ad09SPeter Avalosis set to an ASCII
14160b4ad09SPeter Avalos.Sq 1
14260b4ad09SPeter Avalosand the
14360b4ad09SPeter Avalos.Va linkname
14460b4ad09SPeter Avalosfield holds the first name under which this file appears.
14560b4ad09SPeter Avalos(Note that regular files have a null value in the
14660b4ad09SPeter Avalos.Va linkflag
14760b4ad09SPeter Avalosfield.)
14860b4ad09SPeter Avalos.El
14960b4ad09SPeter Avalos.Pp
15060b4ad09SPeter AvalosEarly tar implementations varied in how they terminated these fields.
15160b4ad09SPeter AvalosThe tar command in
15260b4ad09SPeter Avalos.At v7
15360b4ad09SPeter Avalosused the following conventions (this is also documented in early BSD manpages):
15460b4ad09SPeter Avalosthe pathname must be null-terminated;
15560b4ad09SPeter Avalosthe mode, uid, and gid fields must end in a space and a null byte;
15660b4ad09SPeter Avalosthe size and mtime fields must end in a space;
15760b4ad09SPeter Avalosthe checksum is terminated by a null and a space.
15860b4ad09SPeter AvalosEarly implementations filled the numeric fields with leading spaces.
15960b4ad09SPeter AvalosThis seems to have been common practice until the
16060b4ad09SPeter Avalos.St -p1003.1-88
16160b4ad09SPeter Avalosstandard was released.
16260b4ad09SPeter AvalosFor best portability, modern implementations should fill the numeric
16360b4ad09SPeter Avalosfields with leading zeros.
16460b4ad09SPeter Avalos.Ss Pre-POSIX Archives
16560b4ad09SPeter AvalosAn early draft of
16660b4ad09SPeter Avalos.St -p1003.1-88
16760b4ad09SPeter Avalosserved as the basis for John Gilmore's
16860b4ad09SPeter Avalos.Nm pdtar
16960b4ad09SPeter Avalosprogram and many system implementations from the late 1980s
17060b4ad09SPeter Avalosand early 1990s.
17160b4ad09SPeter AvalosThese archives generally follow the POSIX ustar
17260b4ad09SPeter Avalosformat described below with the following variations:
17360b4ad09SPeter Avalos.Bl -bullet -compact -width indent
17460b4ad09SPeter Avalos.It
175c09f92d2SPeter AvalosThe magic value consists of the five characters
176c09f92d2SPeter Avalos.Dq ustar
177c09f92d2SPeter Avalosfollowed by a space.
17860b4ad09SPeter AvalosThe version field contains a space character followed by a null.
17960b4ad09SPeter Avalos.It
18060b4ad09SPeter AvalosThe numeric fields are generally filled with leading spaces
18160b4ad09SPeter Avalos(not leading zeros as recommended in the final standard).
18260b4ad09SPeter Avalos.It
18360b4ad09SPeter AvalosThe prefix field is often not used, limiting pathnames to
18460b4ad09SPeter Avalosthe 100 characters of old-style archives.
18560b4ad09SPeter Avalos.El
18660b4ad09SPeter Avalos.Ss POSIX ustar Archives
18760b4ad09SPeter Avalos.St -p1003.1-88
18860b4ad09SPeter Avalosdefined a standard tar file format to be read and written
18960b4ad09SPeter Avalosby compliant implementations of
19060b4ad09SPeter Avalos.Xr tar 1 .
19160b4ad09SPeter AvalosThis format is often called the
19260b4ad09SPeter Avalos.Dq ustar
19360b4ad09SPeter Avalosformat, after the magic value used
19460b4ad09SPeter Avalosin the header.
19560b4ad09SPeter Avalos(The name is an acronym for
19660b4ad09SPeter Avalos.Dq Unix Standard TAR . )
19760b4ad09SPeter AvalosIt extends the historic format with new fields:
19860b4ad09SPeter Avalos.Bd -literal -offset indent
19960b4ad09SPeter Avalosstruct header_posix_ustar {
20060b4ad09SPeter Avalos	char name[100];
20160b4ad09SPeter Avalos	char mode[8];
20260b4ad09SPeter Avalos	char uid[8];
20360b4ad09SPeter Avalos	char gid[8];
20460b4ad09SPeter Avalos	char size[12];
20560b4ad09SPeter Avalos	char mtime[12];
20660b4ad09SPeter Avalos	char checksum[8];
20760b4ad09SPeter Avalos	char typeflag[1];
20860b4ad09SPeter Avalos	char linkname[100];
20960b4ad09SPeter Avalos	char magic[6];
21060b4ad09SPeter Avalos	char version[2];
21160b4ad09SPeter Avalos	char uname[32];
21260b4ad09SPeter Avalos	char gname[32];
21360b4ad09SPeter Avalos	char devmajor[8];
21460b4ad09SPeter Avalos	char devminor[8];
21560b4ad09SPeter Avalos	char prefix[155];
21660b4ad09SPeter Avalos	char pad[12];
21760b4ad09SPeter Avalos};
21860b4ad09SPeter Avalos.Ed
21960b4ad09SPeter Avalos.Bl -tag -width indent
22060b4ad09SPeter Avalos.It Va typeflag
22160b4ad09SPeter AvalosType of entry.
22260b4ad09SPeter AvalosPOSIX extended the earlier
22360b4ad09SPeter Avalos.Va linkflag
22460b4ad09SPeter Avalosfield with several new type values:
22560b4ad09SPeter Avalos.Bl -tag -width indent -compact
22660b4ad09SPeter Avalos.It Dq 0
22760b4ad09SPeter AvalosRegular file.
22860b4ad09SPeter AvalosNUL should be treated as a synonym, for compatibility purposes.
22960b4ad09SPeter Avalos.It Dq 1
23060b4ad09SPeter AvalosHard link.
23160b4ad09SPeter Avalos.It Dq 2
23260b4ad09SPeter AvalosSymbolic link.
23360b4ad09SPeter Avalos.It Dq 3
23460b4ad09SPeter AvalosCharacter device node.
23560b4ad09SPeter Avalos.It Dq 4
23660b4ad09SPeter AvalosBlock device node.
23760b4ad09SPeter Avalos.It Dq 5
23860b4ad09SPeter AvalosDirectory.
23960b4ad09SPeter Avalos.It Dq 6
24060b4ad09SPeter AvalosFIFO node.
24160b4ad09SPeter Avalos.It Dq 7
24260b4ad09SPeter AvalosReserved.
24360b4ad09SPeter Avalos.It Other
24460b4ad09SPeter AvalosA POSIX-compliant implementation must treat any unrecognized typeflag value
24560b4ad09SPeter Avalosas a regular file.
24660b4ad09SPeter AvalosIn particular, writers should ensure that all entries
24760b4ad09SPeter Avaloshave a valid filename so that they can be restored by readers that do not
24860b4ad09SPeter Avalossupport the corresponding extension.
24960b4ad09SPeter AvalosUppercase letters "A" through "Z" are reserved for custom extensions.
25060b4ad09SPeter AvalosNote that sockets and whiteout entries are not archivable.
25160b4ad09SPeter Avalos.El
25260b4ad09SPeter AvalosIt is worth noting that the
25360b4ad09SPeter Avalos.Va size
25460b4ad09SPeter Avalosfield, in particular, has different meanings depending on the type.
25560b4ad09SPeter AvalosFor regular files, of course, it indicates the amount of data
25660b4ad09SPeter Avalosfollowing the header.
25760b4ad09SPeter AvalosFor directories, it may be used to indicate the total size of all
25860b4ad09SPeter Avalosfiles in the directory, for use by operating systems that pre-allocate
25960b4ad09SPeter Avalosdirectory space.
26060b4ad09SPeter AvalosFor all other types, it should be set to zero by writers and ignored
26160b4ad09SPeter Avalosby readers.
26260b4ad09SPeter Avalos.It Va magic
26360b4ad09SPeter AvalosContains the magic value
26460b4ad09SPeter Avalos.Dq ustar
26560b4ad09SPeter Avalosfollowed by a NUL byte to indicate that this is a POSIX standard archive.
26660b4ad09SPeter AvalosFull compliance requires the uname and gname fields be properly set.
26760b4ad09SPeter Avalos.It Va version
26860b4ad09SPeter AvalosVersion.
26960b4ad09SPeter AvalosThis should be
27060b4ad09SPeter Avalos.Dq 00
27160b4ad09SPeter Avalos(two copies of the ASCII digit zero) for POSIX standard archives.
27260b4ad09SPeter Avalos.It Va uname , Va gname
27360b4ad09SPeter AvalosUser and group names, as null-terminated ASCII strings.
27460b4ad09SPeter AvalosThese should be used in preference to the uid/gid values
27560b4ad09SPeter Avaloswhen they are set and the corresponding names exist on
27660b4ad09SPeter Avalosthe system.
27760b4ad09SPeter Avalos.It Va devmajor , Va devminor
27860b4ad09SPeter AvalosMajor and minor numbers for character device or block device entry.
2799c82a63eSPeter Avalos.It Va name , Va prefix
28060b4ad09SPeter AvalosIf the pathname is too long to fit in the 100 bytes provided by the standard
28160b4ad09SPeter Avalosformat, it can be split at any
28260b4ad09SPeter Avalos.Pa /
2839c82a63eSPeter Avaloscharacter with the first portion going into the prefix field.
28460b4ad09SPeter AvalosIf the prefix field is not empty, the reader will prepend
28560b4ad09SPeter Avalosthe prefix value and a
28660b4ad09SPeter Avalos.Pa /
28760b4ad09SPeter Avaloscharacter to the regular name field to obtain the full pathname.
2889c82a63eSPeter AvalosThe standard does not require a trailing
2899c82a63eSPeter Avalos.Pa /
2909c82a63eSPeter Avaloscharacter on directory names, though most implementations still
2919c82a63eSPeter Avalosinclude this for compatibility reasons.
29260b4ad09SPeter Avalos.El
29360b4ad09SPeter Avalos.Pp
29460b4ad09SPeter AvalosNote that all unused bytes must be set to
29560b4ad09SPeter Avalos.Dv NUL .
29660b4ad09SPeter Avalos.Pp
29760b4ad09SPeter AvalosField termination is specified slightly differently by POSIX
29860b4ad09SPeter Avalosthan by previous implementations.
29960b4ad09SPeter AvalosThe
30060b4ad09SPeter Avalos.Va magic ,
30160b4ad09SPeter Avalos.Va uname ,
30260b4ad09SPeter Avalosand
30360b4ad09SPeter Avalos.Va gname
30460b4ad09SPeter Avalosfields must have a trailing
30560b4ad09SPeter Avalos.Dv NUL .
30660b4ad09SPeter AvalosThe
30760b4ad09SPeter Avalos.Va pathname ,
30860b4ad09SPeter Avalos.Va linkname ,
30960b4ad09SPeter Avalosand
31060b4ad09SPeter Avalos.Va prefix
31160b4ad09SPeter Avalosfields must have a trailing
31260b4ad09SPeter Avalos.Dv NUL
31360b4ad09SPeter Avalosunless they fill the entire field.
31460b4ad09SPeter Avalos(In particular, it is possible to store a 256-character pathname if it
31560b4ad09SPeter Avaloshappens to have a
31660b4ad09SPeter Avalos.Pa /
31760b4ad09SPeter Avalosas the 156th character.)
3189c82a63eSPeter AvalosPOSIX requires numeric fields to be zero-padded in the front, and requires
31960b4ad09SPeter Avalosthem to be terminated with either space or
32060b4ad09SPeter Avalos.Dv NUL
32160b4ad09SPeter Avaloscharacters.
32260b4ad09SPeter Avalos.Pp
32360b4ad09SPeter AvalosCurrently, most tar implementations comply with the ustar
32460b4ad09SPeter Avalosformat, occasionally extending it by adding new fields to the
32560b4ad09SPeter Avalosblank area at the end of the header record.
326c09f92d2SPeter Avalos.Ss Numeric Extensions
327c09f92d2SPeter AvalosThere have been several attempts to extend the range of sizes
328c09f92d2SPeter Avalosor times supported by modifying how numbers are stored in the
329c09f92d2SPeter Avalosheader.
330c09f92d2SPeter Avalos.Pp
331c09f92d2SPeter AvalosOne obvious extension to increase the size of files is to
332c09f92d2SPeter Avaloseliminate the terminating characters from the various
333c09f92d2SPeter Avalosnumeric fields.
334c09f92d2SPeter AvalosFor example, the standard only allows the size field to contain
335c09f92d2SPeter Avalos11 octal digits, reserving the twelfth byte for a trailing
336c09f92d2SPeter AvalosNUL character.
337c09f92d2SPeter AvalosAllowing 12 octal digits allows file sizes up to 64 GB.
338c09f92d2SPeter Avalos.Pp
339c09f92d2SPeter AvalosAnother extension, utilized by GNU tar, star, and other newer
340c09f92d2SPeter Avalos.Nm
341c09f92d2SPeter Avalosimplementations, permits binary numbers in the standard numeric fields.
342c09f92d2SPeter AvalosThis is flagged by setting the high bit of the first byte.
343c09f92d2SPeter AvalosThe remainder of the field is treated as a signed twos-complement
344c09f92d2SPeter Avalosvalue.
345c09f92d2SPeter AvalosThis permits 95-bit values for the length and time fields
346c09f92d2SPeter Avalosand 63-bit values for the uid, gid, and device numbers.
347c09f92d2SPeter AvalosIn particular, this provides a consistent way to handle
348c09f92d2SPeter Avalosnegative time values.
349c09f92d2SPeter AvalosGNU tar supports this extension for the
350c09f92d2SPeter Avaloslength, mtime, ctime, and atime fields.
351c09f92d2SPeter AvalosJoerg Schilling's star program and the libarchive library support
352c09f92d2SPeter Avalosthis extension for all numeric fields.
353c09f92d2SPeter AvalosNote that this extension is largely obsoleted by the extended
354c09f92d2SPeter Avalosattribute record provided by the pax interchange format.
355c09f92d2SPeter Avalos.Pp
356c09f92d2SPeter AvalosAnother early GNU extension allowed base-64 values rather than octal.
357c09f92d2SPeter AvalosThis extension was short-lived and is no longer supported by any
358c09f92d2SPeter Avalosimplementation.
35960b4ad09SPeter Avalos.Ss Pax Interchange Format
36060b4ad09SPeter AvalosThere are many attributes that cannot be portably stored in a
36160b4ad09SPeter AvalosPOSIX ustar archive.
36260b4ad09SPeter Avalos.St -p1003.1-2001
36360b4ad09SPeter Avalosdefined a
36460b4ad09SPeter Avalos.Dq pax interchange format
36560b4ad09SPeter Avalosthat uses two new types of entries to hold text-formatted
36660b4ad09SPeter Avalosmetadata that applies to following entries.
36760b4ad09SPeter AvalosNote that a pax interchange format archive is a ustar archive in every
36860b4ad09SPeter Avalosrespect.
36960b4ad09SPeter AvalosThe new data is stored in ustar-compatible archive entries that use the
37060b4ad09SPeter Avalos.Dq x
37160b4ad09SPeter Avalosor
37260b4ad09SPeter Avalos.Dq g
37360b4ad09SPeter Avalostypeflag.
37460b4ad09SPeter AvalosIn particular, older implementations that do not fully support these
37560b4ad09SPeter Avalosextensions will extract the metadata into regular files, where the
37660b4ad09SPeter Avalosmetadata can be examined as necessary.
37760b4ad09SPeter Avalos.Pp
37860b4ad09SPeter AvalosAn entry in a pax interchange format archive consists of one or
37960b4ad09SPeter Avalostwo standard ustar entries, each with its own header and data.
38060b4ad09SPeter AvalosThe first optional entry stores the extended attributes
38160b4ad09SPeter Avalosfor the following entry.
38260b4ad09SPeter AvalosThis optional first entry has an "x" typeflag and a size field that
38360b4ad09SPeter Avalosindicates the total size of the extended attributes.
38460b4ad09SPeter AvalosThe extended attributes themselves are stored as a series of text-format
38560b4ad09SPeter Avaloslines encoded in the portable UTF-8 encoding.
38660b4ad09SPeter AvalosEach line consists of a decimal number, a space, a key string, an equals
38760b4ad09SPeter Avalossign, a value string, and a new line.
38860b4ad09SPeter AvalosThe decimal number indicates the length of the entire line, including the
38960b4ad09SPeter Avalosinitial length field and the trailing newline.
39060b4ad09SPeter AvalosAn example of such a field is:
39160b4ad09SPeter Avalos.Dl 25 ctime=1084839148.1212\en
39260b4ad09SPeter AvalosKeys in all lowercase are standard keys.
39360b4ad09SPeter AvalosVendors can add their own keys by prefixing them with an all uppercase
39460b4ad09SPeter Avalosvendor name and a period.
39560b4ad09SPeter AvalosNote that, unlike the historic header, numeric values are stored using
39660b4ad09SPeter Avalosdecimal, not octal.
39760b4ad09SPeter AvalosA description of some common keys follows:
39860b4ad09SPeter Avalos.Bl -tag -width indent
39960b4ad09SPeter Avalos.It Cm atime , Cm ctime , Cm mtime
40060b4ad09SPeter AvalosFile access, inode change, and modification times.
40160b4ad09SPeter AvalosThese fields can be negative or include a decimal point and a fractional value.
402c09f92d2SPeter Avalos.It Cm hdrcharset
403c09f92d2SPeter AvalosThe character set used by the pax extension values.
404c09f92d2SPeter AvalosBy default, all textual values in the pax extended attributes
405c09f92d2SPeter Avalosare assumed to be in UTF-8, including pathnames, user names,
406c09f92d2SPeter Avalosand group names.
407c09f92d2SPeter AvalosIn some cases, it is not possible to translate local
408c09f92d2SPeter Avalosconventions into UTF-8.
409c09f92d2SPeter AvalosIf this key is present and the value is the six-character ASCII string
410c09f92d2SPeter Avalos.Dq BINARY ,
411c09f92d2SPeter Avalosthen all textual values are assumed to be in a platform-dependent
412c09f92d2SPeter Avalosmulti-byte encoding.
413c09f92d2SPeter AvalosNote that there are only two valid values for this key:
414c09f92d2SPeter Avalos.Dq BINARY
415c09f92d2SPeter Avalosor
416c09f92d2SPeter Avalos.Dq ISO-IR\ 10646\ 2000\ UTF-8 .
417c09f92d2SPeter AvalosNo other values are permitted by the standard, and
418c09f92d2SPeter Avalosthe latter value should generally not be used as it is the
419c09f92d2SPeter Avalosdefault when this key is not specified.
420c09f92d2SPeter AvalosIn particular, this flag should not be used as a general
421c09f92d2SPeter Avalosmechanism to allow filenames to be stored in arbitrary
422c09f92d2SPeter Avalosencodings.
42360b4ad09SPeter Avalos.It Cm uname , Cm uid , Cm gname , Cm gid
42460b4ad09SPeter AvalosUser name, group name, and numeric UID and GID values.
42560b4ad09SPeter AvalosThe user name and group name stored here are encoded in UTF8
42660b4ad09SPeter Avalosand can thus include non-ASCII characters.
42760b4ad09SPeter AvalosThe UID and GID fields can be of arbitrary length.
42860b4ad09SPeter Avalos.It Cm linkpath
42960b4ad09SPeter AvalosThe full path of the linked-to file.
43060b4ad09SPeter AvalosNote that this is encoded in UTF8 and can thus include non-ASCII characters.
43160b4ad09SPeter Avalos.It Cm path
43260b4ad09SPeter AvalosThe full pathname of the entry.
43360b4ad09SPeter AvalosNote that this is encoded in UTF8 and can thus include non-ASCII characters.
43460b4ad09SPeter Avalos.It Cm realtime.* , Cm security.*
43560b4ad09SPeter AvalosThese keys are reserved and may be used for future standardization.
43660b4ad09SPeter Avalos.It Cm size
43760b4ad09SPeter AvalosThe size of the file.
43860b4ad09SPeter AvalosNote that there is no length limit on this field, allowing conforming
43960b4ad09SPeter Avalosarchives to store files much larger than the historic 8GB limit.
44060b4ad09SPeter Avalos.It Cm SCHILY.*
44160b4ad09SPeter AvalosVendor-specific attributes used by Joerg Schilling's
44260b4ad09SPeter Avalos.Nm star
44360b4ad09SPeter Avalosimplementation.
444e95abc47Szrj.It Cm SCHILY.acl.access , Cm SCHILY.acl.default , Cm SCHILY.acl.ace
445e95abc47SzrjStores the access, default and NFSv4 ACLs as textual strings in a format
44660b4ad09SPeter Avalosthat is an extension of the format specified by POSIX.1e draft 17.
447e95abc47SzrjIn particular, each user or group access specification can include
448e95abc47Szrjan additional colon-separated field with the numeric UID or GID.
44960b4ad09SPeter AvalosThis allows ACLs to be restored on systems that may not have complete
45060b4ad09SPeter Avalosuser or group information available (such as when NIS/YP or LDAP services
45160b4ad09SPeter Avalosare temporarily unavailable).
45260b4ad09SPeter Avalos.It Cm SCHILY.devminor , Cm SCHILY.devmajor
45360b4ad09SPeter AvalosThe full minor and major numbers for device nodes.
4549c82a63eSPeter Avalos.It Cm SCHILY.fflags
4559c82a63eSPeter AvalosThe file flags.
4569c82a63eSPeter Avalos.It Cm SCHILY.realsize
4579c82a63eSPeter AvalosThe full size of the file on disk.
4589c82a63eSPeter AvalosXXX explain? XXX
45960b4ad09SPeter Avalos.It Cm SCHILY.dev , Cm SCHILY.ino , Cm SCHILY.nlinks
46060b4ad09SPeter AvalosThe device number, inode number, and link count for the entry.
46160b4ad09SPeter AvalosIn particular, note that a pax interchange format archive using Joerg
46260b4ad09SPeter AvalosSchilling's
46360b4ad09SPeter Avalos.Cm SCHILY.*
46460b4ad09SPeter Avalosextensions can store all of the data from
46560b4ad09SPeter Avalos.Va struct stat .
466c09f92d2SPeter Avalos.It Cm LIBARCHIVE.*
467c09f92d2SPeter AvalosVendor-specific attributes used by the
468c09f92d2SPeter Avalos.Nm libarchive
469c09f92d2SPeter Avaloslibrary and programs that use it.
470c09f92d2SPeter Avalos.It Cm LIBARCHIVE.creationtime
471c09f92d2SPeter AvalosThe time when the file was created.
472c09f92d2SPeter Avalos(This should not be confused with the POSIX
473c09f92d2SPeter Avalos.Dq ctime
474c09f92d2SPeter Avalosattribute, which refers to the time when the file
475c09f92d2SPeter Avalosmetadata was last changed.)
476*085658deSDaniel Fojt.It Cm LIBARCHIVE.xattr . Ns Ar namespace . Ns Ar key
47760b4ad09SPeter AvalosLibarchive stores POSIX.1e-style extended attributes using
47860b4ad09SPeter Avaloskeys of this form.
47960b4ad09SPeter AvalosThe
48060b4ad09SPeter Avalos.Ar key
48160b4ad09SPeter Avalosvalue is URL-encoded:
48260b4ad09SPeter AvalosAll non-ASCII characters and the two special characters
48360b4ad09SPeter Avalos.Dq =
48460b4ad09SPeter Avalosand
48560b4ad09SPeter Avalos.Dq %
48660b4ad09SPeter Avalosare encoded as
48760b4ad09SPeter Avalos.Dq %
48860b4ad09SPeter Avalosfollowed by two uppercase hexadecimal digits.
48960b4ad09SPeter AvalosThe value of this key is the extended attribute value
49060b4ad09SPeter Avalosencoded in base 64.
49160b4ad09SPeter AvalosXXX Detail the base-64 format here XXX
49260b4ad09SPeter Avalos.It Cm VENDOR.*
49360b4ad09SPeter AvalosXXX document other vendor-specific extensions XXX
49460b4ad09SPeter Avalos.El
49560b4ad09SPeter Avalos.Pp
49660b4ad09SPeter AvalosAny values stored in an extended attribute override the corresponding
49760b4ad09SPeter Avalosvalues in the regular tar header.
49860b4ad09SPeter AvalosNote that compliant readers should ignore the regular fields when they
49960b4ad09SPeter Avalosare overridden.
50060b4ad09SPeter AvalosThis is important, as existing archivers are known to store non-compliant
50160b4ad09SPeter Avalosvalues in the standard header fields in this situation.
50260b4ad09SPeter AvalosThere are no limits on length for any of these fields.
50360b4ad09SPeter AvalosIn particular, numeric fields can be arbitrarily large.
50460b4ad09SPeter AvalosAll text fields are encoded in UTF8.
50560b4ad09SPeter AvalosCompliant writers should store only portable 7-bit ASCII characters in
50660b4ad09SPeter Avalosthe standard ustar header and use extended
50760b4ad09SPeter Avalosattributes whenever a text value contains non-ASCII characters.
50860b4ad09SPeter Avalos.Pp
50960b4ad09SPeter AvalosIn addition to the
51060b4ad09SPeter Avalos.Cm x
51160b4ad09SPeter Avalosentry described above, the pax interchange format
51260b4ad09SPeter Avalosalso supports a
51360b4ad09SPeter Avalos.Cm g
51460b4ad09SPeter Avalosentry.
51560b4ad09SPeter AvalosThe
51660b4ad09SPeter Avalos.Cm g
51760b4ad09SPeter Avalosentry is identical in format, but specifies attributes that serve as
51860b4ad09SPeter Avalosdefaults for all subsequent archive entries.
51960b4ad09SPeter AvalosThe
52060b4ad09SPeter Avalos.Cm g
52160b4ad09SPeter Avalosentry is not widely used.
52260b4ad09SPeter Avalos.Pp
52360b4ad09SPeter AvalosBesides the new
52460b4ad09SPeter Avalos.Cm x
52560b4ad09SPeter Avalosand
52660b4ad09SPeter Avalos.Cm g
52760b4ad09SPeter Avalosentries, the pax interchange format has a few other minor variations
52860b4ad09SPeter Avalosfrom the earlier ustar format.
52960b4ad09SPeter AvalosThe most troubling one is that hardlinks are permitted to have
53060b4ad09SPeter Avalosdata following them.
53160b4ad09SPeter AvalosThis allows readers to restore any hardlink to a file without
53260b4ad09SPeter Avaloshaving to rewind the archive to find an earlier entry.
53360b4ad09SPeter AvalosHowever, it creates complications for robust readers, as it is no longer
53460b4ad09SPeter Avalosclear whether or not they should ignore the size field for hardlink entries.
53560b4ad09SPeter Avalos.Ss GNU Tar Archives
53660b4ad09SPeter AvalosThe GNU tar program started with a pre-POSIX format similar to that
53760b4ad09SPeter Avalosdescribed earlier and has extended it using several different mechanisms:
53860b4ad09SPeter AvalosIt added new fields to the empty space in the header (some of which was later
53960b4ad09SPeter Avalosused by POSIX for conflicting purposes);
54060b4ad09SPeter Avalosit allowed the header to be continued over multiple records;
54160b4ad09SPeter Avalosand it defined new entries that modify following entries
54260b4ad09SPeter Avalos(similar in principle to the
54360b4ad09SPeter Avalos.Cm x
54460b4ad09SPeter Avalosentry described above, but each GNU special entry is single-purpose,
54560b4ad09SPeter Avalosunlike the general-purpose
54660b4ad09SPeter Avalos.Cm x
54760b4ad09SPeter Avalosentry).
54860b4ad09SPeter AvalosAs a result, GNU tar archives are not POSIX compatible, although
54960b4ad09SPeter Avalosmore lenient POSIX-compliant readers can successfully extract most
55060b4ad09SPeter AvalosGNU tar archives.
55160b4ad09SPeter Avalos.Bd -literal -offset indent
55260b4ad09SPeter Avalosstruct header_gnu_tar {
55360b4ad09SPeter Avalos	char name[100];
55460b4ad09SPeter Avalos	char mode[8];
55560b4ad09SPeter Avalos	char uid[8];
55660b4ad09SPeter Avalos	char gid[8];
55760b4ad09SPeter Avalos	char size[12];
55860b4ad09SPeter Avalos	char mtime[12];
55960b4ad09SPeter Avalos	char checksum[8];
56060b4ad09SPeter Avalos	char typeflag[1];
56160b4ad09SPeter Avalos	char linkname[100];
56260b4ad09SPeter Avalos	char magic[6];
56360b4ad09SPeter Avalos	char version[2];
56460b4ad09SPeter Avalos	char uname[32];
56560b4ad09SPeter Avalos	char gname[32];
56660b4ad09SPeter Avalos	char devmajor[8];
56760b4ad09SPeter Avalos	char devminor[8];
56860b4ad09SPeter Avalos	char atime[12];
56960b4ad09SPeter Avalos	char ctime[12];
57060b4ad09SPeter Avalos	char offset[12];
57160b4ad09SPeter Avalos	char longnames[4];
57260b4ad09SPeter Avalos	char unused[1];
57360b4ad09SPeter Avalos	struct {
57460b4ad09SPeter Avalos		char offset[12];
57560b4ad09SPeter Avalos		char numbytes[12];
57660b4ad09SPeter Avalos	} sparse[4];
57760b4ad09SPeter Avalos	char isextended[1];
57860b4ad09SPeter Avalos	char realsize[12];
57960b4ad09SPeter Avalos	char pad[17];
58060b4ad09SPeter Avalos};
58160b4ad09SPeter Avalos.Ed
58260b4ad09SPeter Avalos.Bl -tag -width indent
58360b4ad09SPeter Avalos.It Va typeflag
58460b4ad09SPeter AvalosGNU tar uses the following special entry types, in addition to
58560b4ad09SPeter Avalosthose defined by POSIX:
58660b4ad09SPeter Avalos.Bl -tag -width indent
58760b4ad09SPeter Avalos.It "7"
58860b4ad09SPeter AvalosGNU tar treats type "7" records identically to type "0" records,
58960b4ad09SPeter Avalosexcept on one obscure RTOS where they are used to indicate the
59060b4ad09SPeter Avalospre-allocation of a contiguous file on disk.
59160b4ad09SPeter Avalos.It "D"
59260b4ad09SPeter AvalosThis indicates a directory entry.
59360b4ad09SPeter AvalosUnlike the POSIX-standard "5"
59460b4ad09SPeter Avalostypeflag, the header is followed by data records listing the names
59560b4ad09SPeter Avalosof files in this directory.
59660b4ad09SPeter AvalosEach name is preceded by an ASCII "Y"
59760b4ad09SPeter Avalosif the file is stored in this archive or "N" if the file is not
59860b4ad09SPeter Avalosstored in this archive.
59960b4ad09SPeter AvalosEach name is terminated with a null, and
60060b4ad09SPeter Avalosan extra null marks the end of the name list.
60160b4ad09SPeter AvalosThe purpose of this
60260b4ad09SPeter Avalosentry is to support incremental backups; a program restoring from
60360b4ad09SPeter Avalossuch an archive may wish to delete files on disk that did not exist
60460b4ad09SPeter Avalosin the directory when the archive was made.
60560b4ad09SPeter Avalos.Pp
60660b4ad09SPeter AvalosNote that the "D" typeflag specifically violates POSIX, which requires
60760b4ad09SPeter Avalosthat unrecognized typeflags be restored as normal files.
60860b4ad09SPeter AvalosIn this case, restoring the "D" entry as a file could interfere
60960b4ad09SPeter Avaloswith subsequent creation of the like-named directory.
61060b4ad09SPeter Avalos.It "K"
61160b4ad09SPeter AvalosThe data for this entry is a long linkname for the following regular entry.
61260b4ad09SPeter Avalos.It "L"
61360b4ad09SPeter AvalosThe data for this entry is a long pathname for the following regular entry.
61460b4ad09SPeter Avalos.It "M"
61560b4ad09SPeter AvalosThis is a continuation of the last file on the previous volume.
61660b4ad09SPeter AvalosGNU multi-volume archives guarantee that each volume begins with a valid
61760b4ad09SPeter Avalosentry header.
61860b4ad09SPeter AvalosTo ensure this, a file may be split, with part stored at the end of one volume,
61960b4ad09SPeter Avalosand part stored at the beginning of the next volume.
62060b4ad09SPeter AvalosThe "M" typeflag indicates that this entry continues an existing file.
62160b4ad09SPeter AvalosSuch entries can only occur as the first or second entry
62260b4ad09SPeter Avalosin an archive (the latter only if the first entry is a volume label).
62360b4ad09SPeter AvalosThe
62460b4ad09SPeter Avalos.Va size
62560b4ad09SPeter Avalosfield specifies the size of this entry.
62660b4ad09SPeter AvalosThe
62760b4ad09SPeter Avalos.Va offset
62860b4ad09SPeter Avalosfield at bytes 369-380 specifies the offset where this file fragment
62960b4ad09SPeter Avalosbegins.
63060b4ad09SPeter AvalosThe
63160b4ad09SPeter Avalos.Va realsize
63260b4ad09SPeter Avalosfield specifies the total size of the file (which must equal
63360b4ad09SPeter Avalos.Va size
63460b4ad09SPeter Avalosplus
63560b4ad09SPeter Avalos.Va offset ) .
63660b4ad09SPeter AvalosWhen extracting, GNU tar checks that the header file name is the one it is
63760b4ad09SPeter Avalosexpecting, that the header offset is in the correct sequence, and that
63860b4ad09SPeter Avalosthe sum of offset and size is equal to realsize.
63960b4ad09SPeter Avalos.It "N"
64060b4ad09SPeter AvalosType "N" records are no longer generated by GNU tar.
64160b4ad09SPeter AvalosThey contained a
64260b4ad09SPeter Avaloslist of files to be renamed or symlinked after extraction; this was
64360b4ad09SPeter Avalosoriginally used to support long names.
64460b4ad09SPeter AvalosThe contents of this record
64560b4ad09SPeter Avalosare a text description of the operations to be done, in the form
64660b4ad09SPeter Avalos.Dq Rename %s to %s\en
64760b4ad09SPeter Avalosor
64860b4ad09SPeter Avalos.Dq Symlink %s to %s\en ;
64960b4ad09SPeter Avalosin either case, both
65060b4ad09SPeter Avalosfilenames are escaped using K&R C syntax.
6519c82a63eSPeter AvalosDue to security concerns, "N" records are now generally ignored
6529c82a63eSPeter Avaloswhen reading archives.
65360b4ad09SPeter Avalos.It "S"
65460b4ad09SPeter AvalosThis is a
65560b4ad09SPeter Avalos.Dq sparse
65660b4ad09SPeter Avalosregular file.
65760b4ad09SPeter AvalosSparse files are stored as a series of fragments.
65860b4ad09SPeter AvalosThe header contains a list of fragment offset/length pairs.
65960b4ad09SPeter AvalosIf more than four such entries are required, the header is
66060b4ad09SPeter Avalosextended as necessary with
66160b4ad09SPeter Avalos.Dq extra
66260b4ad09SPeter Avalosheader extensions (an older format that is no longer used), or
66360b4ad09SPeter Avalos.Dq sparse
66460b4ad09SPeter Avalosextensions.
66560b4ad09SPeter Avalos.It "V"
66660b4ad09SPeter AvalosThe
66760b4ad09SPeter Avalos.Va name
66860b4ad09SPeter Avalosfield should be interpreted as a tape/volume header name.
66960b4ad09SPeter AvalosThis entry should generally be ignored on extraction.
67060b4ad09SPeter Avalos.El
67160b4ad09SPeter Avalos.It Va magic
67260b4ad09SPeter AvalosThe magic field holds the five characters
67360b4ad09SPeter Avalos.Dq ustar
67460b4ad09SPeter Avalosfollowed by a space.
67560b4ad09SPeter AvalosNote that POSIX ustar archives have a trailing null.
67660b4ad09SPeter Avalos.It Va version
67760b4ad09SPeter AvalosThe version field holds a space character followed by a null.
67860b4ad09SPeter AvalosNote that POSIX ustar archives use two copies of the ASCII digit
67960b4ad09SPeter Avalos.Dq 0 .
68060b4ad09SPeter Avalos.It Va atime , Va ctime
68160b4ad09SPeter AvalosThe time the file was last accessed and the time of
68260b4ad09SPeter Avaloslast change of file information, stored in octal as with
68360b4ad09SPeter Avalos.Va mtime .
68460b4ad09SPeter Avalos.It Va longnames
68560b4ad09SPeter AvalosThis field is apparently no longer used.
68660b4ad09SPeter Avalos.It Sparse Va offset / Va numbytes
68760b4ad09SPeter AvalosEach such structure specifies a single fragment of a sparse
68860b4ad09SPeter Avalosfile.
68960b4ad09SPeter AvalosThe two fields store values as octal numbers.
69060b4ad09SPeter AvalosThe fragments are each padded to a multiple of 512 bytes
69160b4ad09SPeter Avalosin the archive.
69260b4ad09SPeter AvalosOn extraction, the list of fragments is collected from the
69360b4ad09SPeter Avalosheader (including any extension headers), and the data
69460b4ad09SPeter Avalosis then read and written to the file at appropriate offsets.
69560b4ad09SPeter Avalos.It Va isextended
69660b4ad09SPeter AvalosIf this is set to non-zero, the header will be followed by additional
69760b4ad09SPeter Avalos.Dq sparse header
69860b4ad09SPeter Avalosrecords.
69960b4ad09SPeter AvalosEach such record contains information about as many as 21 additional
70060b4ad09SPeter Avalossparse blocks as shown here:
70160b4ad09SPeter Avalos.Bd -literal -offset indent
70260b4ad09SPeter Avalosstruct gnu_sparse_header {
70360b4ad09SPeter Avalos	struct {
70460b4ad09SPeter Avalos		char offset[12];
70560b4ad09SPeter Avalos		char numbytes[12];
70660b4ad09SPeter Avalos	} sparse[21];
70760b4ad09SPeter Avalos	char    isextended[1];
70860b4ad09SPeter Avalos	char    padding[7];
70960b4ad09SPeter Avalos};
71060b4ad09SPeter Avalos.Ed
71160b4ad09SPeter Avalos.It Va realsize
71260b4ad09SPeter AvalosA binary representation of the file's complete size, with a much larger range
71360b4ad09SPeter Avalosthan the POSIX file size.
71460b4ad09SPeter AvalosIn particular, with
71560b4ad09SPeter Avalos.Cm M
71660b4ad09SPeter Avalostype files, the current entry is only a portion of the file.
71760b4ad09SPeter AvalosIn that case, the POSIX size field will indicate the size of this
71860b4ad09SPeter Avalosentry; the
71960b4ad09SPeter Avalos.Va realsize
72060b4ad09SPeter Avalosfield will indicate the total size of the file.
72160b4ad09SPeter Avalos.El
7229c82a63eSPeter Avalos.Ss GNU tar pax archives
7239c82a63eSPeter AvalosGNU tar 1.14 (XXX check this XXX) and later will write
7249c82a63eSPeter Avalospax interchange format archives when you specify the
7259c82a63eSPeter Avalos.Fl -posix
7269c82a63eSPeter Avalosflag.
727c09f92d2SPeter AvalosThis format follows the pax interchange format closely,
728c09f92d2SPeter Avalosusing some
729c09f92d2SPeter Avalos.Cm SCHILY
730c09f92d2SPeter Avalostags and introducing new keywords to store sparse file information.
731c09f92d2SPeter AvalosThere have been three iterations of the sparse file support, referred to
7329c82a63eSPeter Avalosas
7339c82a63eSPeter Avalos.Dq 0.0 ,
7349c82a63eSPeter Avalos.Dq 0.1 ,
7359c82a63eSPeter Avalosand
7369c82a63eSPeter Avalos.Dq 1.0 .
7379c82a63eSPeter Avalos.Bl -tag -width indent
7389c82a63eSPeter Avalos.It Cm GNU.sparse.numblocks , Cm GNU.sparse.offset , Cm GNU.sparse.numbytes , Cm  GNU.sparse.size
7399c82a63eSPeter AvalosThe
7409c82a63eSPeter Avalos.Dq 0.0
7419c82a63eSPeter Avalosformat used an initial
7429c82a63eSPeter Avalos.Cm GNU.sparse.numblocks
7439c82a63eSPeter Avalosattribute to indicate the number of blocks in the file, a pair of
7449c82a63eSPeter Avalos.Cm GNU.sparse.offset
7459c82a63eSPeter Avalosand
7469c82a63eSPeter Avalos.Cm GNU.sparse.numbytes
7479c82a63eSPeter Avalosto indicate the offset and size of each block,
7489c82a63eSPeter Avalosand a single
7499c82a63eSPeter Avalos.Cm GNU.sparse.size
7509c82a63eSPeter Avalosto indicate the full size of the file.
7519c82a63eSPeter AvalosThis is not the same as the size in the tar header because the
7529c82a63eSPeter Avaloslatter value does not include the size of any holes.
7539c82a63eSPeter AvalosThis format required that the order of attributes be preserved and
7549c82a63eSPeter Avalosrelied on readers accepting multiple appearances of the same attribute
7559c82a63eSPeter Avalosnames, which is not officially permitted by the standards.
7569c82a63eSPeter Avalos.It Cm GNU.sparse.map
7579c82a63eSPeter AvalosThe
7589c82a63eSPeter Avalos.Dq 0.1
7599c82a63eSPeter Avalosformat used a single attribute that stored a comma-separated
7609c82a63eSPeter Avaloslist of decimal numbers.
7619c82a63eSPeter AvalosEach pair of numbers indicated the offset and size, respectively,
7629c82a63eSPeter Avalosof a block of data.
7639c82a63eSPeter AvalosThis does not work well if the archive is extracted by an archiver
7649c82a63eSPeter Avalosthat does not recognize this extension, since many pax implementations
7659c82a63eSPeter Avalossimply discard unrecognized attributes.
7669c82a63eSPeter Avalos.It Cm GNU.sparse.major , Cm GNU.sparse.minor , Cm GNU.sparse.name , Cm GNU.sparse.realsize
7679c82a63eSPeter AvalosThe
7689c82a63eSPeter Avalos.Dq 1.0
7699c82a63eSPeter Avalosformat stores the sparse block map in one or more 512-byte blocks
7709c82a63eSPeter Avalosprepended to the file data in the entry body.
7719c82a63eSPeter AvalosThe pax attributes indicate the existence of this map
7729c82a63eSPeter Avalos(via the
7739c82a63eSPeter Avalos.Cm GNU.sparse.major
7749c82a63eSPeter Avalosand
7759c82a63eSPeter Avalos.Cm GNU.sparse.minor
7769c82a63eSPeter Avalosfields)
7779c82a63eSPeter Avalosand the full size of the file.
7789c82a63eSPeter AvalosThe
7799c82a63eSPeter Avalos.Cm GNU.sparse.name
7809c82a63eSPeter Avalosholds the true name of the file.
7819c82a63eSPeter AvalosTo avoid confusion, the name stored in the regular tar header
7829c82a63eSPeter Avalosis a modified name so that extraction errors will be apparent
7839c82a63eSPeter Avalosto users.
7849c82a63eSPeter Avalos.El
78560b4ad09SPeter Avalos.Ss Solaris Tar
78660b4ad09SPeter AvalosXXX More Details Needed XXX
78760b4ad09SPeter Avalos.Pp
78860b4ad09SPeter AvalosSolaris tar (beginning with SunOS XXX 5.7 ?? XXX) supports an
78960b4ad09SPeter Avalos.Dq extended
79060b4ad09SPeter Avalosformat that is fundamentally similar to pax interchange format,
79160b4ad09SPeter Avaloswith the following differences:
79260b4ad09SPeter Avalos.Bl -bullet -compact -width indent
79360b4ad09SPeter Avalos.It
79460b4ad09SPeter AvalosExtended attributes are stored in an entry whose type is
79560b4ad09SPeter Avalos.Cm X ,
79660b4ad09SPeter Avalosnot
79760b4ad09SPeter Avalos.Cm x ,
79860b4ad09SPeter Avalosas used by pax interchange format.
79960b4ad09SPeter AvalosThe detailed format of this entry appears to be the same
80060b4ad09SPeter Avalosas detailed above for the
80160b4ad09SPeter Avalos.Cm x
80260b4ad09SPeter Avalosentry.
80360b4ad09SPeter Avalos.It
80460b4ad09SPeter AvalosAn additional
80560b4ad09SPeter Avalos.Cm A
806c09f92d2SPeter Avalosheader is used to store an ACL for the following regular entry.
80760b4ad09SPeter AvalosThe body of this entry contains a seven-digit octal number
80860b4ad09SPeter Avalosfollowed by a zero byte, followed by the
80960b4ad09SPeter Avalostextual ACL description.
8109c82a63eSPeter AvalosThe octal value is the number of ACL entries
8119c82a63eSPeter Avalosplus a constant that indicates the ACL type: 01000000
8129c82a63eSPeter Avalosfor POSIX.1e ACLs and 03000000 for NFSv4 ACLs.
81360b4ad09SPeter Avalos.El
8149c82a63eSPeter Avalos.Ss AIX Tar
8159c82a63eSPeter AvalosXXX More details needed XXX
816c09f92d2SPeter Avalos.Pp
817c09f92d2SPeter AvalosAIX Tar uses a ustar-formatted header with the type
818c09f92d2SPeter Avalos.Cm A
819c09f92d2SPeter Avalosfor storing coded ACL information.
820c09f92d2SPeter AvalosUnlike the Solaris format, AIX tar writes this header after the
821c09f92d2SPeter Avalosregular file body to which it applies.
822c09f92d2SPeter AvalosThe pathname in this header is either
823c09f92d2SPeter Avalos.Cm NFS4
824c09f92d2SPeter Avalosor
825c09f92d2SPeter Avalos.Cm AIXC
826c09f92d2SPeter Avalosto indicate the type of ACL stored.
827c09f92d2SPeter AvalosThe actual ACL is stored in platform-specific binary format.
8289c82a63eSPeter Avalos.Ss Mac OS X Tar
8299c82a63eSPeter AvalosThe tar distributed with Apple's Mac OS X stores most regular files
830c09f92d2SPeter Avalosas two separate files in the tar archive.
831c09f92d2SPeter AvalosThe two files have the same name except that the first
8329c82a63eSPeter Avalosone has
8339c82a63eSPeter Avalos.Dq ._
834c09f92d2SPeter Avalosprepended to the last path element.
835c09f92d2SPeter AvalosThis special file stores an AppleDouble-encoded
836c09f92d2SPeter Avalosbinary blob with additional metadata about the second file,
837c09f92d2SPeter Avalosincluding ACL, extended attributes, and resources.
838c09f92d2SPeter AvalosTo recreate the original file on disk, each
839c09f92d2SPeter Avalosseparate file can be extracted and the Mac OS X
840c09f92d2SPeter Avalos.Fn copyfile
841c09f92d2SPeter Avalosfunction can be used to unpack the separate
842c09f92d2SPeter Avalosmetadata file and apply it to th regular file.
843c09f92d2SPeter AvalosConversely, the same function provides a
844c09f92d2SPeter Avalos.Dq pack
845c09f92d2SPeter Avalosoption to encode the extended metadata from
846c09f92d2SPeter Avalosa file into a separate file whose contents
847c09f92d2SPeter Avaloscan then be put into a tar archive.
8489c82a63eSPeter Avalos.Pp
849c09f92d2SPeter AvalosNote that the Apple extended attributes interact
850c09f92d2SPeter Avalosbadly with long filenames.
851c09f92d2SPeter AvalosSince each file is stored with the full name,
852c09f92d2SPeter Avalosa separate set of extensions needs to be included
853c09f92d2SPeter Avalosin the archive for each one, doubling the overhead
854c09f92d2SPeter Avalosrequired for files with long names.
855c09f92d2SPeter Avalos.Ss Summary of tar type codes
856c09f92d2SPeter AvalosThe following list is a condensed summary of the type codes
857c09f92d2SPeter Avalosused in tar header records generated by different tar implementations.
858c09f92d2SPeter AvalosMore details about specific implementations can be found above:
859c09f92d2SPeter Avalos.Bl -tag -compact -width XXX
860c09f92d2SPeter Avalos.It NUL
861c09f92d2SPeter AvalosEarly tar programs stored a zero byte for regular files.
862c09f92d2SPeter Avalos.It Cm 0
863c09f92d2SPeter AvalosPOSIX standard type code for a regular file.
864c09f92d2SPeter Avalos.It Cm 1
865c09f92d2SPeter AvalosPOSIX standard type code for a hard link description.
866c09f92d2SPeter Avalos.It Cm 2
867c09f92d2SPeter AvalosPOSIX standard type code for a symbolic link description.
868c09f92d2SPeter Avalos.It Cm 3
869c09f92d2SPeter AvalosPOSIX standard type code for a character device node.
870c09f92d2SPeter Avalos.It Cm 4
871c09f92d2SPeter AvalosPOSIX standard type code for a block device node.
872c09f92d2SPeter Avalos.It Cm 5
873c09f92d2SPeter AvalosPOSIX standard type code for a directory.
874c09f92d2SPeter Avalos.It Cm 6
875c09f92d2SPeter AvalosPOSIX standard type code for a FIFO.
876c09f92d2SPeter Avalos.It Cm 7
877c09f92d2SPeter AvalosPOSIX reserved.
878c09f92d2SPeter Avalos.It Cm 7
879c09f92d2SPeter AvalosGNU tar used for pre-allocated files on some systems.
880c09f92d2SPeter Avalos.It Cm A
881c09f92d2SPeter AvalosSolaris tar ACL description stored prior to a regular file header.
882c09f92d2SPeter Avalos.It Cm A
883c09f92d2SPeter AvalosAIX tar ACL description stored after the file body.
884c09f92d2SPeter Avalos.It Cm D
885c09f92d2SPeter AvalosGNU tar directory dump.
886c09f92d2SPeter Avalos.It Cm K
887c09f92d2SPeter AvalosGNU tar long linkname for the following header.
888c09f92d2SPeter Avalos.It Cm L
889c09f92d2SPeter AvalosGNU tar long pathname for the following header.
890c09f92d2SPeter Avalos.It Cm M
891c09f92d2SPeter AvalosGNU tar multivolume marker, indicating the file is a continuation of a file from the previous volume.
892c09f92d2SPeter Avalos.It Cm N
893*085658deSDaniel FojtGNU tar long filename support.
894*085658deSDaniel FojtDeprecated.
895c09f92d2SPeter Avalos.It Cm S
896c09f92d2SPeter AvalosGNU tar sparse regular file.
897c09f92d2SPeter Avalos.It Cm V
898c09f92d2SPeter AvalosGNU tar tape/volume header name.
899c09f92d2SPeter Avalos.It Cm X
900c09f92d2SPeter AvalosSolaris tar general-purpose extension header.
901c09f92d2SPeter Avalos.It Cm g
902c09f92d2SPeter AvalosPOSIX pax interchange format global extensions.
903c09f92d2SPeter Avalos.It Cm x
904c09f92d2SPeter AvalosPOSIX pax interchange format per-file extensions.
905c09f92d2SPeter Avalos.El
90660b4ad09SPeter Avalos.Sh SEE ALSO
90760b4ad09SPeter Avalos.Xr ar 1 ,
90860b4ad09SPeter Avalos.Xr pax 1 ,
90960b4ad09SPeter Avalos.Xr tar 1
91060b4ad09SPeter Avalos.Sh STANDARDS
91160b4ad09SPeter AvalosThe
91260b4ad09SPeter Avalos.Nm tar
91360b4ad09SPeter Avalosutility is no longer a part of POSIX or the Single Unix Standard.
91460b4ad09SPeter AvalosIt last appeared in
91560b4ad09SPeter Avalos.St -susv2 .
91660b4ad09SPeter AvalosIt has been supplanted in subsequent standards by
91760b4ad09SPeter Avalos.Xr pax 1 .
91860b4ad09SPeter AvalosThe ustar format is currently part of the specification for the
91960b4ad09SPeter Avalos.Xr pax 1
92060b4ad09SPeter Avalosutility.
92160b4ad09SPeter AvalosThe pax interchange file format is new with
92260b4ad09SPeter Avalos.St -p1003.1-2001 .
92360b4ad09SPeter Avalos.Sh HISTORY
92460b4ad09SPeter AvalosA
92560b4ad09SPeter Avalos.Nm tar
92660b4ad09SPeter Avaloscommand appeared in Seventh Edition Unix, which was released in January, 1979.
92760b4ad09SPeter AvalosIt replaced the
92860b4ad09SPeter Avalos.Nm tp
92960b4ad09SPeter Avalosprogram from Fourth Edition Unix which in turn replaced the
93060b4ad09SPeter Avalos.Nm tap
93160b4ad09SPeter Avalosprogram from First Edition Unix.
93260b4ad09SPeter AvalosJohn Gilmore's
93360b4ad09SPeter Avalos.Nm pdtar
93460b4ad09SPeter Avalospublic-domain implementation (circa 1987) was highly influential
93560b4ad09SPeter Avalosand formed the basis of
9369c82a63eSPeter Avalos.Nm GNU tar
9379c82a63eSPeter Avalos(circa 1988).
93860b4ad09SPeter AvalosJoerg Shilling's
93960b4ad09SPeter Avalos.Nm star
9406b384f39SPeter Avalosarchiver is another open-source (CDDL) archiver (originally developed
94160b4ad09SPeter Avaloscirca 1985) which features complete support for pax interchange
94260b4ad09SPeter Avalosformat.
9439c82a63eSPeter Avalos.Pp
9449c82a63eSPeter AvalosThis documentation was written as part of the
9459c82a63eSPeter Avalos.Nm libarchive
9469c82a63eSPeter Avalosand
9479c82a63eSPeter Avalos.Nm bsdtar
9489c82a63eSPeter Avalosproject by
9499c82a63eSPeter Avalos.An Tim Kientzle Aq kientzle@FreeBSD.org .
950