file/src/tar.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Ian F. Darwin 1986-1995.
00003  * Software written by Ian F. Darwin and others;
00004  * maintained 1995-present by Christos Zoulas and others.
00005  * 
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  * 1. Redistributions of source code must retain the above copyright
00010  *    notice immediately at the beginning of the file, without modification,
00011  *    this list of conditions, and the following disclaimer.
00012  * 2. Redistributions in binary form must reproduce the above copyright
00013  *    notice, this list of conditions and the following disclaimer in the
00014  *    documentation and/or other materials provided with the distribution.
00015  *  
00016  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
00017  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00018  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00019  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
00020  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00021  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00022  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00023  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00024  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00025  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00026  * SUCH DAMAGE.
00027  */
00028 /*
00029  * Header file for public domain tar (tape archive) program.
00030  *
00031  * @(#)tar.h 1.20 86/10/29      Public Domain.
00032  *
00033  * Created 25 August 1985 by John Gilmore, ihnp4!hoptoad!gnu.
00034  *
00035  * $Id: tar.h,v 1.8 2004/09/11 19:15:58 christos Exp $ # checkin only
00036  */
00037 
00038 /*
00039  * Kludge for handling systems that cannot cope with multiple
00040  * external definitions of a variable.  In ONE routine (tar.c),
00041  * we #define TAR_EXTERN to null; here, we set it to "extern" if
00042  * it is not already set.
00043  */
00044 #ifndef TAR_EXTERN
00045 #define TAR_EXTERN extern
00046 #endif
00047 
00048 /*
00049  * Header block on tape.
00050  *
00051  * I'm going to use traditional DP naming conventions here.
00052  * A "block" is a big chunk of stuff that we do I/O on.
00053  * A "record" is a piece of info that we care about.
00054  * Typically many "record"s fit into a "block".
00055  */
00056 #define RECORDSIZE      512
00057 #define NAMSIZ  100
00058 #define TUNMLEN 32
00059 #define TGNMLEN 32
00060 
00061 union record {
00062         char            charptr[RECORDSIZE];
00063         struct header {
00064                 char    name[NAMSIZ];
00065                 char    mode[8];
00066                 char    uid[8];
00067                 char    gid[8];
00068                 char    size[12];
00069                 char    mtime[12];
00070                 char    chksum[8];
00071                 char    linkflag;
00072                 char    linkname[NAMSIZ];
00073                 char    magic[8];
00074                 char    uname[TUNMLEN];
00075                 char    gname[TGNMLEN];
00076                 char    devmajor[8];
00077                 char    devminor[8];
00078         } header;
00079 };
00080 
00081 /* The checksum field is filled with this while the checksum is computed. */
00082 #define CHKBLANKS       "        "      /* 8 blanks, no null */
00083 
00084 /* The magic field is filled with this if uname and gname are valid. */
00085 #define TMAGIC          "ustar  "       /* 7 chars and a null */
00086 
00087 /* The linkflag defines the type of file */
00088 #define LF_OLDNORMAL    '\0'            /* Normal disk file, Unix compat */
00089 #define LF_NORMAL       '0'             /* Normal disk file */
00090 #define LF_LINK         '1'             /* Link to previously dumped file */
00091 #define LF_SYMLINK      '2'             /* Symbolic link */
00092 #define LF_CHR          '3'             /* Character special file */
00093 #define LF_BLK          '4'             /* Block special file */
00094 #define LF_DIR          '5'             /* Directory */
00095 #define LF_FIFO         '6'             /* FIFO special file */
00096 #define LF_CONTIG       '7'             /* Contiguous file */
00097 /* Further link types may be defined later. */
00098 
00099 /*
00100  * Exit codes from the "tar" program
00101  */
00102 #define EX_SUCCESS      0               /* success! */
00103 #define EX_ARGSBAD      1               /* invalid args */
00104 #define EX_BADFILE      2               /* invalid filename */
00105 #define EX_BADARCH      3               /* bad archive */
00106 #define EX_SYSTEM       4               /* system gave unexpected error */
00107 
00108 
00109 /*
00110  * Global variables
00111  */
00112 TAR_EXTERN union record *ar_block;      /* Start of block of archive */
00113 TAR_EXTERN union record *ar_record;     /* Current record of archive */
00114 TAR_EXTERN union record *ar_last;       /* Last+1 record of archive block */
00115 TAR_EXTERN char         ar_reading;     /* 0 writing, !0 reading archive */
00116 TAR_EXTERN int          blocking;       /* Size of each block, in records */
00117 TAR_EXTERN int          blocksize;      /* Size of each block, in bytes */
00118 TAR_EXTERN char         *ar_file;       /* File containing archive */
00119 TAR_EXTERN char         *name_file;     /* File containing names to work on */
00120 TAR_EXTERN char         *tar;           /* Name of this program */
00121 
00122 /*
00123  * Flags from the command line
00124  */
00125 TAR_EXTERN char f_reblock;              /* -B */
00126 TAR_EXTERN char f_create;               /* -c */
00127 TAR_EXTERN char f_debug;                /* -d */
00128 TAR_EXTERN char f_sayblock;             /* -D */
00129 TAR_EXTERN char f_follow_links;         /* -h */
00130 TAR_EXTERN char f_ignorez;              /* -i */
00131 TAR_EXTERN char f_keep;                 /* -k */
00132 TAR_EXTERN char f_modified;             /* -m */
00133 TAR_EXTERN char f_oldarch;              /* -o */
00134 TAR_EXTERN char f_use_protection;       /* -p */
00135 TAR_EXTERN char f_sorted_names;         /* -s */
00136 TAR_EXTERN char f_list;                 /* -t */
00137 TAR_EXTERN char f_namefile;             /* -T */
00138 TAR_EXTERN char f_verbose;              /* -v */
00139 TAR_EXTERN char f_extract;              /* -x */
00140 TAR_EXTERN char f_compress;             /* -z */
00141 
00142 /*
00143  * We now default to Unix Standard format rather than 4.2BSD tar format.
00144  * The code can actually produce all three:
00145  *      f_standard      ANSI standard
00146  *      f_oldarch       V7
00147  *      neither         4.2BSD
00148  * but we don't bother, since 4.2BSD can read ANSI standard format anyway.
00149  * The only advantage to the "neither" option is that we can cmp(1) our
00150  * output to the output of 4.2BSD tar, for debugging.
00151  */
00152 #define         f_standard              (!f_oldarch)
00153 
00154 /*
00155  * Structure for keeping track of filenames and lists thereof.
00156  */
00157 struct name {
00158         struct name     *next;
00159         short           length;
00160         char            found;
00161         char            name[NAMSIZ+1];
00162 };
00163 
00164 TAR_EXTERN struct name  *namelist;      /* Points to first name in list */
00165 TAR_EXTERN struct name  *namelast;      /* Points to last name in list */
00166 
00167 TAR_EXTERN int          archive;        /* File descriptor for archive file */
00168 TAR_EXTERN int          errors;         /* # of files in error */
00169 
00170 /*
00171  *
00172  * Due to the next struct declaration, each routine that includes
00173  * "tar.h" must also include <sys/types.h>.  I tried to make it automatic,
00174  * but System V has no defines in <sys/types.h>, so there is no way of
00175  * knowing when it has been included.  In addition, it cannot be included
00176  * twice, but must be included exactly once.  Argghh!
00177  *
00178  * Thanks, typedef.  Thanks, USG.
00179  */
00180 struct link {
00181         struct link     *next;
00182         dev_t           dev;
00183         ino_t           ino;
00184         short           linkcount;
00185         char            name[NAMSIZ+1];
00186 };
00187 
00188 TAR_EXTERN struct link  *linklist;      /* Points to first link in list */
00189 
00190 
00191 /*
00192  * Error recovery stuff
00193  */
00194 TAR_EXTERN char         read_error_flag;
00195 
00196 
00197 #if 0
00198 /*
00199  * Declarations of functions available to the world.
00200  */
00201 /*LINTLIBRARY*/
00202 #define  annorec(stream, msg)   anno(stream, msg, 0)    /* Cur rec */
00203 #define annofile(stream, msg)   anno(stream, msg, 1)    /* Saved rec */
00204 #endif

Generated on Fri Oct 12 08:44:53 2007 for rpm by  doxygen 1.5.2