1178253Sdelphij/*- 21573Srgrimes * Copyright (c) 1992 Keith Muller. 31573Srgrimes * Copyright (c) 1992, 1993 41573Srgrimes * The Regents of the University of California. All rights reserved. 51573Srgrimes * 61573Srgrimes * This code is derived from software contributed to Berkeley by 71573Srgrimes * Keith Muller of the University of California, San Diego. 81573Srgrimes * 91573Srgrimes * Redistribution and use in source and binary forms, with or without 101573Srgrimes * modification, are permitted provided that the following conditions 111573Srgrimes * are met: 121573Srgrimes * 1. Redistributions of source code must retain the above copyright 131573Srgrimes * notice, this list of conditions and the following disclaimer. 141573Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 151573Srgrimes * notice, this list of conditions and the following disclaimer in the 161573Srgrimes * documentation and/or other materials provided with the distribution. 171573Srgrimes * 4. Neither the name of the University nor the names of its contributors 181573Srgrimes * may be used to endorse or promote products derived from this software 191573Srgrimes * without specific prior written permission. 201573Srgrimes * 211573Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 221573Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 231573Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 241573Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 251573Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 261573Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 271573Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 281573Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 291573Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 301573Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3123668Speter * SUCH DAMAGE. 321573Srgrimes * 3390039Sobrien * @(#)tar.h 8.2 (Berkeley) 4/18/94 3490039Sobrien * $FreeBSD$ 351573Srgrimes */ 3671579Sdeischen 371573Srgrimes/* 3823768Sbde * defines and data structures common to all tar formats 397978Sbde */ 401573Srgrimes#define CHK_LEN 8 /* length of checksum field */ 411573Srgrimes#define TNMSZ 100 /* size of name field */ 427978Sbde#ifdef _PAX_ 431573Srgrimes#define NULLCNT 2 /* number of null blocks in trailer */ 441573Srgrimes#define CHK_OFFSET 148 /* start of checksum field */ 45108631Stjr#define BLNKSUM 256L /* sum of checksum field using ' ' */ 461573Srgrimes#endif /* _PAX_ */ 4771579Sdeischen 481573Srgrimes/* 4969841Sdeischen * Values used in typeflag field in all tar formats 501573Srgrimes * (only REGTYPE, LNKTYPE and SYMTYPE are used in old BSD tar headers) 5123668Speter */ 521573Srgrimes#define REGTYPE '0' /* Regular File */ 531573Srgrimes#define AREGTYPE '\0' /* Regular File */ 54178253Sdelphij#define LNKTYPE '1' /* Link */ 551573Srgrimes#define SYMTYPE '2' /* Symlink */ 5673632Sobrien#define CHRTYPE '3' /* Character Special File */ 5723668Speter#define BLKTYPE '4' /* Block Special File */ 5823668Speter#define DIRTYPE '5' /* Directory */ 591573Srgrimes#define FIFOTYPE '6' /* FIFO */ 6023668Speter#define CONTTYPE '7' /* high perf file */ 61178253Sdelphij 6223668Speter/* 6323668Speter * Mode field encoding of the different file types - values in octal 6423668Speter */ 6523668Speter#define TSUID 04000 /* Set UID on execution */ 6623768Sbde#define TSGID 02000 /* Set GID on execution */ 6723668Speter#define TSVTX 01000 /* Reserved */ 6823668Speter#define TUREAD 00400 /* Read by owner */ 6923668Speter#define TUWRITE 00200 /* Write by owner */ 7014910Sbde#define TUEXEC 00100 /* Execute/Search by owner */ 7171579Sdeischen#define TGREAD 00040 /* Read by group */ 7271579Sdeischen#define TGWRITE 00020 /* Write by group */ 7314910Sbde#define TGEXEC 00010 /* Execute/Search by group */ 7423668Speter#define TOREAD 00004 /* Read by other */ 7523768Sbde#define TOWRITE 00002 /* Write by other */ 7623668Speter#define TOEXEC 00001 /* Execute/Search by other */ 7714910Sbde 7823768Sbde#ifdef _PAX_ 7914910Sbde/* 8056698Sjasone * Pad with a bit mask, much faster than doing a mod but only works on powers 8123668Speter * of 2. Macro below is for block of 512 bytes. 8223768Sbde */ 8371579Sdeischen#define TAR_PAD(x) ((512 - ((x) & 511)) & 511) 8423768Sbde#endif /* _PAX_ */ 8523768Sbde 867978Sbde/* 8723768Sbde * structure of an old tar header as it appeared in BSD releases 887978Sbde */ 8956698Sjasonetypedef struct { 9069841Sdeischen char name[TNMSZ]; /* name of entry */ 9123768Sbde char mode[8]; /* mode */ 9223668Speter char uid[8]; /* uid */ 93133723Sstefanf char gid[8]; /* gid */ 9469841Sdeischen char size[12]; /* size */ 9569841Sdeischen char mtime[12]; /* modification time */ 9669841Sdeischen char chksum[CHK_LEN]; /* checksum */ 971573Srgrimes char linkflag; /* norm, hard, or sym. */ 9823768Sbde char linkname[TNMSZ]; /* linked to name */ 9923668Speter} HD_TAR __aligned(1); 10071579Sdeischen 1011573Srgrimes#ifdef _PAX_ 10223668Speter/* 10323668Speter * -o options for BSD tar to not write directories to the archive 10423668Speter */ 10523668Speter#define TAR_NODIR "nodir" 10623668Speter#define TAR_OPTION "write_opt" 10723668Speter 10823668Speter/* 10923668Speter * default device names 11023668Speter */ 11123668Speter#define DEV_0 "/dev/rmt0" 11271579Sdeischen#define DEV_1 "/dev/rmt1" 11323768Sbde#define DEV_4 "/dev/rmt4" 114115047Stjr#define DEV_5 "/dev/rmt5" 11575860Sjoerg#define DEV_7 "/dev/rmt7" 11623668Speter#define DEV_8 "/dev/rmt8" 11723668Speter#endif /* _PAX_ */ 11823668Speter 11923668Speter/* 12023668Speter * Data Interchange Format - Extended tar header format - POSIX 1003.1-1990 12123668Speter */ 12223668Speter#define TPFSZ 155 12323668Speter#define TMAGIC "ustar" /* ustar and a null */ 12423668Speter#define TMAGLEN 6 12523668Speter#define TVERSION "00" /* 00 and no null */ 12623668Speter#define TVERSLEN 2 12723668Speter 12823668Spetertypedef struct { 12923668Speter char name[TNMSZ]; /* name of entry */ 13023668Speter char mode[8]; /* mode */ 13123668Speter char uid[8]; /* uid */ 13223668Speter char gid[8]; /* gid */ 13323668Speter char size[12]; /* size */ 13423668Speter char mtime[12]; /* modification time */ 13523668Speter char chksum[CHK_LEN]; /* checksum */ 13623668Speter char typeflag; /* type of file. */ 13723668Speter char linkname[TNMSZ]; /* linked to name */ 13823668Speter char magic[TMAGLEN]; /* magic cookie */ 13971579Sdeischen char version[TVERSLEN]; /* version */ 14023668Speter char uname[32]; /* ascii owner name */ 14123668Speter char gname[32]; /* ascii group name */ 14223668Speter char devmajor[8]; /* major device number */ 14323668Speter char devminor[8]; /* minor device number */ 14439327Simp char prefix[TPFSZ]; /* linked to name */ 14523768Sbde} HD_USTAR __aligned(1); 14623768Sbde