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