1 /* Extended tar format from POSIX.1. 2 Copyright (C) 1992-2022 Free Software Foundation, Inc. 3 This file is part of the GNU C Library. 4 5 The GNU C Library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 The GNU C Library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with the GNU C Library; if not, see 17 <https://www.gnu.org/licenses/>. */ 18 19 #ifndef _TAR_H 20 #define _TAR_H 1 21 22 #include <features.h> 23 24 25 /* A tar archive consists of 512-byte blocks. 26 Each file in the archive has a header block followed by 0+ data blocks. 27 Two blocks of NUL bytes indicate the end of the archive. */ 28 29 /* The fields of header blocks: 30 All strings are stored as ISO 646 (approximately ASCII) strings. 31 32 Fields are numeric unless otherwise noted below; numbers are ISO 646 33 representations of octal numbers, with leading zeros as needed. 34 35 linkname is only valid when typeflag==LNKTYPE. It doesn't use prefix; 36 files that are links to pathnames >100 chars long can not be stored 37 in a tar archive. 38 39 If typeflag=={LNKTYPE,SYMTYPE,DIRTYPE} then size must be 0. 40 41 devmajor and devminor are only valid for typeflag=={BLKTYPE,CHRTYPE}. 42 43 chksum contains the sum of all 512 bytes in the header block, 44 treating each byte as an 8-bit unsigned value and treating the 45 8 bytes of chksum as blank characters. 46 47 uname and gname are used in preference to uid and gid, if those 48 names exist locally. 49 50 Field Name Byte Offset Length in Bytes Field Type 51 name 0 100 NUL-terminated if NUL fits 52 mode 100 8 53 uid 108 8 54 gid 116 8 55 size 124 12 56 mtime 136 12 57 chksum 148 8 58 typeflag 156 1 see below 59 linkname 157 100 NUL-terminated if NUL fits 60 magic 257 6 must be TMAGIC (NUL term.) 61 version 263 2 must be TVERSION 62 uname 265 32 NUL-terminated 63 gname 297 32 NUL-terminated 64 devmajor 329 8 65 devminor 337 8 66 prefix 345 155 NUL-terminated if NUL fits 67 68 If the first character of prefix is '\0', the file name is name; 69 otherwise, it is prefix/name. Files whose pathnames don't fit in that 70 length can not be stored in a tar archive. */ 71 72 /* The bits in mode: */ 73 #define TSUID 04000 74 #define TSGID 02000 75 #if defined __USE_XOPEN || !defined __USE_XOPEN2K 76 # define TSVTX 01000 77 #endif 78 #define TUREAD 00400 79 #define TUWRITE 00200 80 #define TUEXEC 00100 81 #define TGREAD 00040 82 #define TGWRITE 00020 83 #define TGEXEC 00010 84 #define TOREAD 00004 85 #define TOWRITE 00002 86 #define TOEXEC 00001 87 88 /* The values for typeflag: 89 Values 'A'-'Z' are reserved for custom implementations. 90 All other values are reserved for future POSIX.1 revisions. */ 91 92 #define REGTYPE '0' /* Regular file (preferred code). */ 93 #define AREGTYPE '\0' /* Regular file (alternate code). */ 94 #define LNKTYPE '1' /* Hard link. */ 95 #define SYMTYPE '2' /* Symbolic link (hard if not supported). */ 96 #define CHRTYPE '3' /* Character special. */ 97 #define BLKTYPE '4' /* Block special. */ 98 #define DIRTYPE '5' /* Directory. */ 99 #define FIFOTYPE '6' /* Named pipe. */ 100 #define CONTTYPE '7' /* Contiguous file */ 101 /* (regular file if not supported). */ 102 103 /* Contents of magic field and its length. */ 104 #define TMAGIC "ustar" 105 #define TMAGLEN 6 106 107 /* Contents of the version field and its length. */ 108 #define TVERSION "00" 109 #define TVERSLEN 2 110 111 #endif /* tar.h */ 112