Commit | Line | Data |
---|---|---|
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 | .\" @(#)tarformat.5 6.2 (Berkeley) %G% |
0204d2d0 | 6 | .\" |
28181978 | 7 | .TH TAR 5 "" |
0204d2d0 KM |
8 | .UC 5 |
9 | .SH NAME | |
10 | tar \- tape archive file format | |
11 | .SH DESCRIPTION | |
12 | .IR Tar , | |
13 | (the tape archive command) | |
14 | dumps several files into one, in a medium suitable for transportation. | |
15 | .PP | |
16 | A ``tar tape'' or file is a series of blocks. Each block is of size TBLOCK. | |
17 | A file on the tape is represented by a header block which describes | |
18 | the file, followed by zero or more blocks which give the contents of the | |
19 | file. At the end of the tape are two blocks filled with binary | |
20 | zeros, as an end-of-file indicator. | |
21 | .PP | |
22 | The blocks are grouped for physical I/O operations. Each group of | |
23 | .I n | |
24 | blocks (where | |
25 | .I n | |
26 | is set by the | |
27 | .B b | |
28 | keyletter on the | |
29 | .IR tar (1) | |
30 | command line \(em default is 20 blocks) is written with a single system | |
31 | call; on nine-track tapes, the result of this write is a single tape | |
32 | record. The last group is always written at the full size, so blocks after | |
33 | the two zero blocks contain random data. On reading, the specified or | |
34 | default group size is used for the | |
35 | first read, but if that read returns less than a full tape block, the reduced | |
36 | block size is used for further reads. | |
37 | .PP | |
38 | The header block looks like: | |
39 | .RS | |
40 | .PP | |
41 | .nf | |
42 | #define TBLOCK 512 | |
43 | #define NAMSIZ 100 | |
44 | ||
45 | union 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 | |
64 | is a null-terminated string. | |
65 | The 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 | |
68 | and | |
69 | .IR mtime , | |
4608ef7b JB |
70 | which do not contain the trailing null and |
71 | .IR chksum | |
72 | which has a null followed by a space. | |
0204d2d0 KM |
73 | .IR Name |
74 | is the name of the file, as specified on the | |
75 | .I tar | |
76 | command line. Files dumped because they were in a directory which | |
77 | was named in the command line have the directory name as prefix and | |
78 | .I /filename | |
79 | as 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 | |
89 | is the file mode, with the top bit masked off. | |
90 | .IR Uid | |
91 | and | |
92 | .IR gid | |
93 | are the user and group numbers which own the file. | |
94 | .IR Size | |
95 | is the size of the file in bytes. Links and symbolic links are dumped | |
96 | with this field specified as zero. | |
97 | .IR Mtime | |
98 | is the modification time of the file at the time it was dumped. | |
99 | .IR Chksum | |
4608ef7b | 100 | is an octal ASCII value which represents the sum of all the bytes in the |
0204d2d0 KM |
101 | header block. When calculating the checksum, the |
102 | .IR chksum | |
103 | field is treated as if it were all blanks. | |
104 | .IR Linkflag | |
4608ef7b | 105 | is NULL if the file is ``normal'' or a special file, ASCII `1' |
0204d2d0 KM |
106 | if it is an hard link, and ASCII `2' |
107 | if it is a symbolic link. The name linked-to, if any, is in | |
108 | .IR linkname, | |
109 | with a trailing null. | |
110 | Unused fields of the header are binary zeros (and are included in the | |
111 | checksum). | |
112 | .PP | |
113 | The first time a given i-node number is dumped, it is dumped as a regular | |
114 | file. The second and subsequent times, it is dumped as a link instead. | |
115 | Upon retrieval, if a link entry is retrieved, but not the file it was | |
116 | linked to, an error message is printed and the tape must be manually | |
117 | re-scanned to retrieve the linked-to file. | |
118 | .PP | |
119 | The encoding of the header is designed to be portable across machines. | |
120 | .SH "SEE ALSO" | |
121 | tar(1) | |
122 | .SH BUGS | |
123 | Names or linknames longer than NAMSIZ produce error reports and cannot be | |
124 | dumped. |