tar.h 3.7 KB

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