149650Scael.\" Copyright (c) 1983, 1991 Regents of the University of California. 247845Sbostic.\" All rights reserved. 320827Smckusick.\" 449650Scael.\" %sccs.include.redist.roff% 520827Smckusick.\" 6*65101Smckusick.\" @(#)tarformat.5 6.5 (Berkeley) 12/11/93 747845Sbostic.\" 849650Scael.Dd 949650Scael.Dt TAR 5 1049650Scael.Os BSD 4.2 1149650Scael.Sh NAME 1249650Scael.Nm tar 1349650Scael.Nd tape archive file format 1449650Scael.Sh DESCRIPTION 1549650ScaelThe 1649650Scael.Nm tar 1749650Scaeltape archive command 1820827Smckusickdumps several files into one, in a medium suitable for transportation. 1949650Scael.Pp 2049650ScaelA ``tar tape'' or file is a series of blocks. Each block is of size 2149650Scael.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. 2649650Scael.Pp 2749650ScaelThe blocks are grouped for physical 2849650Scael.Tn I/O 2949650Scaeloperations. Each group of 3049650Scael.Ar n 3149650Scaelfunctions 3220827Smckusickblocks (where 3349650Scael.Ar n 3420827Smckusickis set by the 3549650Scael.Cm b 3620827Smckusickkeyletter on the 3749650Scael.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. 4549650Scael.Pp 4620827SmckusickThe header block looks like: 4749650Scael.Bd -literal -offset indent 4820827Smckusick#define TBLOCK 512 4949650Scael#define NBLOCK 20 5020827Smckusick#define NAMSIZ 100 5120827Smckusick 5220827Smckusickunion hblock { 5349650Scael char dummy[TBLOCK]; 5449650Scael struct header { 5549650Scael char name[NAMSIZ]; 5649650Scael char mode[8]; 5749650Scael char uid[8]; 5849650Scael char gid[8]; 5949650Scael char size[12]; 6049650Scael char mtime[12]; 6149650Scael char chksum[8]; 6249650Scael char linkflag; 6349650Scael char linkname[NAMSIZ]; 6449650Scael } dbuf; 6520827Smckusick}; 6649650Scael.Ed 6749650Scael.Pp 6849650ScaelThe 6949650Scael.Fa name 7049650Scaelfield 7120827Smckusickis a null-terminated string. 7249650ScaelThe other fields are zero-filled octal numbers in 7349650Scael.Tn ASCII . 7449650ScaelEach field 7549650Scael(of width w) contains w\-2 digits, a space, and a null, except 7649650Scael.Xr size 7720827Smckusickand 7849650Scael.Fa mtime , 7925418Sbloomwhich do not contain the trailing null and 8049650Scael.Fa chksum 8125418Sbloomwhich has a null followed by a space. 8249650Scael.Fa Name 8320827Smckusickis the name of the file, as specified on the 8449650Scael.Nm tar 8549650Scaelcommand line. 8649650ScaelFiles dumped because they were in a directory which 8720827Smckusickwas named in the command line have the directory name as prefix and 8849650Scael.Pa /filename 8920827Smckusickas suffix. 9049650Scael.Fa Mode 9120827Smckusickis the file mode, with the top bit masked off. 9249650Scael.Fa Uid 9320827Smckusickand 9449650Scael.Fa gid 9520827Smckusickare the user and group numbers which own the file. 9649650Scael.Fa Size 9720827Smckusickis the size of the file in bytes. Links and symbolic links are dumped 9820827Smckusickwith this field specified as zero. 9949650Scael.Fa Mtime 10020827Smckusickis the modification time of the file at the time it was dumped. 10149650Scael.Fa Chksum 10249650Scaelis an octal 10349650Scael.Tn ASCII 10449650Scaelvalue which represents the sum of all the bytes in the 10520827Smckusickheader block. When calculating the checksum, the 10649650Scael.Fa chksum 10720827Smckusickfield is treated as if it were all blanks. 10849650Scael.Fa Linkflag 10949650Scaelis 11049650Scael.Dv NULL 11149650Scaelif the file is ``normal'' or a special file, 11249650Scael.Tn ASCII 11349650Scael`1' 114*65101Smckusickif it is a hard link, and 11549650Scael.Tn ASCII 11649650Scael`2' 11720827Smckusickif it is a symbolic link. The name linked-to, if any, is in 11849650Scael.Fa linkname , 11920827Smckusickwith a trailing null. 12020827SmckusickUnused fields of the header are binary zeros (and are included in the 12120827Smckusickchecksum). 12249650Scael.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. 12849650Scael.Pp 12920827SmckusickThe encoding of the header is designed to be portable across machines. 13049650Scael.Sh SEE ALSO 13149650Scael.Xr tar 1 13249650Scael.Sh BUGS 13349650ScaelNames or linknames longer than 13449650Scael.Dv NAMSIZ 13549650Scaelproduce error reports and cannot be 13620827Smckusickdumped. 13749650Scael.Sh HISTORY 13849650ScaelThe 13949650Scael.Nm 14049650Scaelfile format manual appeared in 14149650Scael.Bx 4.2 . 142