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