tar.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /* Declarations for the tarfs.
  2. Copyright (C) 1995 The Free Software Foundation
  3. Written by: 1995 Jakub Jelinek
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; see the file COPYING. If not, write to
  14. the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  15. #if 0
  16. #include "testpad.h"
  17. #else
  18. #define NEEDPAD
  19. #endif
  20. #include <sys/types.h>
  21. /* major() and minor() macros (among other things) defined here for hpux */
  22. #ifdef hpux
  23. #include <sys/mknod.h>
  24. #endif
  25. /*
  26. * Header block on tape.
  27. *
  28. * I'm going to use traditional DP naming conventions here.
  29. * A "block" is a big chunk of stuff that we do I/O on.
  30. * A "record" is a piece of info that we care about.
  31. * Typically many "record"s fit into a "block".
  32. */
  33. #define RECORDSIZE 512
  34. #define NAMSIZ 100
  35. #define TUNMLEN 32
  36. #define TGNMLEN 32
  37. #define SPARSE_EXT_HDR 21
  38. #define SPARSE_IN_HDR 4
  39. struct sparse {
  40. char offset[12];
  41. char numbytes[12];
  42. };
  43. struct sp_array {
  44. int offset;
  45. int numbytes;
  46. };
  47. union record {
  48. char charptr[RECORDSIZE];
  49. struct header {
  50. char arch_name[NAMSIZ];
  51. char mode[8];
  52. char uid[8];
  53. char gid[8];
  54. char size[12];
  55. char mtime[12];
  56. char chksum[8];
  57. char linkflag;
  58. char arch_linkname[NAMSIZ];
  59. char magic[8];
  60. char uname[TUNMLEN];
  61. char gname[TGNMLEN];
  62. char devmajor[8];
  63. char devminor[8];
  64. /* these following fields were added by JF for gnu */
  65. /* and are NOT standard */
  66. char atime[12];
  67. char ctime[12];
  68. char offset[12];
  69. char longnames[4];
  70. #ifdef NEEDPAD
  71. char pad;
  72. #endif
  73. struct sparse sp[SPARSE_IN_HDR];
  74. char isextended;
  75. char realsize[12]; /* true size of the sparse file */
  76. /* char ending_blanks[12];*//* number of nulls at the
  77. end of the file, if any */
  78. } header;
  79. struct extended_header {
  80. struct sparse sp[21];
  81. char isextended;
  82. } ext_hdr;
  83. };
  84. /* The checksum field is filled with this while the checksum is computed. */
  85. #define CHKBLANKS " " /* 8 blanks, no null */
  86. /* The magic field is filled with this if uname and gname are valid. */
  87. #define TMAGIC "ustar " /* 7 chars and a null */
  88. /* The linkflag defines the type of file */
  89. #define LF_OLDNORMAL '\0' /* Normal disk file, Unix compat */
  90. #define LF_NORMAL '0' /* Normal disk file */
  91. #define LF_LINK '1' /* Link to previously dumped file */
  92. #define LF_SYMLINK '2' /* Symbolic link */
  93. #define LF_CHR '3' /* Character special file */
  94. #define LF_BLK '4' /* Block special file */
  95. #define LF_DIR '5' /* Directory */
  96. #define LF_FIFO '6' /* FIFO special file */
  97. #define LF_CONTIG '7' /* Contiguous file */
  98. /* Further link types may be defined later. */
  99. /* Note that the standards committee allows only capital A through
  100. capital Z for user-defined expansion. This means that defining something
  101. as, say '8' is a *bad* idea. */
  102. #define LF_DUMPDIR 'D' /* This is a dir entry that contains
  103. the names of files that were in
  104. the dir at the time the dump
  105. was made */
  106. #define LF_LONGLINK 'K' /* Identifies the NEXT file on the tape
  107. as having a long linkname */
  108. #define LF_LONGNAME 'L' /* Identifies the NEXT file on the tape
  109. as having a long name. */
  110. #define LF_MULTIVOL 'M' /* This is the continuation
  111. of a file that began on another
  112. volume */
  113. #define LF_NAMES 'N' /* For storing filenames that didn't
  114. fit in 100 characters */
  115. #define LF_SPARSE 'S' /* This is for sparse files */
  116. #define LF_VOLHDR 'V' /* This file is a tape/volume header */
  117. /* Ignore it on extraction */
  118. /*
  119. * Exit codes from the "tar" program
  120. */
  121. #define EX_SUCCESS 0 /* success! */
  122. #define EX_ARGSBAD 1 /* invalid args */
  123. #define EX_BADFILE 2 /* invalid filename */
  124. #define EX_BADARCH 3 /* bad archive */
  125. #define EX_SYSTEM 4 /* system gave unexpected error */
  126. #define EX_BADVOL 5 /* Special error code means
  127. Tape volume doesn't match the one
  128. specified on the command line */
  129. /*
  130. * We default to Unix Standard format rather than 4.2BSD tar format.
  131. * The code can actually produce all three:
  132. * f_standard ANSI standard
  133. * f_oldarch V7
  134. * neither 4.2BSD
  135. * but we don't bother, since 4.2BSD can read ANSI standard format anyway.
  136. * The only advantage to the "neither" option is that we can cmp our
  137. * output to the output of 4.2BSD tar, for debugging.
  138. */
  139. #define f_standard (!f_oldarch)