1*49650Scael.\" Copyright (c) 1983, 1991 Regents of the University of California. 247845Sbostic.\" All rights reserved. 320827Smckusick.\" 4*49650Scael.\" %sccs.include.redist.roff% 520827Smckusick.\" 6*49650Scael.\" @(#)tarformat.5 6.4 (Berkeley) 05/10/91 747845Sbostic.\" 8*49650Scael.Dd 9*49650Scael.Dt TAR 5 10*49650Scael.Os BSD 4.2 11*49650Scael.Sh NAME 12*49650Scael.Nm tar 13*49650Scael.Nd tape archive file format 14*49650Scael.Sh DESCRIPTION 15*49650ScaelThe 16*49650Scael.Nm tar 17*49650Scaeltape archive command 1820827Smckusickdumps several files into one, in a medium suitable for transportation. 19*49650Scael.Pp 20*49650ScaelA ``tar tape'' or file is a series of blocks. Each block is of size 21*49650Scael.Dv TBLOCK . 2220827SmckusickA file on the tape is represented by a header block which describes 2320827Smckusickthe file, followed by zero or more blocks which give the contents of the 2420827Smckusickfile. At the end of the tape are two blocks filled with binary 2520827Smckusickzeros, as an end-of-file indicator. 26*49650Scael.Pp 27*49650ScaelThe blocks are grouped for physical 28*49650Scael.Tn I/O 29*49650Scaeloperations. Each group of 30*49650Scael.Ar n 31*49650Scaelfunctions 3220827Smckusickblocks (where 33*49650Scael.Ar n 3420827Smckusickis set by the 35*49650Scael.Cm b 3620827Smckusickkeyletter on the 37*49650Scael.Xr tar 1 3820827Smckusickcommand line \(em default is 20 blocks) is written with a single system 3920827Smckusickcall; on nine-track tapes, the result of this write is a single tape 4020827Smckusickrecord. The last group is always written at the full size, so blocks after 4120827Smckusickthe two zero blocks contain random data. On reading, the specified or 4220827Smckusickdefault group size is used for the 4320827Smckusickfirst read, but if that read returns less than a full tape block, the reduced 4420827Smckusickblock size is used for further reads. 45*49650Scael.Pp 4620827SmckusickThe header block looks like: 47*49650Scael.Bd -literal -offset indent 4820827Smckusick#define TBLOCK 512 49*49650Scael#define NBLOCK 20 5020827Smckusick#define NAMSIZ 100 5120827Smckusick 5220827Smckusickunion hblock { 53*49650Scael char dummy[TBLOCK]; 54*49650Scael struct header { 55*49650Scael char name[NAMSIZ]; 56*49650Scael char mode[8]; 57*49650Scael char uid[8]; 58*49650Scael char gid[8]; 59*49650Scael char size[12]; 60*49650Scael char mtime[12]; 61*49650Scael char chksum[8]; 62*49650Scael char linkflag; 63*49650Scael char linkname[NAMSIZ]; 64*49650Scael } dbuf; 6520827Smckusick}; 66*49650Scael.Ed 67*49650Scael.Pp 68*49650ScaelThe 69*49650Scael.Fa name 70*49650Scaelfield 7120827Smckusickis a null-terminated string. 72*49650ScaelThe other fields are zero-filled octal numbers in 73*49650Scael.Tn ASCII . 74*49650ScaelEach field 75*49650Scael(of width w) contains w\-2 digits, a space, and a null, except 76*49650Scael.Xr size 7720827Smckusickand 78*49650Scael.Fa mtime , 7925418Sbloomwhich do not contain the trailing null and 80*49650Scael.Fa chksum 8125418Sbloomwhich has a null followed by a space. 82*49650Scael.Fa Name 8320827Smckusickis the name of the file, as specified on the 84*49650Scael.Nm tar 85*49650Scaelcommand line. 86*49650ScaelFiles dumped because they were in a directory which 8720827Smckusickwas named in the command line have the directory name as prefix and 88*49650Scael.Pa /filename 8920827Smckusickas suffix. 90*49650Scael.Fa Mode 9120827Smckusickis the file mode, with the top bit masked off. 92*49650Scael.Fa Uid 9320827Smckusickand 94*49650Scael.Fa gid 9520827Smckusickare the user and group numbers which own the file. 96*49650Scael.Fa Size 9720827Smckusickis the size of the file in bytes. Links and symbolic links are dumped 9820827Smckusickwith this field specified as zero. 99*49650Scael.Fa Mtime 10020827Smckusickis the modification time of the file at the time it was dumped. 101*49650Scael.Fa Chksum 102*49650Scaelis an octal 103*49650Scael.Tn ASCII 104*49650Scaelvalue which represents the sum of all the bytes in the 10520827Smckusickheader block. When calculating the checksum, the 106*49650Scael.Fa chksum 10720827Smckusickfield is treated as if it were all blanks. 108*49650Scael.Fa Linkflag 109*49650Scaelis 110*49650Scael.Dv NULL 111*49650Scaelif the file is ``normal'' or a special file, 112*49650Scael.Tn ASCII 113*49650Scael`1' 114*49650Scaelif it is an hard link, and 115*49650Scael.Tn ASCII 116*49650Scael`2' 11720827Smckusickif it is a symbolic link. The name linked-to, if any, is in 118*49650Scael.Fa linkname , 11920827Smckusickwith a trailing null. 12020827SmckusickUnused fields of the header are binary zeros (and are included in the 12120827Smckusickchecksum). 122*49650Scael.Pp 12320827SmckusickThe first time a given i-node number is dumped, it is dumped as a regular 12420827Smckusickfile. The second and subsequent times, it is dumped as a link instead. 12520827SmckusickUpon retrieval, if a link entry is retrieved, but not the file it was 12620827Smckusicklinked to, an error message is printed and the tape must be manually 12720827Smckusickre-scanned to retrieve the linked-to file. 128*49650Scael.Pp 12920827SmckusickThe encoding of the header is designed to be portable across machines. 130*49650Scael.Sh SEE ALSO 131*49650Scael.Xr tar 1 132*49650Scael.Sh BUGS 133*49650ScaelNames or linknames longer than 134*49650Scael.Dv NAMSIZ 135*49650Scaelproduce error reports and cannot be 13620827Smckusickdumped. 137*49650Scael.Sh HISTORY 138*49650ScaelThe 139*49650Scael.Nm 140*49650Scaelfile format manual appeared in 141*49650Scael.Bx 4.2 . 142