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