- Main Page
- Related Pages
- Modules
- Data Structures
- Files

# 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  * $File: tar.h,v 1.11 2007/01/16 14:56:45 ljt 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"         /* 5 chars and a null */
    00086 #define GNUTMAGIC       "ustar  "       /* 7 chars and a null */
    00087
    00088 /* The linkflag defines the type of file */
    00089 #define LF_OLDNORMAL    '\0'            /* Normal disk file, Unix compat */
    00090 #define LF_NORMAL       '0'             /* Normal disk file */
    00091 #define LF_LINK         '1'             /* Link to previously dumped file */
    00092 #define LF_SYMLINK      '2'             /* Symbolic link */
    00093 #define LF_CHR          '3'             /* Character special file */
    00094 #define LF_BLK          '4'             /* Block special file */
    00095 #define LF_DIR          '5'             /* Directory */
    00096 #define LF_FIFO         '6'             /* FIFO special file */
    00097 #define LF_CONTIG       '7'             /* Contiguous file */
    00098 /* Further link types may be defined later. */
    00099
    00100 /*
    00101  * Exit codes from the "tar" program
    00102  */
    00103 #define EX_SUCCESS      0               /* success! */
    00104 #define EX_ARGSBAD      1               /* invalid args */
    00105 #define EX_BADFILE      2               /* invalid filename */
    00106 #define EX_BADARCH      3               /* bad archive */
    00107 #define EX_SYSTEM       4               /* system gave unexpected error */
    00108
    00109 /*
    00110  * Structure for keeping track of filenames and lists thereof.
    00111  */
    00112 struct name {
    00113         struct name     *next;
    00114         short           length;
    00115         char            found;
    00116         char            name[NAMSIZ+1];
    00117 };
    00118
    00119 /*
    00120  *
    00121  * Due to the next struct declaration, each routine that includes
    00122  * "tar.h" must also include <sys/types.h>.  I tried to make it automatic,
    00123  * but System V has no defines in <sys/types.h>, so there is no way of
    00124  * knowing when it has been included.  In addition, it cannot be included
    00125  * twice, but must be included exactly once.  Argghh!
    00126  *
    00127  * Thanks, typedef.  Thanks, USG.
    00128  */
    00129 struct link {
    00130         struct link     *next;
    00131         dev_t           dev;
    00132         ino_t           ino;
    00133         short           linkcount;
    00134         char            name[NAMSIZ+1];
    00135 };