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