Deleted Added
full compact
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. 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

--- 18 unchanged lines hidden (view full) ---

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
34#ifndef lint
35static char sccsid[] = "@(#)restore.c 8.1 (Berkeley) 6/5/93";
35static char sccsid[] = "@(#)restore.c 8.3 (Berkeley) 9/13/94";
36#endif /* not lint */
37
38#include <sys/types.h>
39#include <sys/stat.h>
40
41#include <ufs/ufs/dinode.h>
42
43#include <stdio.h>

--- 36 unchanged lines hidden (view full) ---

80 register struct entry *ep;
81 long descend = hflag ? GOOD : FAIL;
82 char buf[100];
83
84 if (TSTINO(ino, dumpmap) == 0) {
85 dprintf(stdout, "%s: not on the tape\n", name);
86 return (descend);
87 }
88 if (ino == WINO && command == 'i' && !vflag)
89 return (descend);
90 if (!mflag) {
91 (void) sprintf(buf, "./%u", ino);
92 name = buf;
93 if (type == NODE) {
94 (void) genliteraldir(name, ino);
95 return (descend);
96 }
97 }

--- 23 unchanged lines hidden (view full) ---

121 ino_t ino;
122 int type;
123{
124 long descend = hflag ? GOOD : FAIL;
125 struct entry *ep;
126
127 if (TSTINO(ino, dumpmap) == 0)
128 return (descend);
127 ep = lookupino(ino);
128 if (ep != NULL)
129 ep = lookupname(name);
130 if (ep != NULL) {
131 ep->e_flags &= ~NEW;
132 ep->e_flags |= REMOVED;
133 if (ep->e_type != NODE)
134 freeentry(ep);
135 }
136 return (descend);
137}
138
139/*
140 * The following four routines implement the incremental
141 * restore algorithm. The first removes old entries, the second
142 * does renames and calculates the extraction list, the third
143 * cleans up link names missed by the first two, and the final
144 * one deletes old directories.
145 *
146 * Directories cannot be immediately deleted, as they may have
147 * other files in them which need to be moved out first. As
148 * directories to be deleted are found, they are put on the
149 * following deletion list. After all deletions and renames
150 * are done, this list is actually deleted.
151 */
152static struct entry *removelist;
153
154/*
155 * Remove invalid whiteouts from the old tree.
156 * Remove unneeded leaves from the old tree.
157 * Remove directories from the lookup chains.
158 */
159void
160removeoldleaves()
161{
155 register struct entry *ep;
156 register ino_t i;
162 register struct entry *ep, *nextep;
163 register ino_t i, mydirino;
164
165 vprintf(stdout, "Mark entries to be removed.\n");
166 if (ep = lookupino(WINO)) {
167 vprintf(stdout, "Delete whiteouts\n");
168 for ( ; ep != NULL; ep = nextep) {
169 nextep = ep->e_links;
170 mydirino = ep->e_parent->e_ino;
171 /*
172 * We remove all whiteouts that are in directories
173 * that have been removed or that have been dumped.
174 */
175 if (TSTINO(mydirino, usedinomap) &&
176 !TSTINO(mydirino, dumpmap))
177 continue;
178 delwhiteout(ep);
179 freeentry(ep);
180 }
181 }
182 for (i = ROOTINO + 1; i < maxino; i++) {
183 ep = lookupino(i);
184 if (ep == NULL)
185 continue;
163 if (TSTINO(i, clrimap))
186 if (TSTINO(i, usedinomap))
187 continue;
188 for ( ; ep != NULL; ep = ep->e_links) {
189 dprintf(stdout, "%s: REMOVE\n", myname(ep));
190 if (ep->e_type == LEAF) {
191 removeleaf(ep);
192 freeentry(ep);
193 } else {
194 mktempname(ep);

--- 568 unchanged lines hidden (view full) ---

763 */
764void
765createlinks()
766{
767 register struct entry *np, *ep;
768 register ino_t i;
769 char name[BUFSIZ];
770
771 if (ep = lookupino(WINO)) {
772 vprintf(stdout, "Add whiteouts\n");
773 for ( ; ep != NULL; ep = ep->e_links) {
774 if ((ep->e_flags & NEW) == 0)
775 continue;
776 (void) addwhiteout(myname(ep));
777 ep->e_flags &= ~NEW;
778 }
779 }
780 vprintf(stdout, "Add links\n");
781 for (i = ROOTINO; i < maxino; i++) {
782 ep = lookupino(i);
783 if (ep == NULL)
784 continue;
785 for (np = ep->e_links; np != NULL; np = np->e_links) {
786 if ((np->e_flags & NEW) == 0)
787 continue;

--- 15 unchanged lines hidden (view full) ---

803 */
804void
805checkrestore()
806{
807 register struct entry *ep;
808 register ino_t i;
809
810 vprintf(stdout, "Check the symbol table.\n");
779 for (i = ROOTINO; i < maxino; i++) {
811 for (i = WINO; i < maxino; i++) {
812 for (ep = lookupino(i); ep != NULL; ep = ep->e_links) {
813 ep->e_flags &= ~KEEP;
814 if (ep->e_type == NODE)
815 ep->e_flags &= ~(NEW|EXISTED);
816 if (ep->e_flags != NULL)
817 badentry(ep, "incomplete operations");
818 }
819 }

--- 32 unchanged lines hidden ---