1: /*
2: * Copyright (c) 1983 Regents of the University of California.
3: * All rights reserved. The Berkeley software License Agreement
4: * specifies the terms and conditions for redistribution.
5: *
6: * @(#)restore.h 5.1 (Berkeley) 5/28/85
7: */
8:
9: #include <stdio.h>
10: #include <sys/param.h>
11: #include <sys/inode.h>
12: #include <sys/fs.h>
13: #include <sys/dir.h>
14:
15: /*
16: * Flags
17: */
18: extern int cvtflag; /* convert from old to new tape format */
19: extern int bflag; /* set input block size */
20: extern int dflag; /* print out debugging info */
21: extern int hflag; /* restore heirarchies */
22: extern int mflag; /* restore by name instead of inode number */
23: extern int vflag; /* print out actions taken */
24: extern int yflag; /* always try to recover from tape errors */
25: /*
26: * Global variables
27: */
28: extern char *dumpmap; /* map of inodes on this dump tape */
29: extern char *clrimap; /* map of inodes to be deleted */
30: extern ino_t maxino; /* highest numbered inode in this file system */
31: extern long dumpnum; /* location of the dump on this tape */
32: extern long volno; /* current volume being read */
33: extern long ntrec; /* number of TP_BSIZE records per tape block */
34: extern time_t dumptime; /* time that this dump begins */
35: extern time_t dumpdate; /* time that this dump was made */
36: extern char command; /* opration being performed */
37: extern FILE *terminal; /* file descriptor for the terminal input */
38:
39: /*
40: * Each file in the file system is described by one of these entries
41: */
42: struct entry {
43: char *e_name; /* the current name of this entry */
44: u_char e_namlen; /* length of this name */
45: char e_type; /* type of this entry, see below */
46: short e_flags; /* status flags, see below */
47: ino_t e_ino; /* inode number in previous file sys */
48: long e_index; /* unique index (for dumpped table) */
49: struct entry *e_parent; /* pointer to parent directory (..) */
50: struct entry *e_sibling; /* next element in this directory (.) */
51: struct entry *e_links; /* hard links to this inode */
52: struct entry *e_entries; /* for directories, their entries */
53: struct entry *e_next; /* hash chain list */
54: };
55: /* types */
56: #define LEAF 1 /* non-directory entry */
57: #define NODE 2 /* directory entry */
58: #define LINK 4 /* synthesized type, stripped by addentry */
59: /* flags */
60: #define 0x0001 /* entry is to be replaced from the tape */
61: #define NEW 0x0002 /* a new entry to be extracted */
62: #define KEEP 0x0004 /* entry is not to change */
63: #define REMOVED 0x0010 /* entry has been removed */
64: #define TMPNAME 0x0020 /* entry has been given a temporary name */
65: #define EXISTED 0x0040 /* directory already existed during extract */
66: /*
67: * functions defined on entry structs
68: */
69: extern struct entry *lookupino();
70: extern struct entry *lookupname();
71: extern struct entry *lookupparent();
72: extern struct entry *addentry();
73: extern char *myname();
74: extern char *savename();
75: extern char *gentempname();
76: extern char *flagvalues();
77: extern ino_t lowerbnd();
78: extern ino_t upperbnd();
79: extern DIR *rst_opendir();
80: extern struct direct *rst_readdir();
81: #define NIL ((struct entry *)(0))
82: /*
83: * Constants associated with entry structs
84: */
85: #define HARDLINK 1
86: #define SYMLINK 2
87: #define TMPHDR "RSTTMP"
88:
89: /*
90: * The entry describes the next file available on the tape
91: */
92: struct context {
93: char *name; /* name of file */
94: ino_t ino; /* inumber of file */
95: struct dinode *dip; /* pointer to inode */
96: char action; /* action being taken on this file */
97: } curfile;
98: /* actions */
99: #define USING 1 /* extracting from the tape */
100: #define SKIP 2 /* skipping */
101: #define UNKNOWN 3 /* disposition or starting point is unknown */
102:
103: /*
104: * Other exported routines
105: */
106: extern ino_t psearch();
107: extern ino_t dirlookup();
108: extern long listfile();
109: extern long deletefile();
110: extern long addfile();
111: extern long nodeupdates();
112: extern long verifyfile();
113: extern char *rindex();
114: extern char *index();
115: extern char *strcat();
116: extern char *strncat();
117: extern char *strcpy();
118: extern char *strncpy();
119: extern char *fgets();
120: extern char *mktemp();
121: extern char *malloc();
122: extern char *calloc();
123: extern char *realloc();
124: extern long lseek();
125:
126: /*
127: * Useful macros
128: */
129: #define MWORD(m,i) (m[(unsigned)(i-1)/NBBY])
130: #define MBIT(i) (1<<((unsigned)(i-1)%NBBY))
131: #define BIS(i,w) (MWORD(w,i) |= MBIT(i))
132: #define BIC(i,w) (MWORD(w,i) &= ~MBIT(i))
133: #define BIT(i,w) (MWORD(w,i) & MBIT(i))
134:
135: #define dprintf if (dflag) fprintf
136: #define vprintf if (vflag) fprintf
137:
138: #define GOOD 1
139: #define FAIL 0
Defined variables
curfile
defined in line
97; used 60 times
- in /usr/src/etc/restore/dirs.c line
103-105(3),
118,
132,
514(2),
521(2)
- in /usr/src/etc/restore/restore.c line
535,
544,
559-565(3),
606,
624-625(2),
635-638(2),
659,
671
- in /usr/src/etc/restore/symtab.c line
542
- in /usr/src/etc/restore/tape.c line
187,
197,
231,
314,
320,
360-364(5),
386,
402,
409(2),
424(2),
452,
508,
527(2),
543(2),
557,
572,
643,
651-655(2),
934-937(4),
945-958(5),
1012(2)
Defined struct's
entry
defined in line
42; used 164 times
- in line 49-53(10),
69-72(8)
- in /usr/src/etc/restore/dirs.c line
148(2),
445(2)
- in /usr/src/etc/restore/interactive.c line
48(2),
696(2)
- in /usr/src/etc/restore/restore.c line
43(2),
86(2),
110(2),
118(2),
158(2),
447(2),
494(2),
523(2),
602(2),
688(2),
718(2),
743(2)
- in /usr/src/etc/restore/symtab.c line
31(2),
37-41(4),
56-58(4),
78-79(4),
98-102(4),
125-129(4),
150(2),
171-176(4),
182-189(8),
228-230(4),
271-274(4),
300-302(4),
403-405(4),
436-452(14),
462-463(4),
489-490(4),
499-501(6),
555-558(10)
- in /usr/src/etc/restore/tape.c line
356(2)
- in /usr/src/etc/restore/utilities.c line
20(2),
44(2),
63-66(4),
96(2),
117(2),
141(2),
201(2),
220(2),
236(2),
262(2)
Defined macros
BIC
defined in line
132;
never used
BIS
defined in line
131;
never used
BIT
defined in line
133; used 10 times
defined in line
60; used 10 times
FAIL
defined in line
139; used 45 times
- in /usr/src/etc/restore/dirs.c line
164,
471,
505
- in /usr/src/etc/restore/interactive.c line
599,
665,
679,
792
- in /usr/src/etc/restore/restore.c line
23,
44,
85,
316,
384,
749-753(2)
- in /usr/src/etc/restore/tape.c line
134-137(2),
170-177(3),
189,
295-300(2),
370,
407,
422,
472,
737,
745-747(2),
792,
798-799(2),
826-827(2),
938-940(2),
961,
977,
987,
1013
- in /usr/src/etc/restore/utilities.c line
174,
183-187(2),
312-316(2)
GOOD
defined in line
138; used 31 times
- in /usr/src/etc/restore/dirs.c line
528
- in /usr/src/etc/restore/interactive.c line
686
- in /usr/src/etc/restore/restore.c line
23,
44,
85,
159,
744
- in /usr/src/etc/restore/tape.c line
375,
383,
395,
413,
429,
440-441(2),
470,
504-505(2),
738,
749,
871,
944-957(4),
978,
988,
1015
- in /usr/src/etc/restore/utilities.c line
191,
315,
329-330(2)
KEEP
defined in line
62; used 11 times
LEAF
defined in line
56; used 13 times
LINK
defined in line
58; used 8 times
MBIT
defined in line
130; used 3 times
NEW
defined in line
61; used 23 times
- in /usr/src/etc/restore/dirs.c line
467,
480
- in /usr/src/etc/restore/interactive.c line
94,
770
- in /usr/src/etc/restore/restore.c line
62,
70,
93,
286,
323,
372,
549,
568,
580,
664,
676,
698,
706,
726
- in /usr/src/etc/restore/symtab.c line
504
- in /usr/src/etc/restore/utilities.c line
35,
207,
226,
274
NIL
defined in line
81; used 84 times
- in /usr/src/etc/restore/dirs.c line
464,
474
- in /usr/src/etc/restore/interactive.c line
94,
706
- in /usr/src/etc/restore/restore.c line
60,
92,
124-128(2),
183,
196-198(2),
227,
453-455(2),
468-469(2),
501-502(2),
512,
546,
566,
661,
673,
695-697(2),
723,
747,
754-757(2)
- in /usr/src/etc/restore/symtab.c line
44-48(3),
67,
84,
107-119(4),
134-139(3),
171,
184,
190-196(3),
211,
217,
236-251(5),
257,
278,
308,
314,
422,
434,
440-449(4),
459-460(2),
501,
560,
567-573(4)
- in /usr/src/etc/restore/tape.c line
184,
380,
936
- in /usr/src/etc/restore/utilities.c line
31,
69-71(2),
123,
205,
224,
243-249(4)
NODE
defined in line
57; used 18 times
- in /usr/src/etc/restore/dirs.c line
164,
542
- in /usr/src/etc/restore/interactive.c line
779
- in /usr/src/etc/restore/restore.c line
54,
68,
284,
315,
701,
725
- in /usr/src/etc/restore/symtab.c line
140,
235,
503
- in /usr/src/etc/restore/utilities.c line
32,
100,
121,
205,
224,
252
SKIP
defined in line
100; used 5 times
USING
defined in line
99; used 5 times
dprintf
defined in line
135; used 17 times
- in /usr/src/etc/restore/dirs.c line
393,
404,
412
- in /usr/src/etc/restore/restore.c line
129,
223,
251,
287,
311,
324,
335,
373,
382,
457,
473
- in /usr/src/etc/restore/tape.c line
182,
507,
746
vprintf
defined in line
136; used 32 times
- in /usr/src/etc/restore/dirs.c line
77,
448
- in /usr/src/etc/restore/main.c line
189-193(2),
201-204(2),
212
- in /usr/src/etc/restore/restore.c line
28,
48,
121,
450,
497,
528-530(2),
605,
692,
721
- in /usr/src/etc/restore/symtab.c line
410,
496
- in /usr/src/etc/restore/tape.c line
117,
373,
385,
393,
401,
416,
711,
794
- in /usr/src/etc/restore/utilities.c line
89,
110,
134,
156,
189
Usage of this include