Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

tar.h

Go to the documentation of this file.
00001 /*
00002  * Header file for public domain tar (tape archive) program.
00003  *
00004  * @(#)tar.h 1.20 86/10/29      Public Domain.
00005  *
00006  * Created 25 August 1985 by John Gilmore, ihnp4!hoptoad!gnu.
00007  *
00008  * Id: tar.h,v 1.5 1999/01/13 15:44:10 christos Exp  # checkin only
00009  */
00010 
00011 #ifndef __tar_h__
00012 #define __tar_h__
00013 
00014 /*
00015  * Header block on tape.
00016  *
00017  * I'm going to use traditional DP naming conventions here.
00018  * A "block" is a big chunk of stuff that we do I/O on.
00019  * A "record" is a piece of info that we care about.
00020  * Typically many "record"s fit into a "block".
00021  */
00022 #define RECORDSIZE      512
00023 #define NAMSIZ  100
00024 #define TUNMLEN 32
00025 #define TGNMLEN 32
00026 
00027 /*@-fielduse@*/
00028 union record {
00029         char            charptr[RECORDSIZE];
00030         struct header {
00031                 char    name[NAMSIZ];
00032                 char    mode[8];
00033                 char    uid[8];
00034                 char    gid[8];
00035                 char    size[12];
00036                 char    mtime[12];
00037                 char    chksum[8];
00038                 char    linkflag;
00039                 char    linkname[NAMSIZ];
00040                 char    magic[8];
00041                 char    uname[TUNMLEN];
00042                 char    gname[TGNMLEN];
00043                 char    devmajor[8];
00044                 char    devminor[8];
00045         } header;
00046 };
00047 /*@=fielduse@*/
00048 
00049 /* The checksum field is filled with this while the checksum is computed. */
00050 #define CHKBLANKS       "        "      /* 8 blanks, no null */
00051 
00052 /* The magic field is filled with this if uname and gname are valid. */
00053 #define TARMAGIC                "ustar  "       /* 7 chars and a null */
00054 
00055 #if 0
00056 /* The linkflag defines the type of file */
00057 #define LF_OLDNORMAL    '\0'            /* Normal disk file, Unix compat */
00058 #define LF_NORMAL       '0'             /* Normal disk file */
00059 #define LF_LINK         '1'             /* Link to previously dumped file */
00060 #define LF_SYMLINK      '2'             /* Symbolic link */
00061 #define LF_CHR          '3'             /* Character special file */
00062 #define LF_BLK          '4'             /* Block special file */
00063 #define LF_DIR          '5'             /* Directory */
00064 #define LF_FIFO         '6'             /* FIFO special file */
00065 #define LF_CONTIG       '7'             /* Contiguous file */
00066 /* Further link types may be defined later. */
00067 
00068 /*
00069  * Exit codes from the "tar" program
00070  */
00071 #define EX_SUCCESS      0               /* success! */
00072 #define EX_ARGSBAD      1               /* invalid args */
00073 #define EX_BADFILE      2               /* invalid filename */
00074 #define EX_BADARCH      3               /* bad archive */
00075 #define EX_SYSTEM       4               /* system gave unexpected error */
00076 
00077 
00078 /*
00079  * Global variables
00080  */
00081 extern union record     *ar_block;      /* Start of block of archive */
00082 extern union record     *ar_record;     /* Current record of archive */
00083 extern union record     *ar_last;       /* Last+1 record of archive block */
00084 extern char             ar_reading;     /* 0 writing, !0 reading archive */
00085 extern int              blocking;       /* Size of each block, in records */
00086 extern int              blocksize;      /* Size of each block, in bytes */
00087 extern char             *ar_file;       /* File containing archive */
00088 extern char             *name_file;     /* File containing names to work on */
00089 extern char             *tar;           /* Name of this program */
00090 
00091 /*
00092  * Flags from the command line
00093  */
00094 extern char     f_reblock;              /* -B */
00095 extern char     f_create;               /* -c */
00096 extern char     f_debug;                /* -d */
00097 extern char     f_sayblock;             /* -D */
00098 extern char     f_follow_links;         /* -h */
00099 extern char     f_ignorez;              /* -i */
00100 extern char     f_keep;                 /* -k */
00101 extern char     f_modified;             /* -m */
00102 extern char     f_oldarch;              /* -o */
00103 extern char     f_use_protection;       /* -p */
00104 extern char     f_sorted_names;         /* -s */
00105 extern char     f_list;                 /* -t */
00106 extern char     f_namefile;             /* -T */
00107 extern char     f_verbose;              /* -v */
00108 extern char     f_extract;              /* -x */
00109 extern char     f_compress;             /* -z */
00110 
00111 /*
00112  * We now default to Unix Standard format rather than 4.2BSD tar format.
00113  * The code can actually produce all three:
00114  *      f_standard      ANSI standard
00115  *      f_oldarch       V7
00116  *      neither         4.2BSD
00117  * but we don't bother, since 4.2BSD can read ANSI standard format anyway.
00118  * The only advantage to the "neither" option is that we can cmp(1) our
00119  * output to the output of 4.2BSD tar, for debugging.
00120  */
00121 #define         f_standard              (!f_oldarch)
00122 
00123 /*
00124  * Structure for keeping track of filenames and lists thereof.
00125  */
00126 struct name {
00127         struct name     *next;
00128         short           length;
00129         char            found;
00130         char            name[NAMSIZ+1];
00131 };
00132 
00133 extern struct name      *namelist;      /* Points to first name in list */
00134 extern struct name      *namelast;      /* Points to last name in list */
00135 
00136 extern int              archive;        /* File descriptor for archive file */
00137 extern int              errors;         /* # of files in error */
00138 
00139 /*
00140  *
00141  * Due to the next struct declaration, each routine that includes
00142  * "tar.h" must also include <sys/types.h>.  I tried to make it automatic,
00143  * but System V has no defines in <sys/types.h>, so there is no way of
00144  * knowing when it has been included.  In addition, it cannot be included
00145  * twice, but must be included exactly once.  Argghh!
00146  *
00147  * Thanks, typedef.  Thanks, USG.
00148  */
00149 struct link {
00150         struct link     *next;
00151         dev_t           dev;
00152         ino_t           ino;
00153         short           linkcount;
00154         char            name[NAMSIZ+1];
00155 };
00156 
00157 extern struct link      *linklist;      /* Points to first link in list */
00158 
00159 /*
00160  * Error recovery stuff
00161  */
00162 extern char             read_error_flag;
00163 #endif
00164 
00165 #endif  /* __tar_h__ */

Generated on Thu Aug 14 06:06:27 2008 for rpm by  doxygen 1.3.9.1