The typeflag byte at offset 156 of the
header says what kind of member it
describes. It is a single ASCII character. GNU tar uses the POSIX flags for files, links
and folders, and capital letters of its own for long names, sparse files, incremental
backups and multi-volume archives. The names in the tables are those of GNU tar’s
tar.h.
Files, links and folders
| Flag | Name | Member | Description | Data |
|---|---|---|---|---|
0 (30) | REGTYPE | Regular file | The data blocks after the header are the file’s contents. | size bytes |
NUL (00) | AREGTYPE | Regular file | The old form of 0, “kept for compatibility”. A name ending in / is a folder. | size bytes |
1 | LNKTYPE | Hard link | Another name for a file stored earlier in the archive; linkname names it. | none (see below) |
2 | SYMTYPE | Symbolic link | linkname holds the target. | none |
3 | CHRTYPE | Character device | devmajor and devminor give the device numbers. | none |
4 | BLKTYPE | Block device | As for a character device. | none |
5 | DIRTYPE | Directory | A folder. In an incremental archive, a folder is written as D instead. | none |
6 | FIFOTYPE | FIFO | A named pipe. | none |
7 | CONTTYPE | Contiguous file | Read as a regular file. | size bytes |
For types 2 to 6, readers such as Go and libarchive skip no
data whatever size says. The explorer does the same, and follows the size
only when the block after the header is not a header and the block after the data
would be, reporting it when it does. Type 1 follows the same rule in a GNU
archive. Only pax archives may give a hard link data (see
the ustar page); the explorer
obeys a hard link’s size after any x or g header in the
archive, as libarchive does.
Extended headers
A GNU-format archive should not contain pax headers: GNU tar writes them only in its
posix format, whose headers carry the POSIX magic. Readers still meet
them in mixed archives, and the explorer decodes an x, g or
Solaris X header in a GNU archive as POSIX describes it, linking to the
pax extensions of the ustar
format.
| Flag | Name | Header |
|---|---|---|
x | XHDTYPE | Extended header: records for the next member. |
g | XGLTYPE | Global extended header: records for every following member. |
X | SOLARIS_XHDTYPE | Solaris’s extended header, read like x. |
GNU tar’s flags
| Flag | Name | Member | Data |
|---|---|---|---|
D | GNUTYPE_DUMPDIR | A folder in an incremental backup, with the list of names it held: see dump directories. | the dumpdir |
K | GNUTYPE_LONGLINK | The next member’s link target: see long names. | the text and a NUL |
L | GNUTYPE_LONGNAME | The next member’s name: see long names. | the text and a NUL |
M | GNUTYPE_MULTIVOL | The rest of a file begun on the previous volume: see multi-volume. | size bytes |
N | GNUTYPE_NAMES | A script for old long names, no longer written: see old names. | the script |
S | GNUTYPE_SPARSE | A file with holes: see sparse files. | the stored parts |
V | GNUTYPE_VOLHDR | The archive’s volume label: see volume labels. | none in practice |
Dump directories (D)
GNU tar’s incremental backups (--listed-incremental) write each folder as
a D member. Its data, the dumpdir, lists the names the folder held when the
backup was made, so that restoring can delete files removed since an earlier backup,
and can carry out renames. The GNU manual:
- Each entry is a one-letter control code, a name and a NUL.
- “Each dumpdir ends with a single nul character”, so the list ends with an empty name.
| Code | Meaning | Name |
|---|---|---|
Y | The file is in this archive. | relative to the folder |
N | The file has not changed since the last backup and is not in this archive. | relative |
D | A folder. | relative |
R | Rename this file to the name in the next T entry. | absolute |
T | The new name for the R before it. | absolute |
X | A temporary folder used while renaming. | absolute |
An example from Go’s test archive gnu-incremental.tar, whose first member
is a D folder. Its data, at 0x200:
00000200 59 66 6F 6F 00 59 73 70 61 72 73 65 00 00 Yfoo.Ysparse..
Yfoo and Ysparse, then the empty name that ends the list.Members of such archives carry their access and change times in the
GNU fields, and in Go’s
test data their mode holds the whole file mode, such as 0100644. In pax
archives GNU tar puts the same list in a GNU.dumpdir record instead.
Multi-volume continuations (M)
A multi-volume archive (--multi-volume) is split across tapes or files.
When a file does not fit on one volume, the next volume starts with an
M header for it, holding the rest of the file. Its
offset field, at byte 369, says where in the whole file this part
begins, and its size is the length of this part. A reader that does not
know M extracts the part as a file of its own.
Volume labels (V)
An archive made with a label (--label) starts with a V
header whose name holds the label; tar(5) calls it “a tape/volume header
name”. It describes the archive, not a file, and has no data in practice.
Old long names (N)
Early versions of GNU tar stored long names in N members
(GNUTYPE_NAMES, “for storing filenames that do not fit into the main
header”). tar(5): they “contained a list of files to be renamed or symlinked after
extraction”. The data is text, one operation to a line, in the form
Rename %s to %s\n or Symlink %s to %s\n, the names
escaped in K&R C syntax (\n, \t, \\,
three-digit octal and so on). The two names are split at the first
to .
GNU tar’s reader, extract_mangle in its mangle.c, unescapes
both names of a Symlink line, but only the new name of a
Rename line: the old name, the short one the file was extracted under,
is taken as it stands, less a final slash. Any other line is an error (“Unknown
demangling command”).
tar(5): they are “no longer generated”, and “due to security concerns” are “now generally ignored when reading archives”, since an archive could rename anything; GNU tar dropped its reader in 2006. The explorer reads each line as GNU tar did, but performs nothing.
Other flags
POSIX reserves A to Z for vendors. Besides GNU tar’s own,
readers meet these:
| Flag | From | Meaning |
|---|---|---|
A | Solaris and AIX | Security attributes: on Solaris a run of records, each a type, a count or length and text (ACLs and Trusted Extensions labels), before the file; on AIX a binary ACL after the file, named NFS4 or AIXC, for which no published layout was found. See ACL members. |
E | Solaris | An extended attribute: a header member, then a member holding the attribute. |
I | star | Inode metadata only: star(5) says the size holds the file’s length and no data follows the header. |
A reader that meets a flag it does not know treats the member as a regular file. The explorer does the same, and shows the flag as an unknown type.