tar.h 3.6 KB

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