A tar file is a sequence of 512-byte header blocks (name, mode, uid, gid, size, mtime, checksum, type flag, link name, and for ustar a magic ustar plus prefix) each followed by data padded to 512 bytes. The archive ends with two zero blocks. GNU and pax extensions carry long names, large sizes and extended attributes. Tar itself does no compression, so it is usually wrapped in gzip, bzip2, xz or zstd.
Where it is used
Software source distribution and Unix backups.
Container image layers.
History
Introduced in Version 7 Unix (1979); standardized in POSIX.1-1988 (ustar) and POSIX.1-2001 (pax).
Status today
Universal on Unix-like systems.
Structures read by the implementation
Offsets are in bytes from the start of the buffer named in each heading. Field names are taken from the implementation and are not an official specification. Fixed-width integers are shown as u/i (unsigned/signed) followed by bit width and byte order.
Header.Parse buffer block · TarFormat.cs
Offset
Size
Type
Field
Notes
0x7C
12
bytes
–
0x88
12
bytes
Odified
0x94
8
bytes
–
0x9C
1
u8
Type
0x9D
100
bytes
–
0x101
8
bytes
Agic
0x159
155
bytes
Name
0x159
1
u8
–
Other fields read
Read in
Offset
Size
Type
Field
Notes
TarStreamScanner.OnHeader
0x1E3
12
bytes
–
Constants
General TarCarver
Name
Value
Type
Notes
MetaChunk
65536
int
General TarFormat
Name
Value
Type
Notes
BlockSize
512
int
RecordSize
10240
int
GNU tar / bsdtar / Python default blocking factor 20
General TarArchiveModule
Name
Value
Type
Notes
Block
512
int
Implementation limits reader
Class
Name
Value
Notes
TarStreamScanner
MaxEntries
100_000
TarStreamScanner
MaxMetaData
1 << 20
TarSummary
MaxNamesInDetails
25
TarArchiveModule
MaxEntries
5_000_000
TarFlavor enum
Name
Value
Ustar
(next)
Pax
(next)
Signatures and magic strings referenced
Text
Where
Context
ustar \0
Header.Parse
if (magic.SequenceEqual(“ustar \0″u8))
ustar\0
Header.Parse
else if (magic[..6].SequenceEqual(“ustar\0″u8) || magic[..5].SequenceEqual(“ustar”u8))
ustar
Header.Parse
else if (magic[..6].SequenceEqual(“ustar\0″u8) || magic[..5].SequenceEqual(“ustar”u8))
Structures and constants were extracted from: Carving/Plugins/Tar/TarCarver.cs, Carving/Plugins/Tar/TarFormat.cs, Modules/FileSystems/TarArchiveModule.cs. Prose sections are a summary from public sources; verify details before relying on them.