1 /*- 2 * Copyright (c) 1992 Keith Muller. 3 * Copyright (c) 1992 The Regents of the University of California. 4 * 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 1.1 (Berkeley) 12/13/92 12 */ 13 14 /* 15 * defines and data structures common to all tar formats 16 */ 17 #define NULLCNT 2 /* number of null blks in trailer */ 18 #define TNMSZ 100 /* size of name field */ 19 #define CHK_OFFSET 148 /* start of chksum field */ 20 #define CHK_LEN 8 /* length of checksum field */ 21 #define BLNKSUM 256L /* sum of checksum field using ' ' */ 22 23 /* 24 * Pad with a bit mask, much faster than doing a mod but only works on powers 25 * of 2. Macro below is for block of 512 bytes. 26 */ 27 #define TAR_PAD(x) ((512 - ((x) & 511)) & 511) 28 29 /* 30 * -o options for telling tar to not write directories to the archive 31 */ 32 #define TAR_NODIR "nodir" 33 #define TAR_OPTION "write_opt" 34 35 /* 36 * structure of an old tar header as appeared in BSD releases 37 */ 38 typedef struct { 39 char name[TNMSZ]; /* name of entry */ 40 char mode[8]; /* mode */ 41 char uid[8]; /* uid */ 42 char gid[8]; /* gid */ 43 char size[12]; /* size */ 44 char mtime[12]; /* modification time */ 45 char chksum[8]; /* checksum */ 46 char linkflag; /* norm, hard, or sym. */ 47 char linkname[TNMSZ]; /* linked to name */ 48 } HD_TAR; 49 50 /* 51 * Data Interchange Format - Extended tar Format - POSIX 1003.1-1990 52 */ 53 #define TPFSZ 155 54 #define TMAGIC "ustar" /* ustar and a null */ 55 #define TMAGLEN 6 56 #define TVERSION "00" /* 00 and no null */ 57 #define TVERSLEN 2 58 59 typedef struct { 60 char name[TNMSZ]; /* name of entry */ 61 char mode[8]; /* mode */ 62 char uid[8]; /* uid */ 63 char gid[8]; /* gid */ 64 char size[12]; /* size */ 65 char mtime[12]; /* modification time */ 66 char chksum[8]; /* checksum */ 67 char typeflag; /* type of file. */ 68 char linkname[TNMSZ]; /* linked to name */ 69 char magic[TMAGLEN]; /* magic cookie */ 70 char version[TVERSLEN]; /* version */ 71 char uname[32]; /* ascii owner name */ 72 char gname[32]; /* ascii group name */ 73 char devmajor[8]; /* major device number */ 74 char devminor[8]; /* minor device number */ 75 char prefix[TPFSZ]; /* linked to name */ 76 } HD_USTAR; 77 78 /* 79 * Values used in typeflag field 80 * (only REGTYPE, LNKTYPE and SYMTYPE are used in old tar headers) 81 */ 82 #define REGTYPE '0' /* Regular File */ 83 #define AREGTYPE '\0' /* Regular File */ 84 #define LNKTYPE '1' /* Link */ 85 #define SYMTYPE '2' /* Symlink */ 86 #define CHRTYPE '3' /* Character Special File */ 87 #define BLKTYPE '4' /* Block Special File */ 88 #define DIRTYPE '5' /* Directory */ 89 #define FIFOTYPE '6' /* FIFO */ 90 #define CONTTYPE '7' /* high perf file */ 91