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