11556Srgrimes/*- 21556Srgrimes * Copyright (c) 1992 Keith Muller. 31556Srgrimes * Copyright (c) 1992, 1993 41556Srgrimes * The Regents of the University of California. All rights reserved. 51556Srgrimes * 61556Srgrimes * This code is derived from software contributed to Berkeley by 71556Srgrimes * Keith Muller of the University of California, San Diego. 81556Srgrimes * 91556Srgrimes * Redistribution and use in source and binary forms, with or without 101556Srgrimes * modification, are permitted provided that the following conditions 111556Srgrimes * are met: 121556Srgrimes * 1. Redistributions of source code must retain the above copyright 131556Srgrimes * notice, this list of conditions and the following disclaimer. 141556Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 151556Srgrimes * notice, this list of conditions and the following disclaimer in the 161556Srgrimes * documentation and/or other materials provided with the distribution. 171556Srgrimes * 4. Neither the name of the University nor the names of its contributors 181556Srgrimes * may be used to endorse or promote products derived from this software 191556Srgrimes * without specific prior written permission. 201556Srgrimes * 211556Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 221556Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 231556Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 241556Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 251556Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 261556Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 271556Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 281556Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 291556Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 301556Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 311556Srgrimes * SUCH DAMAGE. 321556Srgrimes * 331556Srgrimes * @(#)tar.h 8.2 (Berkeley) 4/18/94 3450471Speter * $FreeBSD$ 351556Srgrimes */ 361556Srgrimes 371556Srgrimes/* 381556Srgrimes * defines and data structures common to all tar formats 391556Srgrimes */ 401556Srgrimes#define CHK_LEN 8 /* length of checksum field */ 411556Srgrimes#define TNMSZ 100 /* size of name field */ 421556Srgrimes#ifdef _PAX_ 431556Srgrimes#define NULLCNT 2 /* number of null blocks in trailer */ 4446684Skris#define CHK_OFFSET 148 /* start of checksum field */ 451556Srgrimes#define BLNKSUM 256L /* sum of checksum field using ' ' */ 461556Srgrimes#endif /* _PAX_ */ 471556Srgrimes 481556Srgrimes/* 491556Srgrimes * Values used in typeflag field in all tar formats 5046684Skris * (only REGTYPE, LNKTYPE and SYMTYPE are used in old BSD tar headers) 511556Srgrimes */ 521556Srgrimes#define REGTYPE '0' /* Regular File */ 531556Srgrimes#define AREGTYPE '\0' /* Regular File */ 541556Srgrimes#define LNKTYPE '1' /* Link */ 551556Srgrimes#define SYMTYPE '2' /* Symlink */ 561556Srgrimes#define CHRTYPE '3' /* Character Special File */ 571556Srgrimes#define BLKTYPE '4' /* Block Special File */ 581556Srgrimes#define DIRTYPE '5' /* Directory */ 591556Srgrimes#define FIFOTYPE '6' /* FIFO */ 601556Srgrimes#define CONTTYPE '7' /* high perf file */ 611556Srgrimes 621556Srgrimes/* 631556Srgrimes * Mode field encoding of the different file types - values in octal 641556Srgrimes */ 651556Srgrimes#define TSUID 04000 /* Set UID on execution */ 661556Srgrimes#define TSGID 02000 /* Set GID on execution */ 671556Srgrimes#define TSVTX 01000 /* Reserved */ 681556Srgrimes#define TUREAD 00400 /* Read by owner */ 691556Srgrimes#define TUWRITE 00200 /* Write by owner */ 701556Srgrimes#define TUEXEC 00100 /* Execute/Search by owner */ 711556Srgrimes#define TGREAD 00040 /* Read by group */ 721556Srgrimes#define TGWRITE 00020 /* Write by group */ 731556Srgrimes#define TGEXEC 00010 /* Execute/Search by group */ 741556Srgrimes#define TOREAD 00004 /* Read by other */ 751556Srgrimes#define TOWRITE 00002 /* Write by other */ 761556Srgrimes#define TOEXEC 00001 /* Execute/Search by other */ 771556Srgrimes 781556Srgrimes#ifdef _PAX_ 791556Srgrimes/* 801556Srgrimes * Pad with a bit mask, much faster than doing a mod but only works on powers 811556Srgrimes * of 2. Macro below is for block of 512 bytes. 821556Srgrimes */ 831556Srgrimes#define TAR_PAD(x) ((512 - ((x) & 511)) & 511) 841556Srgrimes#endif /* _PAX_ */ 851556Srgrimes 861556Srgrimes/* 871556Srgrimes * structure of an old tar header as it appeared in BSD releases 881556Srgrimes */ 891556Srgrimestypedef struct { 901556Srgrimes char name[TNMSZ]; /* name of entry */ 911556Srgrimes char mode[8]; /* mode */ 921556Srgrimes char uid[8]; /* uid */ 931556Srgrimes char gid[8]; /* gid */ 941556Srgrimes char size[12]; /* size */ 951556Srgrimes char mtime[12]; /* modification time */ 961556Srgrimes char chksum[CHK_LEN]; /* checksum */ 971556Srgrimes char linkflag; /* norm, hard, or sym. */ 981556Srgrimes char linkname[TNMSZ]; /* linked to name */ 99203613Simp} HD_TAR __aligned(1); 1001556Srgrimes 1011556Srgrimes#ifdef _PAX_ 1021556Srgrimes/* 1031556Srgrimes * -o options for BSD tar to not write directories to the archive 1041556Srgrimes */ 1051556Srgrimes#define TAR_NODIR "nodir" 1061556Srgrimes#define TAR_OPTION "write_opt" 1071556Srgrimes 1081556Srgrimes/* 1091556Srgrimes * default device names 1101556Srgrimes */ 1111556Srgrimes#define DEV_0 "/dev/rmt0" 1121556Srgrimes#define DEV_1 "/dev/rmt1" 1131556Srgrimes#define DEV_4 "/dev/rmt4" 1141556Srgrimes#define DEV_5 "/dev/rmt5" 1151556Srgrimes#define DEV_7 "/dev/rmt7" 1161556Srgrimes#define DEV_8 "/dev/rmt8" 1171556Srgrimes#endif /* _PAX_ */ 1181556Srgrimes 1191556Srgrimes/* 1201556Srgrimes * Data Interchange Format - Extended tar header format - POSIX 1003.1-1990 1211556Srgrimes */ 1221556Srgrimes#define TPFSZ 155 1231556Srgrimes#define TMAGIC "ustar" /* ustar and a null */ 1241556Srgrimes#define TMAGLEN 6 1251556Srgrimes#define TVERSION "00" /* 00 and no null */ 1261556Srgrimes#define TVERSLEN 2 1271556Srgrimes 1281556Srgrimestypedef struct { 1291556Srgrimes char name[TNMSZ]; /* name of entry */ 1301556Srgrimes char mode[8]; /* mode */ 1311556Srgrimes char uid[8]; /* uid */ 1321556Srgrimes char gid[8]; /* gid */ 1331556Srgrimes char size[12]; /* size */ 1341556Srgrimes char mtime[12]; /* modification time */ 1351556Srgrimes char chksum[CHK_LEN]; /* checksum */ 1361556Srgrimes char typeflag; /* type of file. */ 1371556Srgrimes char linkname[TNMSZ]; /* linked to name */ 1381556Srgrimes char magic[TMAGLEN]; /* magic cookie */ 1391556Srgrimes char version[TVERSLEN]; /* version */ 1401556Srgrimes char uname[32]; /* ascii owner name */ 1411556Srgrimes char gname[32]; /* ascii group name */ 1421556Srgrimes char devmajor[8]; /* major device number */ 1431556Srgrimes char devminor[8]; /* minor device number */ 1441556Srgrimes char prefix[TPFSZ]; /* linked to name */ 145203613Simp} HD_USTAR __aligned(1); 146