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.1 (Berkeley) 05/31/93 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 #endif /* _PAX_ */ 85 86 /* 87 * Data Interchange Format - Extended tar header format - POSIX 1003.1-1990 88 */ 89 #define TPFSZ 155 90 #define TMAGIC "ustar" /* ustar and a null */ 91 #define TMAGLEN 6 92 #define TVERSION "00" /* 00 and no null */ 93 #define TVERSLEN 2 94 95 typedef struct { 96 char name[TNMSZ]; /* name of entry */ 97 char mode[8]; /* mode */ 98 char uid[8]; /* uid */ 99 char gid[8]; /* gid */ 100 char size[12]; /* size */ 101 char mtime[12]; /* modification time */ 102 char chksum[CHK_LEN]; /* checksum */ 103 char typeflag; /* type of file. */ 104 char linkname[TNMSZ]; /* linked to name */ 105 char magic[TMAGLEN]; /* magic cookie */ 106 char version[TVERSLEN]; /* version */ 107 char uname[32]; /* ascii owner name */ 108 char gname[32]; /* ascii group name */ 109 char devmajor[8]; /* major device number */ 110 char devminor[8]; /* minor device number */ 111 char prefix[TPFSZ]; /* linked to name */ 112 } HD_USTAR; 113