home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / sbin / restore / restore.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-30  |  5.1 KB  |  133 lines

  1. /*
  2.  * Copyright (c) 1983 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *    This product includes software developed by the University of
  16.  *    California, Berkeley and its contributors.
  17.  * 4. Neither the name of the University nor the names of its contributors
  18.  *    may be used to endorse or promote products derived from this software
  19.  *    without specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.  * SUCH DAMAGE.
  32.  *
  33.  *    @(#)restore.h    5.14 (Berkeley) 10/16/92
  34.  */
  35.  
  36. /*
  37.  * Flags
  38.  */
  39. extern int    cvtflag;    /* convert from old to new tape format */
  40. extern int    bflag;        /* set input block size */
  41. extern int    dflag;        /* print out debugging info */
  42. extern int    hflag;        /* restore heirarchies */
  43. extern int    mflag;        /* restore by name instead of inode number */
  44. extern int    Nflag;        /* do not write the disk */
  45. extern int    vflag;        /* print out actions taken */
  46. extern int    yflag;        /* always try to recover from tape errors */
  47. /*
  48.  * Global variables
  49.  */
  50. extern char    *dumpmap;     /* map of inodes on this dump tape */
  51. extern char    *clrimap;     /* map of inodes to be deleted */
  52. extern ino_t    maxino;        /* highest numbered inode in this file system */
  53. extern long    dumpnum;    /* location of the dump on this tape */
  54. extern long    volno;        /* current volume being read */
  55. extern long    ntrec;        /* number of TP_BSIZE records per tape block */
  56. extern time_t    dumptime;    /* time that this dump begins */
  57. extern time_t    dumpdate;    /* time that this dump was made */
  58. extern char    command;    /* opration being performed */
  59. extern FILE    *terminal;    /* file descriptor for the terminal input */
  60. extern int    oldinofmt;    /* reading tape with old format inodes */
  61. extern int    Bcvt;        /* need byte swapping on inodes and dirs */
  62.  
  63. /*
  64.  * Each file in the file system is described by one of these entries
  65.  */
  66. struct entry {
  67.     char    *e_name;        /* the current name of this entry */
  68.     u_char    e_namlen;        /* length of this name */
  69.     char    e_type;            /* type of this entry, see below */
  70.     short    e_flags;        /* status flags, see below */
  71.     ino_t    e_ino;            /* inode number in previous file sys */
  72.     long    e_index;        /* unique index (for dumpped table) */
  73.     struct    entry *e_parent;    /* pointer to parent directory (..) */
  74.     struct    entry *e_sibling;    /* next element in this directory (.) */
  75.     struct    entry *e_links;        /* hard links to this inode */
  76.     struct    entry *e_entries;    /* for directories, their entries */
  77.     struct    entry *e_next;        /* hash chain list */
  78. };
  79. /* types */
  80. #define    LEAF 1            /* non-directory entry */
  81. #define NODE 2            /* directory entry */
  82. #define LINK 4            /* synthesized type, stripped by addentry */
  83. /* flags */
  84. #define EXTRACT        0x0001    /* entry is to be replaced from the tape */
  85. #define NEW        0x0002    /* a new entry to be extracted */
  86. #define KEEP        0x0004    /* entry is not to change */
  87. #define REMOVED        0x0010    /* entry has been removed */
  88. #define TMPNAME        0x0020    /* entry has been given a temporary name */
  89. #define EXISTED        0x0040    /* directory already existed during extract */
  90.  
  91. /*
  92.  * Constants associated with entry structs
  93.  */
  94. #define HARDLINK    1
  95. #define SYMLINK        2
  96. #define TMPHDR        "RSTTMP"
  97.  
  98. /*
  99.  * The entry describes the next file available on the tape
  100.  */
  101. struct context {
  102.     char    *name;        /* name of file */
  103.     ino_t    ino;        /* inumber of file */
  104.     struct    dinode *dip;    /* pointer to inode */
  105.     char    action;        /* action being taken on this file */
  106. } curfile;
  107. /* actions */
  108. #define    USING    1    /* extracting from the tape */
  109. #define    SKIP    2    /* skipping */
  110. #define UNKNOWN 3    /* disposition or starting point is unknown */
  111.  
  112. /*
  113.  * Definitions for library routines operating on directories.
  114.  */
  115. typedef struct rstdirdesc RST_DIR;
  116.  
  117. /*
  118.  * Flags to setdirmodes.
  119.  */
  120. #define FORCE    0x0001
  121.  
  122. /*
  123.  * Useful macros
  124.  */
  125. #define TSTINO(ino, map) \
  126.     (map[(u_int)((ino) - 1) / NBBY] &  (1 << ((u_int)((ino) - 1) % NBBY)))
  127.  
  128. #define dprintf        if (dflag) fprintf
  129. #define vprintf        if (vflag) fprintf
  130.  
  131. #define GOOD 1
  132. #define FAIL 0
  133.