[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.5

1.5     ! tedu        1: /*     $OpenBSD$ */
        !             2: /*
        !             3:  * Copyright (c) Ian F. Darwin 1986-1995.
        !             4:  * Software written by Ian F. Darwin and others;
        !             5:  * maintained 1995-present by Christos Zoulas and others.
        !             6:  *
        !             7:  * Redistribution and use in source and binary forms, with or without
        !             8:  * modification, are permitted provided that the following conditions
        !             9:  * are met:
        !            10:  * 1. Redistributions of source code must retain the above copyright
        !            11:  *    notice immediately at the beginning of the file, without modification,
        !            12:  *    this list of conditions, and the following disclaimer.
        !            13:  * 2. Redistributions in binary form must reproduce the above copyright
        !            14:  *    notice, this list of conditions and the following disclaimer in the
        !            15:  *    documentation and/or other materials provided with the distribution.
        !            16:  *
        !            17:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
        !            18:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            19:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            20:  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
        !            21:  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            22:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            23:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            24:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            25:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            26:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            27:  * SUCH DAMAGE.
        !            28:  */
1.1       deraadt    29: /*
                     30:  * Header file for public domain tar (tape archive) program.
                     31:  *
                     32:  * @(#)tar.h 1.20 86/10/29     Public Domain.
                     33:  *
                     34:  * Created 25 August 1985 by John Gilmore, ihnp4!hoptoad!gnu.
                     35:  *
1.5     ! tedu       36:  * $Id: tar.h,v 1.7 2003/10/14 19:29:56 christos Exp $ # checkin only
1.1       deraadt    37:  */
                     38:
                     39: /*
1.5     ! tedu       40:  * Kludge for handling systems that cannot cope with multiple
1.1       deraadt    41:  * external definitions of a variable.  In ONE routine (tar.c),
                     42:  * we #define TAR_EXTERN to null; here, we set it to "extern" if
                     43:  * it is not already set.
                     44:  */
                     45: #ifndef TAR_EXTERN
                     46: #define TAR_EXTERN extern
                     47: #endif
                     48:
                     49: /*
                     50:  * Header block on tape.
                     51:  *
                     52:  * I'm going to use traditional DP naming conventions here.
                     53:  * A "block" is a big chunk of stuff that we do I/O on.
                     54:  * A "record" is a piece of info that we care about.
                     55:  * Typically many "record"s fit into a "block".
                     56:  */
                     57: #define        RECORDSIZE      512
                     58: #define        NAMSIZ  100
                     59: #define        TUNMLEN 32
                     60: #define        TGNMLEN 32
                     61:
                     62: union record {
                     63:        char            charptr[RECORDSIZE];
                     64:        struct header {
                     65:                char    name[NAMSIZ];
                     66:                char    mode[8];
                     67:                char    uid[8];
                     68:                char    gid[8];
                     69:                char    size[12];
                     70:                char    mtime[12];
                     71:                char    chksum[8];
                     72:                char    linkflag;
                     73:                char    linkname[NAMSIZ];
                     74:                char    magic[8];
                     75:                char    uname[TUNMLEN];
                     76:                char    gname[TGNMLEN];
                     77:                char    devmajor[8];
                     78:                char    devminor[8];
                     79:        } header;
                     80: };
                     81:
                     82: /* The checksum field is filled with this while the checksum is computed. */
                     83: #define        CHKBLANKS       "        "      /* 8 blanks, no null */
                     84:
                     85: /* The magic field is filled with this if uname and gname are valid. */
                     86: #define        TMAGIC          "ustar  "       /* 7 chars and a null */
                     87:
                     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:
                    100: /*
                    101:  * Exit codes from the "tar" program
                    102:  */
                    103: #define        EX_SUCCESS      0               /* success! */
                    104: #define        EX_ARGSBAD      1               /* invalid args */
                    105: #define        EX_BADFILE      2               /* invalid filename */
                    106: #define        EX_BADARCH      3               /* bad archive */
                    107: #define        EX_SYSTEM       4               /* system gave unexpected error */
                    108:
                    109:
                    110: /*
                    111:  * Global variables
                    112:  */
                    113: TAR_EXTERN union record        *ar_block;      /* Start of block of archive */
                    114: TAR_EXTERN union record        *ar_record;     /* Current record of archive */
                    115: TAR_EXTERN union record        *ar_last;       /* Last+1 record of archive block */
                    116: TAR_EXTERN char                ar_reading;     /* 0 writing, !0 reading archive */
                    117: TAR_EXTERN int         blocking;       /* Size of each block, in records */
                    118: TAR_EXTERN int         blocksize;      /* Size of each block, in bytes */
                    119: TAR_EXTERN char                *ar_file;       /* File containing archive */
                    120: TAR_EXTERN char                *name_file;     /* File containing names to work on */
                    121: TAR_EXTERN char                *tar;           /* Name of this program */
                    122:
                    123: /*
                    124:  * Flags from the command line
                    125:  */
                    126: TAR_EXTERN char        f_reblock;              /* -B */
                    127: TAR_EXTERN char        f_create;               /* -c */
                    128: TAR_EXTERN char        f_debug;                /* -d */
                    129: TAR_EXTERN char        f_sayblock;             /* -D */
                    130: TAR_EXTERN char        f_follow_links;         /* -h */
                    131: TAR_EXTERN char        f_ignorez;              /* -i */
                    132: TAR_EXTERN char        f_keep;                 /* -k */
                    133: TAR_EXTERN char        f_modified;             /* -m */
                    134: TAR_EXTERN char        f_oldarch;              /* -o */
                    135: TAR_EXTERN char        f_use_protection;       /* -p */
                    136: TAR_EXTERN char        f_sorted_names;         /* -s */
                    137: TAR_EXTERN char        f_list;                 /* -t */
                    138: TAR_EXTERN char        f_namefile;             /* -T */
                    139: TAR_EXTERN char        f_verbose;              /* -v */
                    140: TAR_EXTERN char        f_extract;              /* -x */
                    141: TAR_EXTERN char        f_compress;             /* -z */
                    142:
                    143: /*
                    144:  * We now default to Unix Standard format rather than 4.2BSD tar format.
                    145:  * The code can actually produce all three:
                    146:  *     f_standard      ANSI standard
                    147:  *     f_oldarch       V7
                    148:  *     neither         4.2BSD
                    149:  * but we don't bother, since 4.2BSD can read ANSI standard format anyway.
                    150:  * The only advantage to the "neither" option is that we can cmp(1) our
                    151:  * output to the output of 4.2BSD tar, for debugging.
                    152:  */
                    153: #define                f_standard              (!f_oldarch)
                    154:
                    155: /*
                    156:  * Structure for keeping track of filenames and lists thereof.
                    157:  */
                    158: struct name {
                    159:        struct name     *next;
                    160:        short           length;
                    161:        char            found;
                    162:        char            name[NAMSIZ+1];
                    163: };
                    164:
                    165: TAR_EXTERN struct name *namelist;      /* Points to first name in list */
                    166: TAR_EXTERN struct name *namelast;      /* Points to last name in list */
                    167:
                    168: TAR_EXTERN int         archive;        /* File descriptor for archive file */
                    169: TAR_EXTERN int         errors;         /* # of files in error */
                    170:
                    171: /*
                    172:  *
                    173:  * Due to the next struct declaration, each routine that includes
                    174:  * "tar.h" must also include <sys/types.h>.  I tried to make it automatic,
                    175:  * but System V has no defines in <sys/types.h>, so there is no way of
                    176:  * knowing when it has been included.  In addition, it cannot be included
                    177:  * twice, but must be included exactly once.  Argghh!
                    178:  *
                    179:  * Thanks, typedef.  Thanks, USG.
                    180:  */
                    181: struct link {
                    182:        struct link     *next;
                    183:        dev_t           dev;
                    184:        ino_t           ino;
                    185:        short           linkcount;
                    186:        char            name[NAMSIZ+1];
                    187: };
                    188:
                    189: TAR_EXTERN struct link *linklist;      /* Points to first link in list */
                    190:
                    191:
                    192: /*
                    193:  * Error recovery stuff
                    194:  */
                    195: TAR_EXTERN char                read_error_flag;
1.5     ! tedu      196:
        !           197:
        !           198: #if 0
        !           199: /*
        !           200:  * Declarations of functions available to the world.
        !           201:  */
        !           202: /*LINTLIBRARY*/
        !           203: #define         annorec(stream, msg)   anno(stream, msg, 0)    /* Cur rec */
        !           204: #define        annofile(stream, msg)   anno(stream, msg, 1)    /* Saved rec */
        !           205: #endif