make ORPHANS a function; files() bug fix
[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.\"
4608ef7b 5.\" @(#)tar.5 6.2 (Berkeley) %G%
0204d2d0 6.\"
28181978 7.TH TAR 5 ""
0204d2d0
KM
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 ,
4608ef7b
JB
70which do not contain the trailing null and
71.IR chksum
72which has a null followed by a space.
0204d2d0
KM
73.IR Name
74is the name of the file, as specified on the
75.I tar
76command line. Files dumped because they were in a directory which
77was named in the command line have the directory name as prefix and
78.I /filename
79as suffix.
80. \"Whatever format was used in the command line
81. \"will appear here, such as
82. \".I \&./yellow
83. \"or
84. \".IR \&../../brick/./road/.. .
85. \"To retrieve a file from a tar tape, an exact prefix match must be specified,
86. \"including all of the directory prefix information used on the command line
87. \"that dumped the file (if any).
88.IR Mode
89is the file mode, with the top bit masked off.
90.IR Uid
91and
92.IR gid
93are the user and group numbers which own the file.
94.IR Size
95is the size of the file in bytes. Links and symbolic links are dumped
96with this field specified as zero.
97.IR Mtime
98is the modification time of the file at the time it was dumped.
99.IR Chksum
4608ef7b 100is an octal ASCII value which represents the sum of all the bytes in the
0204d2d0
KM
101header block. When calculating the checksum, the
102.IR chksum
103field is treated as if it were all blanks.
104.IR Linkflag
4608ef7b 105is NULL if the file is ``normal'' or a special file, ASCII `1'
0204d2d0
KM
106if it is an hard link, and ASCII `2'
107if it is a symbolic link. The name linked-to, if any, is in
108.IR linkname,
109with a trailing null.
110Unused fields of the header are binary zeros (and are included in the
111checksum).
112.PP
113The first time a given i-node number is dumped, it is dumped as a regular
114file. The second and subsequent times, it is dumped as a link instead.
115Upon retrieval, if a link entry is retrieved, but not the file it was
116linked to, an error message is printed and the tape must be manually
117re-scanned to retrieve the linked-to file.
118.PP
119The encoding of the header is designed to be portable across machines.
120.SH "SEE ALSO"
121tar(1)
122.SH BUGS
123Names or linknames longer than NAMSIZ produce error reports and cannot be
124dumped.