Commit | Line | Data |
---|---|---|
e0519353 KM |
1 | /* Copyright (c) 1983 Regents of the University of California */ |
2 | ||
3 | /* @(#)restore.h 3.3 (Berkeley) 83/01/16 */ | |
4 | ||
5 | #include <stdio.h> | |
6 | #include <sys/param.h> | |
7 | #include <sys/inode.h> | |
8 | #include <sys/fs.h> | |
9 | ||
10 | /* | |
11 | * Flags | |
12 | */ | |
13 | extern int cvtflag; /* convert from old to new tape format */ | |
14 | extern int dflag; /* print out debugging info */ | |
15 | extern int hflag; /* restore heirarchies */ | |
16 | extern int mflag; /* restore by name instead of inode number */ | |
17 | extern int vflag; /* print out actions taken */ | |
18 | extern int yflag; /* always try to recover from tape errors */ | |
19 | /* | |
20 | * Global variables | |
21 | */ | |
22 | extern char *dumpmap; /* map of inodes on this dump tape */ | |
23 | extern char *clrimap; /* map of inodes to be deleted */ | |
24 | extern ino_t maxino; /* highest numbered inode in this file system */ | |
25 | extern long dumpnum; /* location of the dump on this tape */ | |
26 | extern long volno; /* current volume being read */ | |
27 | extern time_t dumptime; /* time that this dump begins */ | |
28 | extern time_t dumpdate; /* time that this dump was made */ | |
29 | extern char command; /* opration being performed */ | |
30 | ||
31 | /* | |
32 | * Each file in the file system is described by one of these entries | |
33 | */ | |
34 | struct entry { | |
35 | char *e_name; /* the current name of this entry */ | |
36 | u_char e_namlen; /* length of this name */ | |
37 | char e_type; /* type of this entry, see below */ | |
38 | short e_flags; /* status flags, see below */ | |
39 | ino_t e_ino; /* inode number in previous file sys */ | |
40 | long e_index; /* unique index (for dumpped table) */ | |
41 | struct entry *e_parent; /* pointer to parent directory (..) */ | |
42 | struct entry *e_sibling; /* next element in this directory (.) */ | |
43 | struct entry *e_links; /* hard links to this inode */ | |
44 | struct entry *e_entries; /* for directories, their entries */ | |
45 | struct entry *e_next; /* hash chain list */ | |
46 | }; | |
47 | /* types */ | |
48 | #define LEAF 1 /* non-directory entry */ | |
49 | #define NODE 2 /* directory entry */ | |
50 | #define LINK 4 /* synthesized type, stripped by addentry */ | |
51 | /* flags */ | |
52 | #define EXTRACT 0x0001 /* entry is to be replaced from the tape */ | |
53 | #define NEW 0x0002 /* a new entry to be extracted */ | |
54 | #define KEEP 0x0004 /* entry is not to change */ | |
55 | #define REMOVED 0x0010 /* entry has been removed */ | |
56 | #define TMPNAME 0x0020 /* entry has been given a temporary name */ | |
57 | /* | |
58 | * functions defined on entry structs | |
59 | */ | |
60 | extern struct entry *lookupino(); | |
61 | extern struct entry *lookupname(); | |
62 | extern struct entry *lookupparent(); | |
63 | extern struct entry *addentry(); | |
64 | extern char *myname(); | |
65 | extern char *savename(); | |
66 | extern ino_t lowerbnd(); | |
67 | extern ino_t upperbnd(); | |
68 | #define NIL ((struct entry *)(0)) | |
69 | /* | |
70 | * Constants associated with entry structs | |
71 | */ | |
72 | #define HARDLINK 1 | |
73 | #define SYMLINK 2 | |
74 | #define TMPCHAR (0x01) | |
75 | ||
76 | /* | |
77 | * The entry describes the next file available on the tape | |
78 | */ | |
79 | struct context { | |
80 | char *name; /* name of file */ | |
81 | ino_t ino; /* inumber of file */ | |
82 | struct dinode *dip; /* pointer to inode */ | |
83 | char action; /* action being taken on this file */ | |
84 | } curfile; | |
85 | /* actions */ | |
86 | #define USING 1 /* extracting from the tape */ | |
87 | #define SKIP 2 /* skipping */ | |
88 | #define UNKNOWN 3 /* disposition or starting point is unknown */ | |
89 | ||
90 | /* | |
91 | * Other exported routines | |
92 | */ | |
93 | extern ino_t psearch(); | |
94 | extern void listfile(); | |
95 | extern void addfile(); | |
96 | extern void nodeupdates(); | |
97 | extern void verifyfile(); | |
98 | extern char *rindex(); | |
99 | extern char *index(); | |
100 | extern char *strcat(); | |
101 | extern char *strcpy(); | |
102 | extern char *mktemp(); | |
103 | extern char *malloc(); | |
104 | extern char *calloc(); | |
105 | extern long lseek(); | |
106 | ||
107 | /* | |
108 | * Useful macros | |
109 | */ | |
110 | #define MWORD(m,i) (m[(unsigned)(i-1)/NBBY]) | |
111 | #define MBIT(i) (1<<((unsigned)(i-1)%NBBY)) | |
112 | #define BIS(i,w) (MWORD(w,i) |= MBIT(i)) | |
113 | #define BIC(i,w) (MWORD(w,i) &= ~MBIT(i)) | |
114 | #define BIT(i,w) (MWORD(w,i) & MBIT(i)) | |
115 | ||
116 | #define dprintf if (dflag) fprintf | |
117 | #define vprintf if (vflag) fprintf | |
118 | ||
119 | #define GOOD 1 | |
120 | #define FAIL 0 |