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