1 /*- 2 * Copyright (c) 1992 Keith Muller. 3 * Copyright (c) 1992, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * Keith Muller of the University of California, San Diego. 8 * 9 * %sccs.include.redist.c% 10 * 11 * @(#)tar.h 8.2 (Berkeley) 04/18/94 12 */ 13 14 /* 15 * defines and data structures common to all tar formats 16 */ 17 #define CHK_LEN 8 /* length of checksum field */ 18 #define TNMSZ 100 /* size of name field */ 19 #ifdef _PAX_ 20 #define NULLCNT 2 /* number of null blocks in trailer */ 21 #define CHK_OFFSET 148 /* start of chksum field */ 22 #define BLNKSUM 256L /* sum of checksum field using ' ' */ 23 #endif /* _PAX_ */ 24 25 /* 26 * Values used in typeflag field in all tar formats 27 * (only REGTYPE, LNKTYPE and SYMTYPE are used in old bsd tar headers) 28 */ 29 #define REGTYPE '0' /* Regular File */ 30 #define AREGTYPE '\0' /* Regular File */ 31 #define LNKTYPE '1' /* Link */ 32 #define SYMTYPE '2' /* Symlink */ 33 #define CHRTYPE '3' /* Character Special File */ 34 #define BLKTYPE '4' /* Block Special File */ 35 #define DIRTYPE '5' /* Directory */ 36 #define FIFOTYPE '6' /* FIFO */ 37 #define CONTTYPE '7' /* high perf file */ 38 39 /* 40 * Mode field encoding of the different file types - values in octal 41 */ 42 #define TSUID 04000 /* Set UID on execution */ 43 #define TSGID 02000 /* Set GID on execution */ 44 #define TSVTX 01000 /* Reserved */ 45 #define TUREAD 00400 /* Read by owner */ 46 #define TUWRITE 00200 /* Write by owner */ 47 #define TUEXEC 00100 /* Execute/Search by owner */ 48 #define TGREAD 00040 /* Read by group */ 49 #define TGWRITE 00020 /* Write by group */ 50 #define TGEXEC 00010 /* Execute/Search by group */ 51 #define TOREAD 00004 /* Read by other */ 52 #define TOWRITE 00002 /* Write by other */ 53 #define TOEXEC 00001 /* Execute/Search by other */ 54 55 #ifdef _PAX_ 56 /* 57 * Pad with a bit mask, much faster than doing a mod but only works on powers 58 * of 2. Macro below is for block of 512 bytes. 59 */ 60 #define TAR_PAD(x) ((512 - ((x) & 511)) & 511) 61 #endif /* _PAX_ */ 62 63 /* 64 * structure of an old tar header as it appeared in BSD releases 65 */ 66 typedef struct { 67 char name[TNMSZ]; /* name of entry */ 68 char mode[8]; /* mode */ 69 char uid[8]; /* uid */ 70 char gid[8]; /* gid */ 71 char size[12]; /* size */ 72 char mtime[12]; /* modification time */ 73 char chksum[CHK_LEN]; /* checksum */ 74 char linkflag; /* norm, hard, or sym. */ 75 char linkname[TNMSZ]; /* linked to name */ 76 } HD_TAR; 77 78 #ifdef _PAX_ 79 /* 80 * -o options for BSD tar to not write directories to the archive 81 */ 82 #define TAR_NODIR "nodir" 83 #define TAR_OPTION "write_opt" 84 85 /* 86 * default device names 87 */ 88 #define DEV_0 "/dev/rmt0" 89 #define DEV_1 "/dev/rmt1" 90 #define DEV_4 "/dev/rmt4" 91 #define DEV_5 "/dev/rmt5" 92 #define DEV_7 "/dev/rmt7" 93 #define DEV_8 "/dev/rmt8" 94 #endif /* _PAX_ */ 95 96 /* 97 * Data Interchange Format - Extended tar header format - POSIX 1003.1-1990 98 */ 99 #define TPFSZ 155 100 #define TMAGIC "ustar" /* ustar and a null */ 101 #define TMAGLEN 6 102 #define TVERSION "00" /* 00 and no null */ 103 #define TVERSLEN 2 104 105 typedef struct { 106 char name[TNMSZ]; /* name of entry */ 107 char mode[8]; /* mode */ 108 char uid[8]; /* uid */ 109 char gid[8]; /* gid */ 110 char size[12]; /* size */ 111 char mtime[12]; /* modification time */ 112 char chksum[CHK_LEN]; /* checksum */ 113 char typeflag; /* type of file. */ 114 char linkname[TNMSZ]; /* linked to name */ 115 char magic[TMAGLEN]; /* magic cookie */ 116 char version[TVERSLEN]; /* version */ 117 char uname[32]; /* ascii owner name */ 118 char gname[32]; /* ascii group name */ 119 char devmajor[8]; /* major device number */ 120 char devminor[8]; /* minor device number */ 121 char prefix[TPFSZ]; /* linked to name */ 122 } HD_USTAR; 123