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