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