14b88c807SRodney W. Grimes /*- 2*8a16b7a1SPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause 3*8a16b7a1SPedro F. Giffuni * 44b88c807SRodney W. Grimes * Copyright (c) 1992 Keith Muller. 54b88c807SRodney W. Grimes * Copyright (c) 1992, 1993 64b88c807SRodney W. Grimes * The Regents of the University of California. All rights reserved. 74b88c807SRodney W. Grimes * 84b88c807SRodney W. Grimes * This code is derived from software contributed to Berkeley by 94b88c807SRodney W. Grimes * Keith Muller of the University of California, San Diego. 104b88c807SRodney W. Grimes * 114b88c807SRodney W. Grimes * Redistribution and use in source and binary forms, with or without 124b88c807SRodney W. Grimes * modification, are permitted provided that the following conditions 134b88c807SRodney W. Grimes * are met: 144b88c807SRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 154b88c807SRodney W. Grimes * notice, this list of conditions and the following disclaimer. 164b88c807SRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 174b88c807SRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 184b88c807SRodney W. Grimes * documentation and/or other materials provided with the distribution. 19fbbd9655SWarner Losh * 3. Neither the name of the University nor the names of its contributors 204b88c807SRodney W. Grimes * may be used to endorse or promote products derived from this software 214b88c807SRodney W. Grimes * without specific prior written permission. 224b88c807SRodney W. Grimes * 234b88c807SRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 244b88c807SRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 254b88c807SRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 264b88c807SRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 274b88c807SRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 284b88c807SRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 294b88c807SRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 304b88c807SRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 314b88c807SRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 324b88c807SRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 334b88c807SRodney W. Grimes * SUCH DAMAGE. 344b88c807SRodney W. Grimes */ 354b88c807SRodney W. Grimes 364b88c807SRodney W. Grimes /* 374b88c807SRodney W. Grimes * defines and data structures common to all tar formats 384b88c807SRodney W. Grimes */ 394b88c807SRodney W. Grimes #define CHK_LEN 8 /* length of checksum field */ 404b88c807SRodney W. Grimes #define TNMSZ 100 /* size of name field */ 414b88c807SRodney W. Grimes #ifdef _PAX_ 424b88c807SRodney W. Grimes #define NULLCNT 2 /* number of null blocks in trailer */ 4346be34b9SKris Kennaway #define CHK_OFFSET 148 /* start of checksum field */ 444b88c807SRodney W. Grimes #define BLNKSUM 256L /* sum of checksum field using ' ' */ 454b88c807SRodney W. Grimes #endif /* _PAX_ */ 464b88c807SRodney W. Grimes 474b88c807SRodney W. Grimes /* 484b88c807SRodney W. Grimes * Values used in typeflag field in all tar formats 4946be34b9SKris Kennaway * (only REGTYPE, LNKTYPE and SYMTYPE are used in old BSD tar headers) 504b88c807SRodney W. Grimes */ 514b88c807SRodney W. Grimes #define REGTYPE '0' /* Regular File */ 524b88c807SRodney W. Grimes #define AREGTYPE '\0' /* Regular File */ 534b88c807SRodney W. Grimes #define LNKTYPE '1' /* Link */ 544b88c807SRodney W. Grimes #define SYMTYPE '2' /* Symlink */ 554b88c807SRodney W. Grimes #define CHRTYPE '3' /* Character Special File */ 564b88c807SRodney W. Grimes #define BLKTYPE '4' /* Block Special File */ 574b88c807SRodney W. Grimes #define DIRTYPE '5' /* Directory */ 584b88c807SRodney W. Grimes #define FIFOTYPE '6' /* FIFO */ 594b88c807SRodney W. Grimes #define CONTTYPE '7' /* high perf file */ 604b88c807SRodney W. Grimes 614b88c807SRodney W. Grimes /* 624b88c807SRodney W. Grimes * Mode field encoding of the different file types - values in octal 634b88c807SRodney W. Grimes */ 644b88c807SRodney W. Grimes #define TSUID 04000 /* Set UID on execution */ 654b88c807SRodney W. Grimes #define TSGID 02000 /* Set GID on execution */ 664b88c807SRodney W. Grimes #define TSVTX 01000 /* Reserved */ 674b88c807SRodney W. Grimes #define TUREAD 00400 /* Read by owner */ 684b88c807SRodney W. Grimes #define TUWRITE 00200 /* Write by owner */ 694b88c807SRodney W. Grimes #define TUEXEC 00100 /* Execute/Search by owner */ 704b88c807SRodney W. Grimes #define TGREAD 00040 /* Read by group */ 714b88c807SRodney W. Grimes #define TGWRITE 00020 /* Write by group */ 724b88c807SRodney W. Grimes #define TGEXEC 00010 /* Execute/Search by group */ 734b88c807SRodney W. Grimes #define TOREAD 00004 /* Read by other */ 744b88c807SRodney W. Grimes #define TOWRITE 00002 /* Write by other */ 754b88c807SRodney W. Grimes #define TOEXEC 00001 /* Execute/Search by other */ 764b88c807SRodney W. Grimes 774b88c807SRodney W. Grimes #ifdef _PAX_ 784b88c807SRodney W. Grimes /* 794b88c807SRodney W. Grimes * Pad with a bit mask, much faster than doing a mod but only works on powers 804b88c807SRodney W. Grimes * of 2. Macro below is for block of 512 bytes. 814b88c807SRodney W. Grimes */ 824b88c807SRodney W. Grimes #define TAR_PAD(x) ((512 - ((x) & 511)) & 511) 834b88c807SRodney W. Grimes #endif /* _PAX_ */ 844b88c807SRodney W. Grimes 854b88c807SRodney W. Grimes /* 864b88c807SRodney W. Grimes * structure of an old tar header as it appeared in BSD releases 874b88c807SRodney W. Grimes */ 884b88c807SRodney W. Grimes typedef struct { 894b88c807SRodney W. Grimes char name[TNMSZ]; /* name of entry */ 904b88c807SRodney W. Grimes char mode[8]; /* mode */ 914b88c807SRodney W. Grimes char uid[8]; /* uid */ 924b88c807SRodney W. Grimes char gid[8]; /* gid */ 934b88c807SRodney W. Grimes char size[12]; /* size */ 944b88c807SRodney W. Grimes char mtime[12]; /* modification time */ 954b88c807SRodney W. Grimes char chksum[CHK_LEN]; /* checksum */ 964b88c807SRodney W. Grimes char linkflag; /* norm, hard, or sym. */ 974b88c807SRodney W. Grimes char linkname[TNMSZ]; /* linked to name */ 98ff52ef95SWarner Losh } HD_TAR __aligned(1); 994b88c807SRodney W. Grimes 1004b88c807SRodney W. Grimes #ifdef _PAX_ 1014b88c807SRodney W. Grimes /* 1024b88c807SRodney W. Grimes * -o options for BSD tar to not write directories to the archive 1034b88c807SRodney W. Grimes */ 1044b88c807SRodney W. Grimes #define TAR_NODIR "nodir" 1054b88c807SRodney W. Grimes #define TAR_OPTION "write_opt" 1064b88c807SRodney W. Grimes 1074b88c807SRodney W. Grimes /* 1084b88c807SRodney W. Grimes * default device names 1094b88c807SRodney W. Grimes */ 1104b88c807SRodney W. Grimes #define DEV_0 "/dev/rmt0" 1114b88c807SRodney W. Grimes #define DEV_1 "/dev/rmt1" 1124b88c807SRodney W. Grimes #define DEV_4 "/dev/rmt4" 1134b88c807SRodney W. Grimes #define DEV_5 "/dev/rmt5" 1144b88c807SRodney W. Grimes #define DEV_7 "/dev/rmt7" 1154b88c807SRodney W. Grimes #define DEV_8 "/dev/rmt8" 1164b88c807SRodney W. Grimes #endif /* _PAX_ */ 1174b88c807SRodney W. Grimes 1184b88c807SRodney W. Grimes /* 1194b88c807SRodney W. Grimes * Data Interchange Format - Extended tar header format - POSIX 1003.1-1990 1204b88c807SRodney W. Grimes */ 1214b88c807SRodney W. Grimes #define TPFSZ 155 1224b88c807SRodney W. Grimes #define TMAGIC "ustar" /* ustar and a null */ 1234b88c807SRodney W. Grimes #define TMAGLEN 6 1244b88c807SRodney W. Grimes #define TVERSION "00" /* 00 and no null */ 1254b88c807SRodney W. Grimes #define TVERSLEN 2 1264b88c807SRodney W. Grimes 1274b88c807SRodney W. Grimes typedef struct { 1284b88c807SRodney W. Grimes char name[TNMSZ]; /* name of entry */ 1294b88c807SRodney W. Grimes char mode[8]; /* mode */ 1304b88c807SRodney W. Grimes char uid[8]; /* uid */ 1314b88c807SRodney W. Grimes char gid[8]; /* gid */ 1324b88c807SRodney W. Grimes char size[12]; /* size */ 1334b88c807SRodney W. Grimes char mtime[12]; /* modification time */ 1344b88c807SRodney W. Grimes char chksum[CHK_LEN]; /* checksum */ 1354b88c807SRodney W. Grimes char typeflag; /* type of file. */ 1364b88c807SRodney W. Grimes char linkname[TNMSZ]; /* linked to name */ 1374b88c807SRodney W. Grimes char magic[TMAGLEN]; /* magic cookie */ 1384b88c807SRodney W. Grimes char version[TVERSLEN]; /* version */ 1394b88c807SRodney W. Grimes char uname[32]; /* ascii owner name */ 1404b88c807SRodney W. Grimes char gname[32]; /* ascii group name */ 1414b88c807SRodney W. Grimes char devmajor[8]; /* major device number */ 1424b88c807SRodney W. Grimes char devminor[8]; /* minor device number */ 1434b88c807SRodney W. Grimes char prefix[TPFSZ]; /* linked to name */ 144ff52ef95SWarner Losh } HD_USTAR __aligned(1); 145