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