Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Tar (computing)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Header=== The file header record contains [[metadata]] about a file. To ensure portability across different architectures with different [[Endianness|byte orderings]], the information in the header record is encoded in [[ASCII]]. Thus if all the files in an archive are ASCII text files, and have ASCII names, then the archive is essentially an ASCII text file (containing many [[Null character|NUL characters]]). The fields defined by the original Unix tar format are listed in the table below. The link indicator/file type table includes some modern extensions. When a field is unused it is filled with NUL bytes. The header uses 257 bytes, then is padded with NUL bytes to make it fill a 512 byte record. There is no "magic number" in the header, for file identification. Pre-POSIX.1-1988 (i.e. v7) tar header: {| class="wikitable" |- ! Field offset ! Field size ! Field |- | 0 | 100 | File path and name |- | 100 | 8 | File mode (octal) |- | 108 | 8 | Owner's numeric user ID (octal) |- | 116 | 8 | Group's numeric user ID (octal) |- | 124 | 12 | File size in bytes (octal) |- | 136 | 12 | Last modification time in numeric Unix time format (octal) |- | 148 | 8 | Checksum for header record |- | 156 | 1 | Link indicator (file type) |- | 157 | 100 | Name of linked file |} The pre-POSIX.1-1988 '''Link indicator''' field can have the following values: {| class="wikitable" |+ Link indicator field |- ! Value ! Meaning |- | '0' or ([[ASCII]] [[Null character|NUL]]) | Normal file |- | '1' | [[Hard link]] |- | '2' | [[Symbolic link]] |} Some pre-POSIX.1-1988 tar implementations indicated a directory by having a trailing [[Slash (punctuation)|slash]] (/) in the name. Numeric values are encoded in [[octal]] numbers using ASCII digits, with leading zeroes. For historical reasons, a final NUL or [[Space (punctuation)|space]] character should also be used. Thus although there are 12 bytes reserved for storing the file size, only 11 octal digits can be stored. This gives a maximum file size of 8 [[gigabyte]]s on archived files. To overcome this limitation, in 2001 star introduced a base-256 coding that is indicated by setting the high-order bit of the leftmost byte of a numeric field.{{cn|date=October 2021}} GNU-tar and BSD-tar followed this idea. Additionally, versions of tar from before the first POSIX standard from 1988 pad the values with spaces instead of zeroes. The [[checksum]] is calculated by taking the sum of the unsigned byte values of the header record with the eight checksum bytes taken to be ASCII spaces (decimal value 32). It is stored as a six digit octal number with leading zeroes followed by a NUL and then a space. Various implementations do not adhere to this format. In addition, some historic tar implementations treated bytes as signed. Implementations typically calculate the checksum both ways, and treat it as good if either the signed or unsigned sum matches the included checksum. Unix filesystems support multiple links (names) for the same file. If several such files appear in a tar archive, only the first one is archived as a normal file; the rest are archived as hard links, with the "name of linked file" field set to the first one's name. On extraction, such hard links should be recreated in the file system.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)