Before pax existed, GNU tar solved the same problems in its own way: long names,
files with holes, incremental backups and archives spread over several tapes. Its
headers carry the magic ustar followed by two spaces and a NUL, and use the
type flags L, K, S, D,
M and V. GNU tar still reads all of these and writes them in
its default format.
Long names
A name or link target too long for the header is written in an extra entry just
before the real one. Its header has the name ././@LongLink, type flag
L for a long name or K for a long link target, and a
size equal to the length of the text plus one for a final NUL. Its data
blocks hold the full text. The real header follows with a shortened name, which
readers replace with the long one.
0Header name././@LongLink, type flagL512 bytes512Long name the full path and a NUL, padded to 512size rounded up…Entry header with the name cut short512 bytes…Entry datasize rounded up
The GNU header
The GNU header matches ustar up to byte 344. From byte 345, where ustar has
prefix, it holds these fields instead:
| Offset | Size | Type | Name | Description |
|---|---|---|---|---|
345 | 12 | octal | atime | Last access time |
357 | 12 | octal | ctime | Last status change time |
369 | 12 | octal | offset | For a M entry, where this part starts within the whole file |
381 | 4 | unused | longnames | Never used |
385 | 1 | unused | unused | Padding |
386 | 96 | 4 entries | sparse | Up to four sparse map entries, each a 12-byte offset and a 12-byte length |
482 | 1 | flag | isextended | Non-zero when more sparse map blocks follow the header |
483 | 12 | octal | realsize | The full size of a sparse file |
495 | 17 | padding | pad | Zeros |
The base-256 numbers that let a header hold large sizes and IDs also began in GNU tar.
Sparse files
A sparse file has holes: long runs of zeros that the file system does not store. An
S entry stores only the parts that hold data. Its sparse map lists each
part as an offset in the original file and a length, and the stored data is those parts
one after another. realsize gives the size of the file once the holes are
put back.
When four map entries are not enough, isextended is set and extension
blocks follow the header. Each block holds 21 more entries (504 bytes), its own
isextended byte at offset 504, and padding. Newer versions of GNU tar
write sparse files in pax archives instead, using GNU.sparse. records in a
pax header.
Other GNU entries
Ddump directory- Written by incremental backups. Its data lists the names the folder held when the backup was made, each with a letter saying whether that file is in this backup, so that restoring can remove files deleted since an earlier backup.
Vvolume label- The first header of a labelled archive. The label is in
name, and there is no data. Mcontinuation- The first header on a new volume of a multi-volume archive, holding the rest of a
file that did not fit on the previous volume.
offsetsays where in the file this part begins.