Contains definitions for flags used in the tar archive header.
The /usr/include/tar.h file contains extended definitions used in the typeflag and mode fields of the tar archive header block. The file also provides values for the required POSIX entries.
Every file archived using the tar command is represented by a header block describing the file, followed by zero or more blocks that give the contents of the file. The end-of-archive indicator consists of two blocks filled with binary zeros. Each block is a fixed size of 512 bytes.
Blocks are grouped for physical I/O operations and groups can be written using a single write subroutine operation. On magnetic tape, the result of this write operation is a single tape record. The last record is always a full 512 bytes. Blocks after the end-of-archive zeros contain undefined data.
The header block structure is shown in the following table. All lengths and offsets are in decimal.
Field Name | Offset | Length in Bytes | Contents |
---|---|---|---|
name | 0 | 100 | File name without a / (slash) |
mode | 100 | 8 | File mode |
uid | 108 | 8 | User ID |
gid | 116 | 8 | Group ID |
size | 124 | 12 | Size in bytes |
mtime | 136 | 12 | Latest modification time |
cksum | 148 | 8 | File and header checksum |
typeflag | 156 | 1 | File type |
linkname | 157 | 100 | Linked path name or file name |
magic | 257 | 6 | Format representation for tar |
version | 263 | 2 | Version representation for tar |
uname | 265 | 32 | User name |
gname | 297 | 32 | Group name |
devmajor | 329 | 8 | Major device representation |
devminor | 337 | 8 | Minor device representation |
prefix | 345 | 155 | Path name without trailing slashes |
Names are preserved only if the characters are chosen from the POSIX portable file-name character set or if the same extended character set is used between systems. During a read operation, a file can be created only if the original file can be accessed using the open, stat, chdir, fcntl, or opendir subroutine.
Each field within the header block and each character on the archive medium are contiguous. There is no padding between fields. More information about the specific fields and their values follows:
Flag | Octal | Description |
---|---|---|
TSUID | 04000 | Set user ID on execution. |
TSGID | 02000 | Set group ID on execution. |
TSVTX | 01000 | Reserved. |
TUREAD | 00400 | Read by owner. |
TUWRITE | 00200 | Write by owner. |
TUEXEC | 00100 | Execute or search by owner. |
TGREAD | 00040 | Read by group. |
TGWRITE | 00020 | Write by group. |
TGEXEC | 00010 | Execute or search by group. |
TOREAD | 00004 | Read by others. |
TOWRITE | 00002 | Write by others. |
TOEXEC | 00001 | Execute or search by other. |
Flag | Value | Description |
---|---|---|
REGTYPE | '0' | Regular file. |
AREGTYPE | '\0' | Regular file. |
LNKTYPE | '1' | Link. |
SYMTYPE | '2' | Reserved. |
CHRTYPE | '3' | Character special. |
BLKTYPE | '4' | Block special. |
DIRTYPE | '5' | Directory. In this case, the size field has no meaning. |
FIFOTYPE | '6' | FIFO special. Archiving a FIFO file archives its existence, not contents. |
CONTTYPE | '7' | Reserved. |
If other values are used, the file is extracted as a regular file and a warning issued to the standard error output. Numeric fields are terminated with a space and a null byte.
The LNKTYPE flag represents a link to another file, of any type, previously archived. Such linked-to files are identified by each file having the same device and file serial number. The linked-to name is specified in the linkname field, including a trailing null byte.
The tar command.