tar.h revision 225736
1178825Sdfr/*-
2233294Sstas * Copyright (c) 1992 Keith Muller.
3233294Sstas * Copyright (c) 1992, 1993
4233294Sstas *	The Regents of the University of California.  All rights reserved.
5178825Sdfr *
6233294Sstas * This code is derived from software contributed to Berkeley by
7233294Sstas * Keith Muller of the University of California, San Diego.
8233294Sstas *
9178825Sdfr * Redistribution and use in source and binary forms, with or without
10233294Sstas * modification, are permitted provided that the following conditions
11233294Sstas * are met:
12178825Sdfr * 1. Redistributions of source code must retain the above copyright
13233294Sstas *    notice, this list of conditions and the following disclaimer.
14233294Sstas * 2. Redistributions in binary form must reproduce the above copyright
15233294Sstas *    notice, this list of conditions and the following disclaimer in the
16178825Sdfr *    documentation and/or other materials provided with the distribution.
17178825Sdfr * 4. Neither the name of the University nor the names of its contributors
18178825Sdfr *    may be used to endorse or promote products derived from this software
19178825Sdfr *    without specific prior written permission.
20178825Sdfr *
21178825Sdfr * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22178825Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23178825Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24178825Sdfr * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25178825Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26178825Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27178825Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28178825Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29178825Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30178825Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31178825Sdfr * SUCH DAMAGE.
32178825Sdfr *
33178825Sdfr *	@(#)tar.h	8.2 (Berkeley) 4/18/94
34178825Sdfr * $FreeBSD: stable/9/bin/pax/tar.h 203613 2010-02-07 17:05:22Z imp $
35178825Sdfr */
36178825Sdfr
37178825Sdfr/*
38178825Sdfr * defines and data structures common to all tar formats
39178825Sdfr */
40178825Sdfr#define CHK_LEN		8		/* length of checksum field */
41178825Sdfr#define TNMSZ		100		/* size of name field */
42178825Sdfr#ifdef _PAX_
43178825Sdfr#define NULLCNT		2		/* number of null blocks in trailer */
44178825Sdfr#define CHK_OFFSET	148		/* start of checksum field */
45178825Sdfr#define BLNKSUM		256L		/* sum of checksum field using ' ' */
46178825Sdfr#endif /* _PAX_ */
47178825Sdfr
48233294Sstas/*
49233294Sstas * Values used in typeflag field in all tar formats
50233294Sstas * (only REGTYPE, LNKTYPE and SYMTYPE are used in old BSD tar headers)
51233294Sstas */
52233294Sstas#define	REGTYPE		'0'		/* Regular File */
53233294Sstas#define	AREGTYPE	'\0'		/* Regular File */
54233294Sstas#define	LNKTYPE		'1'		/* Link */
55178825Sdfr#define	SYMTYPE		'2'		/* Symlink */
56#define	CHRTYPE		'3'		/* Character Special File */
57#define	BLKTYPE		'4'		/* Block Special File */
58#define	DIRTYPE		'5'		/* Directory */
59#define	FIFOTYPE	'6'		/* FIFO */
60#define	CONTTYPE	'7'		/* high perf file */
61
62/*
63 * Mode field encoding of the different file types - values in octal
64 */
65#define TSUID		04000		/* Set UID on execution */
66#define TSGID		02000		/* Set GID on execution */
67#define TSVTX		01000		/* Reserved */
68#define TUREAD		00400		/* Read by owner */
69#define TUWRITE		00200		/* Write by owner */
70#define TUEXEC		00100		/* Execute/Search by owner */
71#define TGREAD		00040		/* Read by group */
72#define TGWRITE		00020		/* Write by group */
73#define TGEXEC		00010		/* Execute/Search by group */
74#define TOREAD		00004		/* Read by other */
75#define TOWRITE		00002		/* Write by other */
76#define TOEXEC		00001		/* Execute/Search by other */
77
78#ifdef _PAX_
79/*
80 * Pad with a bit mask, much faster than doing a mod but only works on powers
81 * of 2. Macro below is for block of 512 bytes.
82 */
83#define TAR_PAD(x)	((512 - ((x) & 511)) & 511)
84#endif /* _PAX_ */
85
86/*
87 * structure of an old tar header as it appeared in BSD releases
88 */
89typedef struct {
90	char name[TNMSZ];		/* name of entry */
91	char mode[8]; 			/* mode */
92	char uid[8]; 			/* uid */
93	char gid[8];			/* gid */
94	char size[12];			/* size */
95	char mtime[12];			/* modification time */
96	char chksum[CHK_LEN];		/* checksum */
97	char linkflag;			/* norm, hard, or sym. */
98	char linkname[TNMSZ];		/* linked to name */
99} HD_TAR __aligned(1);
100
101#ifdef _PAX_
102/*
103 * -o options for BSD tar to not write directories to the archive
104 */
105#define TAR_NODIR	"nodir"
106#define TAR_OPTION	"write_opt"
107
108/*
109 * default device names
110 */
111#define	DEV_0		"/dev/rmt0"
112#define	DEV_1		"/dev/rmt1"
113#define	DEV_4		"/dev/rmt4"
114#define	DEV_5		"/dev/rmt5"
115#define	DEV_7		"/dev/rmt7"
116#define	DEV_8		"/dev/rmt8"
117#endif /* _PAX_ */
118
119/*
120 * Data Interchange Format - Extended tar header format - POSIX 1003.1-1990
121 */
122#define TPFSZ		155
123#define	TMAGIC		"ustar"		/* ustar and a null */
124#define	TMAGLEN		6
125#define	TVERSION	"00"		/* 00 and no null */
126#define	TVERSLEN	2
127
128typedef struct {
129	char name[TNMSZ];		/* name of entry */
130	char mode[8]; 			/* mode */
131	char uid[8]; 			/* uid */
132	char gid[8];			/* gid */
133	char size[12];			/* size */
134	char mtime[12];			/* modification time */
135	char chksum[CHK_LEN];		/* checksum */
136	char typeflag;			/* type of file. */
137	char linkname[TNMSZ];		/* linked to name */
138	char magic[TMAGLEN];		/* magic cookie */
139	char version[TVERSLEN];		/* version */
140	char uname[32];			/* ascii owner name */
141	char gname[32];			/* ascii group name */
142	char devmajor[8];		/* major device number */
143	char devminor[8];		/* minor device number */
144	char prefix[TPFSZ];		/* linked to name */
145} HD_USTAR __aligned(1);
146