restore.c (8871) | restore.c (23685) |
---|---|
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 | 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 } | 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); |
|
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); | 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) { |
129 ep->e_flags &= ~NEW; | 131 ep->e_flags &= ~NEW; |
132 ep->e_flags |= REMOVED; 133 if (ep->e_type != NODE) 134 freeentry(ep); 135 } |
|
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/* | 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. |
|
149 * Remove unneeded leaves from the old tree. 150 * Remove directories from the lookup chains. 151 */ 152void 153removeoldleaves() 154{ | 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; |
157 158 vprintf(stdout, "Mark entries to be removed.\n"); | 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 } |
|
159 for (i = ROOTINO + 1; i < maxino; i++) { 160 ep = lookupino(i); 161 if (ep == NULL) 162 continue; | 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)) |
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 | 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 } |
|
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"); | 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++) { |
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 --- | 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 --- |