| 1 | /* $OpenBSD: tar.h,v 1.9 2014/01/08 06:43:34 deraadt Exp $ */ |
| 2 | /* $NetBSD: tar.h,v 1.3 1995/03/21 09:07:51 cgd Exp $ */ |
| 3 | |
| 4 | /*- |
| 5 | * Copyright (c) 1992 Keith Muller. |
| 6 | * Copyright (c) 1992, 1993 |
| 7 | * The Regents of the University of California. All rights reserved. |
| 8 | * |
| 9 | * This code is derived from software contributed to Berkeley by |
| 10 | * Keith Muller of the University of California, San Diego. |
| 11 | * |
| 12 | * Redistribution and use in source and binary forms, with or without |
| 13 | * modification, are permitted provided that the following conditions |
| 14 | * are met: |
| 15 | * 1. Redistributions of source code must retain the above copyright |
| 16 | * notice, this list of conditions and the following disclaimer. |
| 17 | * 2. Redistributions in binary form must reproduce the above copyright |
| 18 | * notice, this list of conditions and the following disclaimer in the |
| 19 | * documentation and/or other materials provided with the distribution. |
| 20 | * 3. Neither the name of the University nor the names of its contributors |
| 21 | * may be used to endorse or promote products derived from this software |
| 22 | * without specific prior written permission. |
| 23 | * |
| 24 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
| 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 34 | * SUCH DAMAGE. |
| 35 | * |
| 36 | * @(#)tar.h 8.2 (Berkeley) 4/18/94 |
| 37 | */ |
| 38 | |
| 39 | #ifdef EXTERN |
| 40 | __IDSTRING(rcsid_tar_h, "$MirOS: src/bin/pax/tar.h,v 1.4 2018/12/12 18:08:48 tg Exp $"); |
| 41 | #endif |
| 42 | |
| 43 | /* |
| 44 | * defines and data structures common to all tar formats |
| 45 | */ |
| 46 | #define CHK_LEN 8 /* length of checksum field */ |
| 47 | #define TNMSZ 100 /* size of name field */ |
| 48 | #ifdef _PAX_ |
| 49 | #define NULLCNT 2 /* number of null blocks in trailer */ |
| 50 | #define CHK_OFFSET 148 /* start of chksum field */ |
| 51 | #define BLNKSUM 256L /* sum of checksum field using ' ' */ |
| 52 | #endif /* _PAX_ */ |
| 53 | |
| 54 | /* |
| 55 | * Values used in typeflag field in all tar formats |
| 56 | * (only REGTYPE, LNKTYPE and SYMTYPE are used in old bsd tar headers) |
| 57 | */ |
| 58 | #define REGTYPE '0' /* Regular File */ |
| 59 | #define AREGTYPE '\0' /* Regular File */ |
| 60 | #define LNKTYPE '1' /* Link */ |
| 61 | #define SYMTYPE '2' /* Symlink */ |
| 62 | #define CHRTYPE '3' /* Character Special File */ |
| 63 | #define BLKTYPE '4' /* Block Special File */ |
| 64 | #define DIRTYPE '5' /* Directory */ |
| 65 | #define FIFOTYPE '6' /* FIFO */ |
| 66 | #define CONTTYPE '7' /* high perf file */ |
| 67 | |
| 68 | /* |
| 69 | * Extended header - POSIX.1-2001 |
| 70 | */ |
| 71 | #define XHDRTYPE 'x' /* Extended header */ |
| 72 | #define GHDRTYPE 'g' /* Global header*/ |
| 73 | |
| 74 | /* |
| 75 | * GNU tar compatibility; |
| 76 | */ |
| 77 | #define LONGLINKTYPE 'K' /* Long Symlink */ |
| 78 | #define LONGNAMETYPE 'L' /* Long File */ |
| 79 | |
| 80 | /* |
| 81 | * Mode field encoding of the different file types - values in octal |
| 82 | */ |
| 83 | #define TSUID 04000 /* Set UID on execution */ |
| 84 | #define TSGID 02000 /* Set GID on execution */ |
| 85 | #define TSVTX 01000 /* Reserved */ |
| 86 | #define TUREAD 00400 /* Read by owner */ |
| 87 | #define TUWRITE 00200 /* Write by owner */ |
| 88 | #define TUEXEC 00100 /* Execute/Search by owner */ |
| 89 | #define TGREAD 00040 /* Read by group */ |
| 90 | #define TGWRITE 00020 /* Write by group */ |
| 91 | #define TGEXEC 00010 /* Execute/Search by group */ |
| 92 | #define TOREAD 00004 /* Read by other */ |
| 93 | #define TOWRITE 00002 /* Write by other */ |
| 94 | #define TOEXEC 00001 /* Execute/Search by other */ |
| 95 | |
| 96 | #ifdef _PAX_ |
| 97 | /* |
| 98 | * Pad with a bit mask, much faster than doing a mod but only works on powers |
| 99 | * of 2. Macro below is for block of 512 bytes. |
| 100 | */ |
| 101 | #define TAR_PAD(x) ((512 - ((x) & 511)) & 511) |
| 102 | #endif /* _PAX_ */ |
| 103 | |
| 104 | /* |
| 105 | * structure of an old tar header as it appeared in BSD releases |
| 106 | */ |
| 107 | typedef struct { |
| 108 | char name[TNMSZ]; /* name of entry */ |
| 109 | char mode[8]; /* mode */ |
| 110 | char uid[8]; /* uid */ |
| 111 | char gid[8]; /* gid */ |
| 112 | char size[12]; /* size */ |
| 113 | char mtime[12]; /* modification time */ |
| 114 | char chksum[CHK_LEN]; /* checksum */ |
| 115 | char linkflag; /* norm, hard, or sym. */ |
| 116 | char linkname[TNMSZ]; /* linked to name */ |
| 117 | } HD_TAR; |
| 118 | |
| 119 | #ifdef _PAX_ |
| 120 | /* |
| 121 | * -o options for BSD tar to not write directories to the archive |
| 122 | */ |
| 123 | #define TAR_NODIR "nodir" |
| 124 | #define TAR_OPTION "write_opt" |
| 125 | |
| 126 | /* |
| 127 | * default device names |
| 128 | */ |
| 129 | #define DEV_0 "/dev/rst0" |
| 130 | #define DEV_1 "/dev/rst1" |
| 131 | #define DEV_4 "/dev/rst4" |
| 132 | #define DEV_5 "/dev/rst5" |
| 133 | #define DEV_7 "/dev/rst7" |
| 134 | #define DEV_8 "/dev/rst8" |
| 135 | #endif /* _PAX_ */ |
| 136 | |
| 137 | /* |
| 138 | * Data Interchange Format - Extended tar header format - POSIX 1003.1-1990 |
| 139 | */ |
| 140 | #define TPFSZ 155 |
| 141 | #define TMAGIC "ustar" /* ustar and a null */ |
| 142 | #define TMAGLEN 6 |
| 143 | #define TVERSION "00" /* 00 and no null */ |
| 144 | #define TVERSLEN 2 |
| 145 | |
| 146 | typedef struct { |
| 147 | char name[TNMSZ]; /* name of entry */ |
| 148 | char mode[8]; /* mode */ |
| 149 | char uid[8]; /* uid */ |
| 150 | char gid[8]; /* gid */ |
| 151 | char size[12]; /* size */ |
| 152 | char mtime[12]; /* modification time */ |
| 153 | char chksum[CHK_LEN]; /* checksum */ |
| 154 | char typeflag; /* type of file. */ |
| 155 | char linkname[TNMSZ]; /* linked to name */ |
| 156 | char magic[TMAGLEN]; /* magic cookie */ |
| 157 | char version[TVERSLEN]; /* version */ |
| 158 | char uname[32]; /* ascii owner name */ |
| 159 | char gname[32]; /* ascii group name */ |
| 160 | char devmajor[8]; /* major device number */ |
| 161 | char devminor[8]; /* minor device number */ |
| 162 | char prefix[TPFSZ]; /* linked to name */ |
| 163 | } HD_USTAR; |