1.\" Copyright (c) 1983, 1991 Regents of the University of California. 2.\" All rights reserved. 3.\" 4.\" %sccs.include.redist.roff% 5.\" 6.\" @(#)tarformat.5 6.4 (Berkeley) 05/10/91 7.\" 8.Dd 9.Dt TAR 5 10.Os BSD 4.2 11.Sh NAME 12.Nm tar 13.Nd tape archive file format 14.Sh DESCRIPTION 15The 16.Nm tar 17tape archive command 18dumps several files into one, in a medium suitable for transportation. 19.Pp 20A ``tar tape'' or file is a series of blocks. Each block is of size 21.Dv TBLOCK . 22A file on the tape is represented by a header block which describes 23the file, followed by zero or more blocks which give the contents of the 24file. At the end of the tape are two blocks filled with binary 25zeros, as an end-of-file indicator. 26.Pp 27The blocks are grouped for physical 28.Tn I/O 29operations. Each group of 30.Ar n 31functions 32blocks (where 33.Ar n 34is set by the 35.Cm b 36keyletter on the 37.Xr tar 1 38command line \(em default is 20 blocks) is written with a single system 39call; on nine-track tapes, the result of this write is a single tape 40record. The last group is always written at the full size, so blocks after 41the two zero blocks contain random data. On reading, the specified or 42default group size is used for the 43first read, but if that read returns less than a full tape block, the reduced 44block size is used for further reads. 45.Pp 46The header block looks like: 47.Bd -literal -offset indent 48#define TBLOCK 512 49#define NBLOCK 20 50#define NAMSIZ 100 51 52union hblock { 53 char dummy[TBLOCK]; 54 struct header { 55 char name[NAMSIZ]; 56 char mode[8]; 57 char uid[8]; 58 char gid[8]; 59 char size[12]; 60 char mtime[12]; 61 char chksum[8]; 62 char linkflag; 63 char linkname[NAMSIZ]; 64 } dbuf; 65}; 66.Ed 67.Pp 68The 69.Fa name 70field 71is a null-terminated string. 72The other fields are zero-filled octal numbers in 73.Tn ASCII . 74Each field 75(of width w) contains w\-2 digits, a space, and a null, except 76.Xr size 77and 78.Fa mtime , 79which do not contain the trailing null and 80.Fa chksum 81which has a null followed by a space. 82.Fa Name 83is the name of the file, as specified on the 84.Nm tar 85command line. 86Files dumped because they were in a directory which 87was named in the command line have the directory name as prefix and 88.Pa /filename 89as suffix. 90.Fa Mode 91is the file mode, with the top bit masked off. 92.Fa Uid 93and 94.Fa gid 95are the user and group numbers which own the file. 96.Fa Size 97is the size of the file in bytes. Links and symbolic links are dumped 98with this field specified as zero. 99.Fa Mtime 100is the modification time of the file at the time it was dumped. 101.Fa Chksum 102is an octal 103.Tn ASCII 104value which represents the sum of all the bytes in the 105header block. When calculating the checksum, the 106.Fa chksum 107field is treated as if it were all blanks. 108.Fa Linkflag 109is 110.Dv NULL 111if the file is ``normal'' or a special file, 112.Tn ASCII 113`1' 114if it is an hard link, and 115.Tn ASCII 116`2' 117if it is a symbolic link. The name linked-to, if any, is in 118.Fa linkname , 119with a trailing null. 120Unused fields of the header are binary zeros (and are included in the 121checksum). 122.Pp 123The first time a given i-node number is dumped, it is dumped as a regular 124file. The second and subsequent times, it is dumped as a link instead. 125Upon retrieval, if a link entry is retrieved, but not the file it was 126linked to, an error message is printed and the tape must be manually 127re-scanned to retrieve the linked-to file. 128.Pp 129The encoding of the header is designed to be portable across machines. 130.Sh SEE ALSO 131.Xr tar 1 132.Sh BUGS 133Names or linknames longer than 134.Dv NAMSIZ 135produce error reports and cannot be 136dumped. 137.Sh HISTORY 138The 139.Nm 140file format manual appeared in 141.Bx 4.2 . 142