A GNU header has 100 bytes for the name and 100 for the link target, and no prefix. A
longer name or target is written in an extra entry just before the member: a header
named ././@LongLink whose data is the full text. Readers apply it to the next
ordinary header and replace the shortened value there. The same entries are met in other
archives too, wherever GNU tar or a library copying it wrote them.
0Long-name header name././@LongLink, typeL512 bytes512Long name the full path and a NUL, padded with zeros to 512size rounded up…Long-link header optional: the same for the link target, typeK512 bytes and more…Member header with the name cut to 100 characters512 bytes…Member datasize rounded up
Long names (L)
The entry for a long name is a GNU header with these values:
| Field | Value |
|---|---|
name | ././@LongLink |
typeflag | L (4C), GNUTYPE_LONGNAME |
size | the length of the name plus one, for the NUL at its end |
mode, uid, gid, mtime | not used; zeros in the example |
uname, gname | not used; root in the example |
| magic and version | ustar, two spaces, NUL |
To read it:
- Read the
Lheader and its data,sizebytes rounded up to whole blocks. - Take the text up to the first NUL. This is the next member’s full name.
- Read the next header. If it is another
LorK, keep going. The first ordinary header takes the long name in place of its ownname.
The member’s own name field holds the first 100 characters of the name, so
a reader that does not know L extracts a small file named
././@LongLink and then the member under a shortened name.
Long link targets (K)
A link target longer than 100 characters is written the same way, with type
K (4B), GNUTYPE_LONGLINK. Its data replaces the
next member’s linkname. A hard or symbolic link with both a long name and
a long target has both a K entry and an L entry before it;
each applies to the next ordinary header.
Example
The test archive gnu-long-path.tar of the JavaScript library tar-stream
holds one file with a 106-character path. Its first header is the long name. Rows shown
as * are zeros; rows shown as … are left out.
00000000 2E 2F 2E 2F 40 4C 6F 6E 67 4C 69 6E 6B 00 00 00 ././@LongLink...
*
00000060 00 00 00 00 30 30 30 30 30 30 30 00 30 30 30 30 ....0000000.0000
…
00000080 30 30 30 30 31 35 33 00 30 30 30 30 30 30 30 30 0000153.00000000
00000090 30 30 30 00 30 31 31 35 36 34 00 20 4C 00 00 00 000.011564. L...
*
00000100 00 75 73 74 61 72 20 20 00 72 6F 6F 74 00 00 00 .ustar .root...
…
00000200 6E 6F 64 65 2D 76 30 2E 31 31 2E 31 34 2F 64 65 node-v0.11.14/de
…
L header, then the long name in the next block.The size is octal 153, 107 bytes: the 106-character path and a NUL. The
data starts at 0x200 with node-v0.11.14/de… and fills one
block. The member’s own header follows at 0x400, and its name field holds
the first 100 characters of the same path.