tar.h revision 1.10 1 1.10 christos /* $NetBSD: tar.h,v 1.10 2013/01/24 17:43:44 christos Exp $ */
2 1.3 cgd
3 1.1 jtc /*-
4 1.8 agc * Copyright (c) 1992 Keith Muller.
5 1.1 jtc * Copyright (c) 1992, 1993
6 1.1 jtc * The Regents of the University of California. All rights reserved.
7 1.7 agc *
8 1.7 agc * This code is derived from software contributed to Berkeley by
9 1.7 agc * Keith Muller of the University of California, San Diego.
10 1.7 agc *
11 1.7 agc * Redistribution and use in source and binary forms, with or without
12 1.7 agc * modification, are permitted provided that the following conditions
13 1.7 agc * are met:
14 1.7 agc * 1. Redistributions of source code must retain the above copyright
15 1.7 agc * notice, this list of conditions and the following disclaimer.
16 1.7 agc * 2. Redistributions in binary form must reproduce the above copyright
17 1.7 agc * notice, this list of conditions and the following disclaimer in the
18 1.7 agc * documentation and/or other materials provided with the distribution.
19 1.7 agc * 3. Neither the name of the University nor the names of its contributors
20 1.1 jtc * may be used to endorse or promote products derived from this software
21 1.1 jtc * without specific prior written permission.
22 1.1 jtc *
23 1.1 jtc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 1.1 jtc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 1.1 jtc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 1.1 jtc * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 1.1 jtc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 1.1 jtc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 1.1 jtc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.1 jtc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.1 jtc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.1 jtc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.1 jtc * SUCH DAMAGE.
34 1.1 jtc *
35 1.3 cgd * @(#)tar.h 8.2 (Berkeley) 4/18/94
36 1.1 jtc */
37 1.1 jtc
38 1.1 jtc /*
39 1.1 jtc * defines and data structures common to all tar formats
40 1.1 jtc */
41 1.1 jtc #define CHK_LEN 8 /* length of checksum field */
42 1.1 jtc #define TNMSZ 100 /* size of name field */
43 1.1 jtc #ifdef _PAX_
44 1.1 jtc #define NULLCNT 2 /* number of null blocks in trailer */
45 1.1 jtc #define CHK_OFFSET 148 /* start of chksum field */
46 1.1 jtc #define BLNKSUM 256L /* sum of checksum field using ' ' */
47 1.1 jtc #endif /* _PAX_ */
48 1.1 jtc
49 1.1 jtc /*
50 1.1 jtc * Values used in typeflag field in all tar formats
51 1.1 jtc * (only REGTYPE, LNKTYPE and SYMTYPE are used in old bsd tar headers)
52 1.1 jtc */
53 1.1 jtc #define REGTYPE '0' /* Regular File */
54 1.1 jtc #define AREGTYPE '\0' /* Regular File */
55 1.1 jtc #define LNKTYPE '1' /* Link */
56 1.1 jtc #define SYMTYPE '2' /* Symlink */
57 1.1 jtc #define CHRTYPE '3' /* Character Special File */
58 1.1 jtc #define BLKTYPE '4' /* Block Special File */
59 1.1 jtc #define DIRTYPE '5' /* Directory */
60 1.1 jtc #define FIFOTYPE '6' /* FIFO */
61 1.1 jtc #define CONTTYPE '7' /* high perf file */
62 1.10 christos #define GLOBXTYPE 'g' /* global extended header */
63 1.10 christos #define FILEXTYPE 'x' /* file extended header */
64 1.4 mrg
65 1.4 mrg /*
66 1.4 mrg * GNU tar compatibility;
67 1.4 mrg */
68 1.4 mrg #define LONGLINKTYPE 'K' /* Long Symlink */
69 1.4 mrg #define LONGNAMETYPE 'L' /* Long File */
70 1.1 jtc
71 1.1 jtc /*
72 1.1 jtc * Mode field encoding of the different file types - values in octal
73 1.1 jtc */
74 1.1 jtc #define TSUID 04000 /* Set UID on execution */
75 1.1 jtc #define TSGID 02000 /* Set GID on execution */
76 1.1 jtc #define TSVTX 01000 /* Reserved */
77 1.1 jtc #define TUREAD 00400 /* Read by owner */
78 1.1 jtc #define TUWRITE 00200 /* Write by owner */
79 1.1 jtc #define TUEXEC 00100 /* Execute/Search by owner */
80 1.1 jtc #define TGREAD 00040 /* Read by group */
81 1.1 jtc #define TGWRITE 00020 /* Write by group */
82 1.1 jtc #define TGEXEC 00010 /* Execute/Search by group */
83 1.1 jtc #define TOREAD 00004 /* Read by other */
84 1.1 jtc #define TOWRITE 00002 /* Write by other */
85 1.1 jtc #define TOEXEC 00001 /* Execute/Search by other */
86 1.1 jtc
87 1.1 jtc #ifdef _PAX_
88 1.1 jtc /*
89 1.1 jtc * Pad with a bit mask, much faster than doing a mod but only works on powers
90 1.1 jtc * of 2. Macro below is for block of 512 bytes.
91 1.1 jtc */
92 1.1 jtc #define TAR_PAD(x) ((512 - ((x) & 511)) & 511)
93 1.1 jtc #endif /* _PAX_ */
94 1.1 jtc
95 1.1 jtc /*
96 1.1 jtc * structure of an old tar header as it appeared in BSD releases
97 1.1 jtc */
98 1.1 jtc typedef struct {
99 1.1 jtc char name[TNMSZ]; /* name of entry */
100 1.5 itohy char mode[8]; /* mode */
101 1.5 itohy char uid[8]; /* uid */
102 1.1 jtc char gid[8]; /* gid */
103 1.1 jtc char size[12]; /* size */
104 1.1 jtc char mtime[12]; /* modification time */
105 1.1 jtc char chksum[CHK_LEN]; /* checksum */
106 1.1 jtc char linkflag; /* norm, hard, or sym. */
107 1.1 jtc char linkname[TNMSZ]; /* linked to name */
108 1.1 jtc } HD_TAR;
109 1.1 jtc
110 1.1 jtc #ifdef _PAX_
111 1.1 jtc /*
112 1.1 jtc * -o options for BSD tar to not write directories to the archive
113 1.1 jtc */
114 1.1 jtc #define TAR_NODIR "nodir"
115 1.1 jtc #define TAR_OPTION "write_opt"
116 1.1 jtc
117 1.1 jtc /*
118 1.1 jtc * default device names
119 1.1 jtc */
120 1.9 christos extern char DEV_0[];
121 1.9 christos extern char DEV_1[];
122 1.9 christos extern char DEV_4[];
123 1.9 christos extern char DEV_5[];
124 1.9 christos extern char DEV_7[];
125 1.9 christos extern char DEV_8[];
126 1.1 jtc #endif /* _PAX_ */
127 1.1 jtc
128 1.1 jtc /*
129 1.1 jtc * Data Interchange Format - Extended tar header format - POSIX 1003.1-1990
130 1.1 jtc */
131 1.1 jtc #define TPFSZ 155
132 1.1 jtc #define TMAGIC "ustar" /* ustar and a null */
133 1.1 jtc #define TMAGLEN 6
134 1.1 jtc #define TVERSION "00" /* 00 and no null */
135 1.1 jtc #define TVERSLEN 2
136 1.1 jtc
137 1.1 jtc typedef struct {
138 1.1 jtc char name[TNMSZ]; /* name of entry */
139 1.5 itohy char mode[8]; /* mode */
140 1.5 itohy char uid[8]; /* uid */
141 1.1 jtc char gid[8]; /* gid */
142 1.1 jtc char size[12]; /* size */
143 1.1 jtc char mtime[12]; /* modification time */
144 1.1 jtc char chksum[CHK_LEN]; /* checksum */
145 1.1 jtc char typeflag; /* type of file. */
146 1.1 jtc char linkname[TNMSZ]; /* linked to name */
147 1.1 jtc char magic[TMAGLEN]; /* magic cookie */
148 1.1 jtc char version[TVERSLEN]; /* version */
149 1.1 jtc char uname[32]; /* ascii owner name */
150 1.1 jtc char gname[32]; /* ascii group name */
151 1.1 jtc char devmajor[8]; /* major device number */
152 1.1 jtc char devminor[8]; /* minor device number */
153 1.1 jtc char prefix[TPFSZ]; /* linked to name */
154 1.1 jtc } HD_USTAR;
155