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";
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 (!mflag) {
89 (void) sprintf(buf, "./%u", ino);
90 name = buf;
91 if (type == NODE) {
92 (void) genliteraldir(name, ino);
93 return (descend);
94 }
95 }

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

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

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

740 */
741void
742createlinks()
743{
744 register struct entry *np, *ep;
745 register ino_t i;
746 char name[BUFSIZ];
747
748 vprintf(stdout, "Add links\n");
749 for (i = ROOTINO; i < maxino; i++) {
750 ep = lookupino(i);
751 if (ep == NULL)
752 continue;
753 for (np = ep->e_links; np != NULL; np = np->e_links) {
754 if ((np->e_flags & NEW) == 0)
755 continue;

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

771 */
772void
773checkrestore()
774{
775 register struct entry *ep;
776 register ino_t i;
777
778 vprintf(stdout, "Check the symbol table.\n");
779 for (i = ROOTINO; i < maxino; i++) {
780 for (ep = lookupino(i); ep != NULL; ep = ep->e_links) {
781 ep->e_flags &= ~KEEP;
782 if (ep->e_type == NODE)
783 ep->e_flags &= ~(NEW|EXISTED);
784 if (ep->e_flags != NULL)
785 badentry(ep, "incomplete operations");
786 }
787 }

--- 32 unchanged lines hidden ---