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