manual page first distributed with 4.2BSD
[unix-history] / usr / src / usr.bin / ar / tar.5
CommitLineData
0204d2d0
KM
1.\" Copyright (c) 1983 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
5.\" @(#)tar.5 5.1 (Berkeley) %G%
6.\"
7.TH TAR 5 "15 January 1983"
8.UC 5
9.SH NAME
10tar \- tape archive file format
11.SH DESCRIPTION
12.IR Tar ,
13(the tape archive command)
14dumps several files into one, in a medium suitable for transportation.
15.PP
16A ``tar tape'' or file is a series of blocks. Each block is of size TBLOCK.
17A file on the tape is represented by a header block which describes
18the file, followed by zero or more blocks which give the contents of the
19file. At the end of the tape are two blocks filled with binary
20zeros, as an end-of-file indicator.
21.PP
22The blocks are grouped for physical I/O operations. Each group of
23.I n
24blocks (where
25.I n
26is set by the
27.B b
28keyletter on the
29.IR tar (1)
30command line \(em default is 20 blocks) is written with a single system
31call; on nine-track tapes, the result of this write is a single tape
32record. The last group is always written at the full size, so blocks after
33the two zero blocks contain random data. On reading, the specified or
34default group size is used for the
35first read, but if that read returns less than a full tape block, the reduced
36block size is used for further reads.
37.PP
38The header block looks like:
39.RS
40.PP
41.nf
42#define TBLOCK 512
43#define NAMSIZ 100
44
45union hblock {
46 char dummy[TBLOCK];
47 struct header {
48 char name[NAMSIZ];
49 char mode[8];
50 char uid[8];
51 char gid[8];
52 char size[12];
53 char mtime[12];
54 char chksum[8];
55 char linkflag;
56 char linkname[NAMSIZ];
57 } dbuf;
58};
59.ta \w'#define 'u +\w'SARMAG 'u
60.fi
61.RE
62.LP
63.IR Name
64is a null-terminated string.
65The other fields are zero-filled octal numbers in ASCII. Each field
66(of width w) contains w-2 digits, a space, and a null, except
67.IR size
68and
69.IR mtime ,
70which do not contain the trailing null.
71.IR Name
72is the name of the file, as specified on the
73.I tar
74command line. Files dumped because they were in a directory which
75was named in the command line have the directory name as prefix and
76.I /filename
77as suffix.
78. \"Whatever format was used in the command line
79. \"will appear here, such as
80. \".I \&./yellow
81. \"or
82. \".IR \&../../brick/./road/.. .
83. \"To retrieve a file from a tar tape, an exact prefix match must be specified,
84. \"including all of the directory prefix information used on the command line
85. \"that dumped the file (if any).
86.IR Mode
87is the file mode, with the top bit masked off.
88.IR Uid
89and
90.IR gid
91are the user and group numbers which own the file.
92.IR Size
93is the size of the file in bytes. Links and symbolic links are dumped
94with this field specified as zero.
95.IR Mtime
96is the modification time of the file at the time it was dumped.
97.IR Chksum
98is a decimal ASCII value which represents the sum of all the bytes in the
99header block. When calculating the checksum, the
100.IR chksum
101field is treated as if it were all blanks.
102.IR Linkflag
103is ASCII `0' if the file is ``normal'' or a special file, ASCII `1'
104if it is an hard link, and ASCII `2'
105if it is a symbolic link. The name linked-to, if any, is in
106.IR linkname,
107with a trailing null.
108Unused fields of the header are binary zeros (and are included in the
109checksum).
110.PP
111The first time a given i-node number is dumped, it is dumped as a regular
112file. The second and subsequent times, it is dumped as a link instead.
113Upon retrieval, if a link entry is retrieved, but not the file it was
114linked to, an error message is printed and the tape must be manually
115re-scanned to retrieve the linked-to file.
116.PP
117The encoding of the header is designed to be portable across machines.
118.SH "SEE ALSO"
119tar(1)
120.SH BUGS
121Names or linknames longer than NAMSIZ produce error reports and cannot be
122dumped.