1 @comment GNU tar Archive Format description.
3 @comment Copyright 1988-1989, 1991-1997, 2000-2001, 2003-2007, 2012-2013
4 @comment Free Software Foundation, Inc.
6 @comment This file is part of GNU tar.
8 @comment GNU tar is free software; you can redistribute it and/or modify
9 @comment it under the terms of the GNU General Public License as published by
10 @comment the Free Software Foundation; either version 3 of the License, or
11 @comment (at your option) any later version.
13 @comment GNU tar is distributed in the hope that it will be useful,
14 @comment but WITHOUT ANY WARRANTY; without even the implied warranty of
15 @comment MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 @comment GNU General Public License for more details.
18 @comment You should have received a copy of the GNU General Public License
19 @comment along with this program. If not, see <http://www.gnu.org/licenses/>.
21 /*@r{ tar Header Block, from POSIX 1003.1-1990. }*/
23 /*@r{ POSIX header. }*/
26 @{ /*@r{ byte offset }*/
27 char name[100]; /*@r{ 0 }*/
28 char mode[8]; /*@r{ 100 }*/
29 char uid[8]; /*@r{ 108 }*/
30 char gid[8]; /*@r{ 116 }*/
31 char size[12]; /*@r{ 124 }*/
32 char mtime[12]; /*@r{ 136 }*/
33 char chksum[8]; /*@r{ 148 }*/
34 char typeflag; /*@r{ 156 }*/
35 char linkname[100]; /*@r{ 157 }*/
36 char magic[6]; /*@r{ 257 }*/
37 char version[2]; /*@r{ 263 }*/
38 char uname[32]; /*@r{ 265 }*/
39 char gname[32]; /*@r{ 297 }*/
40 char devmajor[8]; /*@r{ 329 }*/
41 char devminor[8]; /*@r{ 337 }*/
42 char prefix[155]; /*@r{ 345 }*/
46 #define TMAGIC "ustar" /*@r{ ustar and a null }*/
48 #define TVERSION "00" /*@r{ 00 and no null }*/
51 /*@r{ Values used in typeflag field. }*/
52 #define REGTYPE '0' /*@r{ regular file }*/
53 #define AREGTYPE '\0' /*@r{ regular file }*/
54 #define LNKTYPE '1' /*@r{ link }*/
55 #define SYMTYPE '2' /*@r{ reserved }*/
56 #define CHRTYPE '3' /*@r{ character special }*/
57 #define BLKTYPE '4' /*@r{ block special }*/
58 #define DIRTYPE '5' /*@r{ directory }*/
59 #define FIFOTYPE '6' /*@r{ FIFO special }*/
60 #define CONTTYPE '7' /*@r{ reserved }*/
62 #define XHDTYPE 'x' /*@r{ Extended header referring to the
63 next file in the archive }*/
64 #define XGLTYPE 'g' /*@r{ Global extended header }*/
66 /*@r{ Bits used in the mode field, values in octal. }*/
67 #define TSUID 04000 /*@r{ set UID on execution }*/
68 #define TSGID 02000 /*@r{ set GID on execution }*/
69 #define TSVTX 01000 /*@r{ reserved }*/
70 /*@r{ file permissions }*/
71 #define TUREAD 00400 /*@r{ read by owner }*/
72 #define TUWRITE 00200 /*@r{ write by owner }*/
73 #define TUEXEC 00100 /*@r{ execute/search by owner }*/
74 #define TGREAD 00040 /*@r{ read by group }*/
75 #define TGWRITE 00020 /*@r{ write by group }*/
76 #define TGEXEC 00010 /*@r{ execute/search by group }*/
77 #define TOREAD 00004 /*@r{ read by other }*/
78 #define TOWRITE 00002 /*@r{ write by other }*/
79 #define TOEXEC 00001 /*@r{ execute/search by other }*/
81 /*@r{ tar Header Block, GNU extensions. }*/
83 /*@r{ In GNU tar, SYMTYPE is for to symbolic links, and CONTTYPE is for
84 contiguous files, so maybe disobeying the "reserved" comment in POSIX
85 header description. I suspect these were meant to be used this way, and
86 should not have really been "reserved" in the published standards. }*/
88 /*@r{ *BEWARE* *BEWARE* *BEWARE* that the following information is still
89 boiling, and may change. Even if the OLDGNU format description should be
90 accurate, the so-called GNU format is not yet fully decided. It is
91 surely meant to use only extensions allowed by POSIX, but the sketch
92 below repeats some ugliness from the OLDGNU format, which should rather
93 go away. Sparse files should be saved in such a way that they do *not*
94 require two passes at archive creation time. Huge files get some POSIX
95 fields to overflow, alternate solutions have to be sought for this. }*/
97 /*@r{ Descriptor for a single file hole. }*/
100 @{ /*@r{ byte offset }*/
101 char offset[12]; /*@r{ 0 }*/
102 char numbytes[12]; /*@r{ 12 }*/
106 /*@r{ Sparse files are not supported in POSIX ustar format. For sparse files
107 with a POSIX header, a GNU extra header is provided which holds overall
108 sparse information and a few sparse descriptors. When an old GNU header
109 replaces both the POSIX header and the GNU extra header, it holds some
110 sparse descriptors too. Whether POSIX or not, if more sparse descriptors
111 are still needed, they are put into as many successive sparse headers as
112 necessary. The following constants tell how many sparse descriptors fit
113 in each kind of header able to hold them. }*/
115 #define SPARSES_IN_EXTRA_HEADER 16
116 #define SPARSES_IN_OLDGNU_HEADER 4
117 #define SPARSES_IN_SPARSE_HEADER 21
119 /*@r{ Extension header for sparse files, used immediately after the GNU extra
120 header, and used only if all sparse information cannot fit into that
121 extra header. There might even be many such extension headers, one after
122 the other, until all sparse information has been recorded. }*/
125 @{ /*@r{ byte offset }*/
126 struct sparse sp[SPARSES_IN_SPARSE_HEADER];
128 char isextended; /*@r{ 504 }*/
132 /*@r{ The old GNU format header conflicts with POSIX format in such a way that
133 POSIX archives may fool old GNU tar's, and POSIX tar's might well be
134 fooled by old GNU tar archives. An old GNU format header uses the space
135 used by the prefix field in a POSIX header, and cumulates information
136 normally found in a GNU extra header. With an old GNU tar header, we
137 never see any POSIX header nor GNU extra header. Supplementary sparse
138 headers are allowed, however. }*/
141 @{ /*@r{ byte offset }*/
142 char unused_pad1[345]; /*@r{ 0 }*/
143 char atime[12]; /*@r{ 345 Incr. archive: atime of the file }*/
144 char ctime[12]; /*@r{ 357 Incr. archive: ctime of the file }*/
145 char offset[12]; /*@r{ 369 Multivolume archive: the offset of
146 the start of this volume }*/
147 char longnames[4]; /*@r{ 381 Not used }*/
148 char unused_pad2; /*@r{ 385 }*/
149 struct sparse sp[SPARSES_IN_OLDGNU_HEADER];
151 char isextended; /*@r{ 482 Sparse file: Extension sparse header
153 char realsize[12]; /*@r{ 483 Sparse file: Real size}*/
157 /*@r{ OLDGNU_MAGIC uses both magic and version fields, which are contiguous.
158 Found in an archive, it indicates an old GNU header format, which will be
159 hopefully become obsolescent. With OLDGNU_MAGIC, uname and gname are
160 valid, though the header is not truly POSIX conforming. }*/
161 #define OLDGNU_MAGIC "ustar " /*@r{ 7 chars and a null }*/
163 /*@r{ The standards committee allows only capital A through capital Z for
164 user-defined expansion. Other letters in use include:
166 'A' Solaris Access Control List
167 'E' Solaris Extended Attribute File
168 'I' Inode only, as in 'star'
169 'N' Obsolete GNU tar, for file names that do not fit into the main header.
170 'X' POSIX 1003.1-2001 eXtended (VU version) }*/
172 /*@r{ This is a dir entry that contains the names of files that were in the
173 dir at the time the dump was made. }*/
174 #define GNUTYPE_DUMPDIR 'D'
176 /*@r{ Identifies the *next* file on the tape as having a long linkname. }*/
177 #define GNUTYPE_LONGLINK 'K'
179 /*@r{ Identifies the *next* file on the tape as having a long name. }*/
180 #define GNUTYPE_LONGNAME 'L'
182 /*@r{ This is the continuation of a file that began on another volume. }*/
183 #define GNUTYPE_MULTIVOL 'M'
185 /*@r{ This is for sparse files. }*/
186 #define GNUTYPE_SPARSE 'S'
188 /*@r{ This file is a tape/volume header. Ignore it on extraction. }*/
189 #define GNUTYPE_VOLHDR 'V'
191 /*@r{ Solaris extended header }*/
192 #define SOLARIS_XHDTYPE 'X'
194 /*@r{ J@"org Schilling star header }*/
197 @{ /*@r{ byte offset }*/
198 char name[100]; /*@r{ 0 }*/
199 char mode[8]; /*@r{ 100 }*/
200 char uid[8]; /*@r{ 108 }*/
201 char gid[8]; /*@r{ 116 }*/
202 char size[12]; /*@r{ 124 }*/
203 char mtime[12]; /*@r{ 136 }*/
204 char chksum[8]; /*@r{ 148 }*/
205 char typeflag; /*@r{ 156 }*/
206 char linkname[100]; /*@r{ 157 }*/
207 char magic[6]; /*@r{ 257 }*/
208 char version[2]; /*@r{ 263 }*/
209 char uname[32]; /*@r{ 265 }*/
210 char gname[32]; /*@r{ 297 }*/
211 char devmajor[8]; /*@r{ 329 }*/
212 char devminor[8]; /*@r{ 337 }*/
213 char prefix[131]; /*@r{ 345 }*/
214 char atime[12]; /*@r{ 476 }*/
215 char ctime[12]; /*@r{ 488 }*/
219 #define SPARSES_IN_STAR_HEADER 4
220 #define SPARSES_IN_STAR_EXT_HEADER 21
222 struct star_in_header
224 char fill[345]; /*@r{ 0 Everything that is before t_prefix }*/
225 char prefix[1]; /*@r{ 345 t_name prefix }*/
226 char fill2; /*@r{ 346 }*/
227 char fill3[8]; /*@r{ 347 }*/
228 char isextended; /*@r{ 355 }*/
229 struct sparse sp[SPARSES_IN_STAR_HEADER]; /*@r{ 356 }*/
230 char realsize[12]; /*@r{ 452 Actual size of the file }*/
231 char offset[12]; /*@r{ 464 Offset of multivolume contents }*/
232 char atime[12]; /*@r{ 476 }*/
233 char ctime[12]; /*@r{ 488 }*/
234 char mfill[8]; /*@r{ 500 }*/
235 char xmagic[4]; /*@r{ 508 "tar" }*/
238 struct star_ext_header
240 struct sparse sp[SPARSES_IN_STAR_EXT_HEADER];