restore.c (90642) | restore.c (92806) |
---|---|
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 --- 22 unchanged lines hidden (view full) --- 31 * SUCH DAMAGE. 32 */ 33 34#ifndef lint 35#if 0 36static char sccsid[] = "@(#)restore.c 8.3 (Berkeley) 9/13/94"; 37#endif 38static const char rcsid[] = | 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 --- 22 unchanged lines hidden (view full) --- 31 * SUCH DAMAGE. 32 */ 33 34#ifndef lint 35#if 0 36static char sccsid[] = "@(#)restore.c 8.3 (Berkeley) 9/13/94"; 37#endif 38static const char rcsid[] = |
39 "$FreeBSD: head/sbin/restore/restore.c 90642 2002-02-14 01:30:45Z iedowse $"; | 39 "$FreeBSD: head/sbin/restore/restore.c 92806 2002-03-20 17:55:10Z obrien $"; |
40#endif /* not lint */ 41 42#include <sys/types.h> 43 44#include <ufs/ufs/dinode.h> 45 46#include <stdio.h> 47#include <string.h> --- 27 unchanged lines hidden (view full) --- 75 * Request that new entries be extracted. 76 */ 77long 78addfile(name, ino, type) 79 char *name; 80 ino_t ino; 81 int type; 82{ | 40#endif /* not lint */ 41 42#include <sys/types.h> 43 44#include <ufs/ufs/dinode.h> 45 46#include <stdio.h> 47#include <string.h> --- 27 unchanged lines hidden (view full) --- 75 * Request that new entries be extracted. 76 */ 77long 78addfile(name, ino, type) 79 char *name; 80 ino_t ino; 81 int type; 82{ |
83 register struct entry *ep; | 83 struct entry *ep; |
84 long descend = hflag ? GOOD : FAIL; 85 char buf[100]; 86 87 if (TSTINO(ino, dumpmap) == 0) { 88 dprintf(stdout, "%s: not on the tape\n", name); 89 return (descend); 90 } 91 if (ino == WINO && command == 'i' && !vflag) --- 65 unchanged lines hidden (view full) --- 157/* 158 * Remove invalid whiteouts from the old tree. 159 * Remove unneeded leaves from the old tree. 160 * Remove directories from the lookup chains. 161 */ 162void 163removeoldleaves() 164{ | 84 long descend = hflag ? GOOD : FAIL; 85 char buf[100]; 86 87 if (TSTINO(ino, dumpmap) == 0) { 88 dprintf(stdout, "%s: not on the tape\n", name); 89 return (descend); 90 } 91 if (ino == WINO && command == 'i' && !vflag) --- 65 unchanged lines hidden (view full) --- 157/* 158 * Remove invalid whiteouts from the old tree. 159 * Remove unneeded leaves from the old tree. 160 * Remove directories from the lookup chains. 161 */ 162void 163removeoldleaves() 164{ |
165 register struct entry *ep, *nextep; 166 register ino_t i, mydirino; | 165 struct entry *ep, *nextep; 166 ino_t i, mydirino; |
167 168 vprintf(stdout, "Mark entries to be removed.\n"); 169 if ((ep = lookupino(WINO))) { 170 vprintf(stdout, "Delete whiteouts\n"); 171 for ( ; ep != NULL; ep = nextep) { 172 nextep = ep->e_links; 173 mydirino = ep->e_parent->e_ino; 174 /* --- 38 unchanged lines hidden (view full) --- 213 * Renames are done at the same time. 214 */ 215long 216nodeupdates(name, ino, type) 217 char *name; 218 ino_t ino; 219 int type; 220{ | 167 168 vprintf(stdout, "Mark entries to be removed.\n"); 169 if ((ep = lookupino(WINO))) { 170 vprintf(stdout, "Delete whiteouts\n"); 171 for ( ; ep != NULL; ep = nextep) { 172 nextep = ep->e_links; 173 mydirino = ep->e_parent->e_ino; 174 /* --- 38 unchanged lines hidden (view full) --- 213 * Renames are done at the same time. 214 */ 215long 216nodeupdates(name, ino, type) 217 char *name; 218 ino_t ino; 219 int type; 220{ |
221 register struct entry *ep, *np, *ip; | 221 struct entry *ep, *np, *ip; |
222 long descend = GOOD; 223 int lookuptype = 0; 224 int key = 0; 225 /* key values */ 226# define ONTAPE 0x1 /* inode is on the tape */ 227# define INOFND 0x2 /* inode already exists */ 228# define NAMEFND 0x4 /* name already exists */ 229# define MODECHG 0x8 /* mode of inode changed */ --- 291 unchanged lines hidden (view full) --- 521} 522 523/* 524 * Find unreferenced link names. 525 */ 526void 527findunreflinks() 528{ | 222 long descend = GOOD; 223 int lookuptype = 0; 224 int key = 0; 225 /* key values */ 226# define ONTAPE 0x1 /* inode is on the tape */ 227# define INOFND 0x2 /* inode already exists */ 228# define NAMEFND 0x4 /* name already exists */ 229# define MODECHG 0x8 /* mode of inode changed */ --- 291 unchanged lines hidden (view full) --- 521} 522 523/* 524 * Find unreferenced link names. 525 */ 526void 527findunreflinks() 528{ |
529 register struct entry *ep, *np; 530 register ino_t i; | 529 struct entry *ep, *np; 530 ino_t i; |
531 532 vprintf(stdout, "Find unreferenced names.\n"); 533 for (i = ROOTINO; i < maxino; i++) { 534 ep = lookupino(i); 535 if (ep == NULL || ep->e_type == LEAF || TSTINO(i, dumpmap) == 0) 536 continue; 537 for (np = ep->e_entries; np != NULL; np = np->e_sibling) { 538 if (np->e_flags == 0) { --- 30 unchanged lines hidden (view full) --- 569 * D is the maximum depth of the tree. 570 * If N == D this can be quite slow. If the list were 571 * topologically sorted, the deletion could be done in 572 * time O(N). 573 */ 574void 575removeoldnodes() 576{ | 531 532 vprintf(stdout, "Find unreferenced names.\n"); 533 for (i = ROOTINO; i < maxino; i++) { 534 ep = lookupino(i); 535 if (ep == NULL || ep->e_type == LEAF || TSTINO(i, dumpmap) == 0) 536 continue; 537 for (np = ep->e_entries; np != NULL; np = np->e_sibling) { 538 if (np->e_flags == 0) { --- 30 unchanged lines hidden (view full) --- 569 * D is the maximum depth of the tree. 570 * If N == D this can be quite slow. If the list were 571 * topologically sorted, the deletion could be done in 572 * time O(N). 573 */ 574void 575removeoldnodes() 576{ |
577 register struct entry *ep, **prev; | 577 struct entry *ep, **prev; |
578 long change; 579 580 vprintf(stdout, "Remove old nodes (directories).\n"); 581 do { 582 change = 0; 583 prev = &removelist; 584 for (ep = removelist; ep != NULL; ep = *prev) { 585 if (ep->e_entries != NULL) { --- 13 unchanged lines hidden (view full) --- 599/* 600 * This is the routine used to extract files for the 'r' command. 601 * Extract new leaves. 602 */ 603void 604createleaves(symtabfile) 605 char *symtabfile; 606{ | 578 long change; 579 580 vprintf(stdout, "Remove old nodes (directories).\n"); 581 do { 582 change = 0; 583 prev = &removelist; 584 for (ep = removelist; ep != NULL; ep = *prev) { 585 if (ep->e_entries != NULL) { --- 13 unchanged lines hidden (view full) --- 599/* 600 * This is the routine used to extract files for the 'r' command. 601 * Extract new leaves. 602 */ 603void 604createleaves(symtabfile) 605 char *symtabfile; 606{ |
607 register struct entry *ep; | 607 struct entry *ep; |
608 ino_t first; 609 long curvol; 610 611 if (command == 'R') { 612 vprintf(stdout, "Continue extraction of new leaves\n"); 613 } else { 614 vprintf(stdout, "Extract new leaves.\n"); 615 dumpsymtable(symtabfile, volno); --- 62 unchanged lines hidden (view full) --- 678 679/* 680 * This is the routine used to extract files for the 'x' and 'i' commands. 681 * Efficiently extract a subset of the files on a tape. 682 */ 683void 684createfiles() 685{ | 608 ino_t first; 609 long curvol; 610 611 if (command == 'R') { 612 vprintf(stdout, "Continue extraction of new leaves\n"); 613 } else { 614 vprintf(stdout, "Extract new leaves.\n"); 615 dumpsymtable(symtabfile, volno); --- 62 unchanged lines hidden (view full) --- 678 679/* 680 * This is the routine used to extract files for the 'x' and 'i' commands. 681 * Efficiently extract a subset of the files on a tape. 682 */ 683void 684createfiles() 685{ |
686 register ino_t first, next, last; 687 register struct entry *ep; | 686 ino_t first, next, last; 687 struct entry *ep; |
688 long curvol; 689 690 vprintf(stdout, "Extract requested files\n"); 691 curfile.action = SKIP; 692 getvol((long)1); 693 skipmaps(); 694 skipdirs(); 695 first = lowerbnd(ROOTINO); --- 78 unchanged lines hidden (view full) --- 774} 775 776/* 777 * Add links. 778 */ 779void 780createlinks() 781{ | 688 long curvol; 689 690 vprintf(stdout, "Extract requested files\n"); 691 curfile.action = SKIP; 692 getvol((long)1); 693 skipmaps(); 694 skipdirs(); 695 first = lowerbnd(ROOTINO); --- 78 unchanged lines hidden (view full) --- 774} 775 776/* 777 * Add links. 778 */ 779void 780createlinks() 781{ |
782 register struct entry *np, *ep; 783 register ino_t i; | 782 struct entry *np, *ep; 783 ino_t i; |
784 char name[BUFSIZ]; 785 786 if ((ep = lookupino(WINO))) { 787 vprintf(stdout, "Add whiteouts\n"); 788 for ( ; ep != NULL; ep = ep->e_links) { 789 if ((ep->e_flags & NEW) == 0) 790 continue; 791 (void) addwhiteout(myname(ep)); --- 22 unchanged lines hidden (view full) --- 814/* 815 * Check the symbol table. 816 * We do this to insure that all the requested work was done, and 817 * that no temporary names remain. 818 */ 819void 820checkrestore() 821{ | 784 char name[BUFSIZ]; 785 786 if ((ep = lookupino(WINO))) { 787 vprintf(stdout, "Add whiteouts\n"); 788 for ( ; ep != NULL; ep = ep->e_links) { 789 if ((ep->e_flags & NEW) == 0) 790 continue; 791 (void) addwhiteout(myname(ep)); --- 22 unchanged lines hidden (view full) --- 814/* 815 * Check the symbol table. 816 * We do this to insure that all the requested work was done, and 817 * that no temporary names remain. 818 */ 819void 820checkrestore() 821{ |
822 register struct entry *ep; 823 register ino_t i; | 822 struct entry *ep; 823 ino_t i; |
824 825 vprintf(stdout, "Check the symbol table.\n"); 826 for (i = WINO; i < maxino; i++) { 827 for (ep = lookupino(i); ep != NULL; ep = ep->e_links) { 828 ep->e_flags &= ~KEEP; 829 if (ep->e_type == NODE) 830 ep->e_flags &= ~(NEW|EXISTED); 831 if (ep->e_flags != 0) --- 35 unchanged lines hidden --- | 824 825 vprintf(stdout, "Check the symbol table.\n"); 826 for (i = WINO; i < maxino; i++) { 827 for (ep = lookupino(i); ep != NULL; ep = ep->e_links) { 828 ep->e_flags &= ~KEEP; 829 if (ep->e_type == NODE) 830 ep->e_flags &= ~(NEW|EXISTED); 831 if (ep->e_flags != 0) --- 35 unchanged lines hidden --- |