Commit | Line | Data |
---|---|---|
e0519353 KM |
1 | /* Copyright (c) 1983 Regents of the University of California */ |
2 | ||
7432ff81 | 3 | /* @(#)restore.h 3.7 (Berkeley) 83/04/19 */ |
e0519353 KM |
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 */ | |
2cb5dabb KM |
27 | extern time_t dumptime; /* time that this dump begins */ |
28 | extern time_t dumpdate; /* time that this dump was made */ | |
e0519353 | 29 | extern char command; /* opration being performed */ |
7432ff81 | 30 | extern FILE *terminal; /* file descriptor for the terminal input */ |
e0519353 KM |
31 | |
32 | /* | |
33 | * Each file in the file system is described by one of these entries | |
34 | */ | |
35 | struct entry { | |
36 | char *e_name; /* the current name of this entry */ | |
37 | u_char e_namlen; /* length of this name */ | |
38 | char e_type; /* type of this entry, see below */ | |
39 | short e_flags; /* status flags, see below */ | |
40 | ino_t e_ino; /* inode number in previous file sys */ | |
16e2b8d5 | 41 | long e_index; /* unique index (for dumpped table) */ |
e0519353 KM |
42 | struct entry *e_parent; /* pointer to parent directory (..) */ |
43 | struct entry *e_sibling; /* next element in this directory (.) */ | |
44 | struct entry *e_links; /* hard links to this inode */ | |
45 | struct entry *e_entries; /* for directories, their entries */ | |
16e2b8d5 | 46 | struct entry *e_next; /* hash chain list */ |
e0519353 KM |
47 | }; |
48 | /* types */ | |
49 | #define LEAF 1 /* non-directory entry */ | |
50 | #define NODE 2 /* directory entry */ | |
51 | #define LINK 4 /* synthesized type, stripped by addentry */ | |
52 | /* flags */ | |
16e2b8d5 KM |
53 | #define EXTRACT 0x0001 /* entry is to be replaced from the tape */ |
54 | #define NEW 0x0002 /* a new entry to be extracted */ | |
55 | #define KEEP 0x0004 /* entry is not to change */ | |
56 | #define REMOVED 0x0010 /* entry has been removed */ | |
57 | #define TMPNAME 0x0020 /* entry has been given a temporary name */ | |
e0519353 KM |
58 | /* |
59 | * functions defined on entry structs | |
60 | */ | |
61 | extern struct entry *lookupino(); | |
62 | extern struct entry *lookupname(); | |
63 | extern struct entry *lookupparent(); | |
64 | extern struct entry *addentry(); | |
65 | extern char *myname(); | |
66 | extern char *savename(); | |
16e2b8d5 | 67 | extern char *gentempname(); |
55f85ba7 | 68 | extern char *flagvalues(); |
e0519353 KM |
69 | extern ino_t lowerbnd(); |
70 | extern ino_t upperbnd(); | |
71 | #define NIL ((struct entry *)(0)) | |
72 | /* | |
73 | * Constants associated with entry structs | |
74 | */ | |
16e2b8d5 KM |
75 | #define HARDLINK 1 |
76 | #define SYMLINK 2 | |
77 | #define TMPHDR "RSTTMP" | |
e0519353 KM |
78 | |
79 | /* | |
80 | * The entry describes the next file available on the tape | |
81 | */ | |
82 | struct context { | |
83 | char *name; /* name of file */ | |
84 | ino_t ino; /* inumber of file */ | |
85 | struct dinode *dip; /* pointer to inode */ | |
86 | char action; /* action being taken on this file */ | |
87 | } curfile; | |
88 | /* actions */ | |
89 | #define USING 1 /* extracting from the tape */ | |
90 | #define SKIP 2 /* skipping */ | |
91 | #define UNKNOWN 3 /* disposition or starting point is unknown */ | |
92 | ||
93 | /* | |
94 | * Other exported routines | |
95 | */ | |
96 | extern ino_t psearch(); | |
7432ff81 | 97 | extern ino_t dirlookup(); |
314ac756 | 98 | extern long listfile(); |
7432ff81 | 99 | extern long deletefile(); |
314ac756 KM |
100 | extern long addfile(); |
101 | extern long nodeupdates(); | |
102 | extern long verifyfile(); | |
e0519353 KM |
103 | extern char *rindex(); |
104 | extern char *index(); | |
16e2b8d5 | 105 | extern char *strcat(); |
7432ff81 | 106 | extern char *strncat(); |
16e2b8d5 | 107 | extern char *strcpy(); |
7432ff81 KM |
108 | extern char *strncpy(); |
109 | extern char *fgets(); | |
16e2b8d5 KM |
110 | extern char *mktemp(); |
111 | extern char *malloc(); | |
112 | extern char *calloc(); | |
7432ff81 | 113 | extern char *realloc(); |
16e2b8d5 | 114 | extern long lseek(); |
e0519353 KM |
115 | |
116 | /* | |
117 | * Useful macros | |
118 | */ | |
119 | #define MWORD(m,i) (m[(unsigned)(i-1)/NBBY]) | |
120 | #define MBIT(i) (1<<((unsigned)(i-1)%NBBY)) | |
121 | #define BIS(i,w) (MWORD(w,i) |= MBIT(i)) | |
122 | #define BIC(i,w) (MWORD(w,i) &= ~MBIT(i)) | |
123 | #define BIT(i,w) (MWORD(w,i) & MBIT(i)) | |
124 | ||
125 | #define dprintf if (dflag) fprintf | |
126 | #define vprintf if (vflag) fprintf | |
127 | ||
2cb5dabb KM |
128 | #define GOOD 1 |
129 | #define FAIL 0 |