Coda Distributed File System
tar-FromRedHatCD.h
Go to the documentation of this file.
1// clang-format off
2/* GNU tar Archive Format description.
3
4 Copyright (C) 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996,
5 1997, 2000, 2001 Free Software Foundation, Inc.
6
7 This program is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any later
10 version.
11
12 This program is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15 Public License for more details.
16
17 You should have received a copy of the GNU General Public License along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20
21/* If OLDGNU_COMPATIBILITY is not zero, tar produces archives which, by
22 default, are readable by older versions of GNU tar. This can be
23 overridden by using --posix; in this case, POSIXLY_CORRECT in environment
24 may be set for enforcing stricter conformance. If OLDGNU_COMPATIBILITY
25 is zero or undefined, tar will eventually produces archives which, by
26 default, POSIX compatible; then either using --posix or defining
27 POSIXLY_CORRECT enforces stricter conformance.
28
29 This #define will disappear in a few years. FP, June 1995. */
30#define OLDGNU_COMPATIBILITY 1
31
32/* tar Header Block, from POSIX 1003.1-1990. */
33
34/* POSIX header. */
35
37{ /* byte offset */
38 char name[100]; /* 0 */
39 char mode[8]; /* 100 */
40 char uid[8]; /* 108 */
41 char gid[8]; /* 116 */
42 char size[12]; /* 124 */
43 char mtime[12]; /* 136 */
44 char chksum[8]; /* 148 */
45 char typeflag; /* 156 */
46 char linkname[100]; /* 157 */
47 char magic[6]; /* 257 */
48 char version[2]; /* 263 */
49 char uname[32]; /* 265 */
50 char gname[32]; /* 297 */
51 char devmajor[8]; /* 329 */
52 char devminor[8]; /* 337 */
53 char prefix[155]; /* 345 */
54 /* 500 */
55};
56
57#define TMAGIC "ustar" /* ustar and a null */
58#define TMAGLEN 6
59#define TVERSION "00" /* 00 and no null */
60#define TVERSLEN 2
61
62/* Values used in typeflag field. */
63#define REGTYPE '0' /* regular file */
64#define AREGTYPE '\0' /* regular file */
65#define LNKTYPE '1' /* link */
66#define SYMTYPE '2' /* reserved */
67#define CHRTYPE '3' /* character special */
68#define BLKTYPE '4' /* block special */
69#define DIRTYPE '5' /* directory */
70#define FIFOTYPE '6' /* FIFO special */
71#define CONTTYPE '7' /* reserved */
72
73/* Bits used in the mode field, values in octal. */
74#define TSUID 04000 /* set UID on execution */
75#define TSGID 02000 /* set GID on execution */
76#define TSVTX 01000 /* reserved */
77 /* file permissions */
78#define TUREAD 00400 /* read by owner */
79#define TUWRITE 00200 /* write by owner */
80#define TUEXEC 00100 /* execute/search by owner */
81#define TGREAD 00040 /* read by group */
82#define TGWRITE 00020 /* write by group */
83#define TGEXEC 00010 /* execute/search by group */
84#define TOREAD 00004 /* read by other */
85#define TOWRITE 00002 /* write by other */
86#define TOEXEC 00001 /* execute/search by other */
87
88/* tar Header Block, GNU extensions. */
89
90/* In GNU tar, SYMTYPE is for to symbolic links, and CONTTYPE is for
91 contiguous files, so maybe disobeying the `reserved' comment in POSIX
92 header description. I suspect these were meant to be used this way, and
93 should not have really been `reserved' in the published standards. */
94
95/* *BEWARE* *BEWARE* *BEWARE* that the following information is still
96 boiling, and may change. Even if the OLDGNU format description should be
97 accurate, the so-called GNU format is not yet fully decided. It is
98 surely meant to use only extensions allowed by POSIX, but the sketch
99 below repeats some ugliness from the OLDGNU format, which should rather
100 go away. Sparse files should be saved in such a way that they do *not*
101 require two passes at archive creation time. Huge files get some POSIX
102 fields to overflow, alternate solutions have to be sought for this. */
103
104/* Descriptor for a single file hole. */
105
106struct sparse
107{ /* byte offset */
108 char offset[12]; /* 0 */
109 char numbytes[12]; /* 12 */
110 /* 24 */
111};
112
113/* Sparse files are not supported in POSIX ustar format. For sparse files
114 with a POSIX header, a GNU extra header is provided which holds overall
115 sparse information and a few sparse descriptors. When an old GNU header
116 replaces both the POSIX header and the GNU extra header, it holds some
117 sparse descriptors too. Whether POSIX or not, if more sparse descriptors
118 are still needed, they are put into as many successive sparse headers as
119 necessary. The following constants tell how many sparse descriptors fit
120 in each kind of header able to hold them. */
121
122#define SPARSES_IN_EXTRA_HEADER 16
123#define SPARSES_IN_OLDGNU_HEADER 4
124#define SPARSES_IN_SPARSE_HEADER 21
125
126/* The GNU extra header contains some information GNU tar needs, but not
127 foreseen in POSIX header format. It is only used after a POSIX header
128 (and never with old GNU headers), and immediately follows this POSIX
129 header, when typeflag is a letter rather than a digit, so signaling a GNU
130 extension. */
131
133{ /* byte offset */
134 char atime[12]; /* 0 */
135 char ctime[12]; /* 12 */
136 char offset[12]; /* 24 */
137 char realsize[12]; /* 36 */
138 char longnames[4]; /* 48 */
139 char unused_pad1[68]; /* 52 */
141 /* 120 */
142 char isextended; /* 504 */
143 /* 505 */
144};
145
146/* Extension header for sparse files, used immediately after the GNU extra
147 header, and used only if all sparse information cannot fit into that
148 extra header. There might even be many such extension headers, one after
149 the other, until all sparse information has been recorded. */
150
152{ /* byte offset */
154 /* 0 */
155 char isextended; /* 504 */
156 /* 505 */
157};
158
159/* The old GNU format header conflicts with POSIX format in such a way that
160 POSIX archives may fool old GNU tar's, and POSIX tar's might well be
161 fooled by old GNU tar archives. An old GNU format header uses the space
162 used by the prefix field in a POSIX header, and cumulates information
163 normally found in a GNU extra header. With an old GNU tar header, we
164 never see any POSIX header nor GNU extra header. Supplementary sparse
165 headers are allowed, however. */
166
168{ /* byte offset */
169 char unused_pad1[345]; /* 0 */
170 char atime[12]; /* 345 */
171 char ctime[12]; /* 357 */
172 char offset[12]; /* 369 */
173 char longnames[4]; /* 381 */
174 char unused_pad2; /* 385 */
176 /* 386 */
177 char isextended; /* 482 */
178 char realsize[12]; /* 483 */
179 /* 495 */
180};
181
182/* OLDGNU_MAGIC uses both magic and version fields, which are contiguous.
183 Found in an archive, it indicates an old GNU header format, which will be
184 hopefully become obsolescent. With OLDGNU_MAGIC, uname and gname are
185 valid, though the header is not truly POSIX conforming. */
186#define OLDGNU_MAGIC "ustar " /* 7 chars and a null */
187
188/* The standards committee allows only capital A through capital Z for
189 user-defined expansion. */
190
191/* This is a dir entry that contains the names of files that were in the
192 dir at the time the dump was made. */
193#define GNUTYPE_DUMPDIR 'D'
194
195/* Identifies the *next* file on the tape as having a long linkname. */
196#define GNUTYPE_LONGLINK 'K'
197
198/* Identifies the *next* file on the tape as having a long name. */
199#define GNUTYPE_LONGNAME 'L'
200
201/* This is the continuation of a file that began on another volume. */
202#define GNUTYPE_MULTIVOL 'M'
203
204/* For storing filenames that do not fit into the main header. */
205#define GNUTYPE_NAMES 'N'
206
207/* This is for sparse files. */
208#define GNUTYPE_SPARSE 'S'
209
210/* This file is a tape/volume header. Ignore it on extraction. */
211#define GNUTYPE_VOLHDR 'V'
212
213/* tar Header Block, overall structure. */
214
215/* tar files are made in basic blocks of this size. */
216#define BLOCKSIZE 512
217
219{
220 DEFAULT_FORMAT, /* format to be decided later */
221 V7_FORMAT, /* old V7 tar format */
222 OLDGNU_FORMAT, /* GNU format as per before tar 1.12 */
223 POSIX_FORMAT, /* restricted, pure POSIX format */
224 GNU_FORMAT /* POSIX format with GNU extensions */
226
227union block
228{
234};
235
236/* End of Format description. */
Definition: coda_dir.h:58
Definition: tar-FromRedHatCD.h:133
char atime[12]
Definition: tar-FromRedHatCD.h:134
char longnames[4]
Definition: tar-FromRedHatCD.h:138
char unused_pad1[68]
Definition: tar-FromRedHatCD.h:139
char ctime[12]
Definition: tar-FromRedHatCD.h:135
char offset[12]
Definition: tar-FromRedHatCD.h:136
struct sparse sp[SPARSES_IN_EXTRA_HEADER]
Definition: tar-FromRedHatCD.h:140
char realsize[12]
Definition: tar-FromRedHatCD.h:137
char isextended
Definition: tar-FromRedHatCD.h:142
Definition: tar-FromRedHatCD.h:168
struct sparse sp[SPARSES_IN_OLDGNU_HEADER]
Definition: tar-FromRedHatCD.h:175
char unused_pad1[345]
Definition: tar-FromRedHatCD.h:169
char ctime[12]
Definition: tar-FromRedHatCD.h:171
char offset[12]
Definition: tar-FromRedHatCD.h:172
char unused_pad2
Definition: tar-FromRedHatCD.h:174
char longnames[4]
Definition: tar-FromRedHatCD.h:173
char atime[12]
Definition: tar-FromRedHatCD.h:170
char realsize[12]
Definition: tar-FromRedHatCD.h:178
char isextended
Definition: tar-FromRedHatCD.h:177
Definition: tar-FromRedHatCD.h:37
char mode[8]
Definition: tar-FromRedHatCD.h:39
char prefix[155]
Definition: tar-FromRedHatCD.h:53
char name[100]
Definition: tar-FromRedHatCD.h:38
char uid[8]
Definition: tar-FromRedHatCD.h:40
char mtime[12]
Definition: tar-FromRedHatCD.h:43
char devminor[8]
Definition: tar-FromRedHatCD.h:52
char size[12]
Definition: tar-FromRedHatCD.h:42
char gid[8]
Definition: tar-FromRedHatCD.h:41
char chksum[8]
Definition: tar-FromRedHatCD.h:44
char magic[6]
Definition: tar-FromRedHatCD.h:47
char devmajor[8]
Definition: tar-FromRedHatCD.h:51
char gname[32]
Definition: tar-FromRedHatCD.h:50
char uname[32]
Definition: tar-FromRedHatCD.h:49
char version[2]
Definition: tar-FromRedHatCD.h:48
char linkname[100]
Definition: tar-FromRedHatCD.h:46
char typeflag
Definition: tar-FromRedHatCD.h:45
Definition: tar-FromRedHatCD.h:152
char isextended
Definition: tar-FromRedHatCD.h:155
struct sparse sp[SPARSES_IN_SPARSE_HEADER]
Definition: tar-FromRedHatCD.h:153
Definition: tar-FromRedHatCD.h:107
char numbytes[12]
Definition: tar-FromRedHatCD.h:109
char offset[12]
Definition: tar-FromRedHatCD.h:108
#define SPARSES_IN_SPARSE_HEADER
Definition: tar-FromRedHatCD.h:124
#define SPARSES_IN_OLDGNU_HEADER
Definition: tar-FromRedHatCD.h:123
#define SPARSES_IN_EXTRA_HEADER
Definition: tar-FromRedHatCD.h:122
archive_format
Definition: tar-FromRedHatCD.h:219
@ GNU_FORMAT
Definition: tar-FromRedHatCD.h:224
@ OLDGNU_FORMAT
Definition: tar-FromRedHatCD.h:222
@ DEFAULT_FORMAT
Definition: tar-FromRedHatCD.h:220
@ POSIX_FORMAT
Definition: tar-FromRedHatCD.h:223
@ V7_FORMAT
Definition: tar-FromRedHatCD.h:221
#define BLOCKSIZE
Definition: tar-FromRedHatCD.h:216
Definition: tar-FromRedHatCD.h:228
struct posix_header header
Definition: tar-FromRedHatCD.h:230