[BACK]Return to tar.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / file

Annotation of src/usr.bin/file/tar.h, Revision 1.1.1.1

1.1       deraadt     1: /*
                      2:  * Header file for public domain tar (tape archive) program.
                      3:  *
                      4:  * @(#)tar.h 1.20 86/10/29     Public Domain.
                      5:  *
                      6:  * Created 25 August 1985 by John Gilmore, ihnp4!hoptoad!gnu.
                      7:  *
                      8:  * $Id: tar.h,v 1.4 1995/03/25 22:36:45 christos Exp $ # checkin only
                      9:  */
                     10:
                     11: /*
                     12:  * Kludge for handling systems that can't cope with multiple
                     13:  * external definitions of a variable.  In ONE routine (tar.c),
                     14:  * we #define TAR_EXTERN to null; here, we set it to "extern" if
                     15:  * it is not already set.
                     16:  */
                     17: #ifndef TAR_EXTERN
                     18: #define TAR_EXTERN extern
                     19: #endif
                     20:
                     21: /*
                     22:  * Header block on tape.
                     23:  *
                     24:  * I'm going to use traditional DP naming conventions here.
                     25:  * A "block" is a big chunk of stuff that we do I/O on.
                     26:  * A "record" is a piece of info that we care about.
                     27:  * Typically many "record"s fit into a "block".
                     28:  */
                     29: #define        RECORDSIZE      512
                     30: #define        NAMSIZ  100
                     31: #define        TUNMLEN 32
                     32: #define        TGNMLEN 32
                     33:
                     34: union record {
                     35:        char            charptr[RECORDSIZE];
                     36:        struct header {
                     37:                char    name[NAMSIZ];
                     38:                char    mode[8];
                     39:                char    uid[8];
                     40:                char    gid[8];
                     41:                char    size[12];
                     42:                char    mtime[12];
                     43:                char    chksum[8];
                     44:                char    linkflag;
                     45:                char    linkname[NAMSIZ];
                     46:                char    magic[8];
                     47:                char    uname[TUNMLEN];
                     48:                char    gname[TGNMLEN];
                     49:                char    devmajor[8];
                     50:                char    devminor[8];
                     51:        } header;
                     52: };
                     53:
                     54: /* The checksum field is filled with this while the checksum is computed. */
                     55: #define        CHKBLANKS       "        "      /* 8 blanks, no null */
                     56:
                     57: /* The magic field is filled with this if uname and gname are valid. */
                     58: #define        TMAGIC          "ustar  "       /* 7 chars and a null */
                     59:
                     60: /* The linkflag defines the type of file */
                     61: #define        LF_OLDNORMAL    '\0'            /* Normal disk file, Unix compat */
                     62: #define        LF_NORMAL       '0'             /* Normal disk file */
                     63: #define        LF_LINK         '1'             /* Link to previously dumped file */
                     64: #define        LF_SYMLINK      '2'             /* Symbolic link */
                     65: #define        LF_CHR          '3'             /* Character special file */
                     66: #define        LF_BLK          '4'             /* Block special file */
                     67: #define        LF_DIR          '5'             /* Directory */
                     68: #define        LF_FIFO         '6'             /* FIFO special file */
                     69: #define        LF_CONTIG       '7'             /* Contiguous file */
                     70: /* Further link types may be defined later. */
                     71:
                     72: /*
                     73:  * Exit codes from the "tar" program
                     74:  */
                     75: #define        EX_SUCCESS      0               /* success! */
                     76: #define        EX_ARGSBAD      1               /* invalid args */
                     77: #define        EX_BADFILE      2               /* invalid filename */
                     78: #define        EX_BADARCH      3               /* bad archive */
                     79: #define        EX_SYSTEM       4               /* system gave unexpected error */
                     80:
                     81:
                     82: /*
                     83:  * Global variables
                     84:  */
                     85: TAR_EXTERN union record        *ar_block;      /* Start of block of archive */
                     86: TAR_EXTERN union record        *ar_record;     /* Current record of archive */
                     87: TAR_EXTERN union record        *ar_last;       /* Last+1 record of archive block */
                     88: TAR_EXTERN char                ar_reading;     /* 0 writing, !0 reading archive */
                     89: TAR_EXTERN int         blocking;       /* Size of each block, in records */
                     90: TAR_EXTERN int         blocksize;      /* Size of each block, in bytes */
                     91: TAR_EXTERN char                *ar_file;       /* File containing archive */
                     92: TAR_EXTERN char                *name_file;     /* File containing names to work on */
                     93: TAR_EXTERN char                *tar;           /* Name of this program */
                     94:
                     95: /*
                     96:  * Flags from the command line
                     97:  */
                     98: TAR_EXTERN char        f_reblock;              /* -B */
                     99: TAR_EXTERN char        f_create;               /* -c */
                    100: TAR_EXTERN char        f_debug;                /* -d */
                    101: TAR_EXTERN char        f_sayblock;             /* -D */
                    102: TAR_EXTERN char        f_follow_links;         /* -h */
                    103: TAR_EXTERN char        f_ignorez;              /* -i */
                    104: TAR_EXTERN char        f_keep;                 /* -k */
                    105: TAR_EXTERN char        f_modified;             /* -m */
                    106: TAR_EXTERN char        f_oldarch;              /* -o */
                    107: TAR_EXTERN char        f_use_protection;       /* -p */
                    108: TAR_EXTERN char        f_sorted_names;         /* -s */
                    109: TAR_EXTERN char        f_list;                 /* -t */
                    110: TAR_EXTERN char        f_namefile;             /* -T */
                    111: TAR_EXTERN char        f_verbose;              /* -v */
                    112: TAR_EXTERN char        f_extract;              /* -x */
                    113: TAR_EXTERN char        f_compress;             /* -z */
                    114:
                    115: /*
                    116:  * We now default to Unix Standard format rather than 4.2BSD tar format.
                    117:  * The code can actually produce all three:
                    118:  *     f_standard      ANSI standard
                    119:  *     f_oldarch       V7
                    120:  *     neither         4.2BSD
                    121:  * but we don't bother, since 4.2BSD can read ANSI standard format anyway.
                    122:  * The only advantage to the "neither" option is that we can cmp(1) our
                    123:  * output to the output of 4.2BSD tar, for debugging.
                    124:  */
                    125: #define                f_standard              (!f_oldarch)
                    126:
                    127: /*
                    128:  * Structure for keeping track of filenames and lists thereof.
                    129:  */
                    130: struct name {
                    131:        struct name     *next;
                    132:        short           length;
                    133:        char            found;
                    134:        char            name[NAMSIZ+1];
                    135: };
                    136:
                    137: TAR_EXTERN struct name *namelist;      /* Points to first name in list */
                    138: TAR_EXTERN struct name *namelast;      /* Points to last name in list */
                    139:
                    140: TAR_EXTERN int         archive;        /* File descriptor for archive file */
                    141: TAR_EXTERN int         errors;         /* # of files in error */
                    142:
                    143: /*
                    144:  *
                    145:  * Due to the next struct declaration, each routine that includes
                    146:  * "tar.h" must also include <sys/types.h>.  I tried to make it automatic,
                    147:  * but System V has no defines in <sys/types.h>, so there is no way of
                    148:  * knowing when it has been included.  In addition, it cannot be included
                    149:  * twice, but must be included exactly once.  Argghh!
                    150:  *
                    151:  * Thanks, typedef.  Thanks, USG.
                    152:  */
                    153: struct link {
                    154:        struct link     *next;
                    155:        dev_t           dev;
                    156:        ino_t           ino;
                    157:        short           linkcount;
                    158:        char            name[NAMSIZ+1];
                    159: };
                    160:
                    161: TAR_EXTERN struct link *linklist;      /* Points to first link in list */
                    162:
                    163:
                    164: /*
                    165:  * Error recovery stuff
                    166:  */
                    167: TAR_EXTERN char                read_error_flag;
                    168:
                    169:
                    170: /*
                    171:  * Declarations of functions available to the world.
                    172:  */
                    173: /*LINTLIBRARY*/
                    174: union record *findrec();
                    175: void userec();
                    176: union record *endofrecs();
                    177: void anno();
                    178: #define         annorec(stream, msg)   anno(stream, msg, 0)    /* Cur rec */
                    179: #define        annofile(stream, msg)   anno(stream, msg, 1)    /* Saved rec */