Commit | Line | Data |
---|---|---|
8c5eec2f DF |
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) %G% | |
7 | */ | |
e0519353 KM |
8 | |
9 | #include <stdio.h> | |
10 | #include <sys/param.h> | |
11 | #include <sys/inode.h> | |
12 | #include <sys/fs.h> | |
f97d7036 | 13 | #include <sys/dir.h> |
e0519353 KM |
14 | |
15 | /* | |
16 | * Flags | |
17 | */ | |
18 | extern int cvtflag; /* convert from old to new tape format */ | |
b97e998a | 19 | extern int bflag; /* set input block size */ |
e0519353 KM |
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 */ | |
19230a53 | 33 | extern long ntrec; /* number of TP_BSIZE records per tape block */ |
2cb5dabb KM |
34 | extern time_t dumptime; /* time that this dump begins */ |
35 | extern time_t dumpdate; /* time that this dump was made */ | |
e0519353 | 36 | extern char command; /* opration being performed */ |
7432ff81 | 37 | extern FILE *terminal; /* file descriptor for the terminal input */ |
e0519353 KM |
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 */ | |
16e2b8d5 | 48 | long e_index; /* unique index (for dumpped table) */ |
e0519353 KM |
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 */ | |
16e2b8d5 | 53 | struct entry *e_next; /* hash chain list */ |
e0519353 KM |
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 */ | |
16e2b8d5 KM |
60 | #define EXTRACT 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 */ | |
a7d37956 | 65 | #define EXISTED 0x0040 /* directory already existed during extract */ |
e0519353 KM |
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(); | |
16e2b8d5 | 75 | extern char *gentempname(); |
55f85ba7 | 76 | extern char *flagvalues(); |
e0519353 KM |
77 | extern ino_t lowerbnd(); |
78 | extern ino_t upperbnd(); | |
f97d7036 KM |
79 | extern DIR *rst_opendir(); |
80 | extern struct direct *rst_readdir(); | |
e0519353 KM |
81 | #define NIL ((struct entry *)(0)) |
82 | /* | |
83 | * Constants associated with entry structs | |
84 | */ | |
16e2b8d5 KM |
85 | #define HARDLINK 1 |
86 | #define SYMLINK 2 | |
87 | #define TMPHDR "RSTTMP" | |
e0519353 KM |
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(); | |
7432ff81 | 107 | extern ino_t dirlookup(); |
314ac756 | 108 | extern long listfile(); |
7432ff81 | 109 | extern long deletefile(); |
314ac756 KM |
110 | extern long addfile(); |
111 | extern long nodeupdates(); | |
112 | extern long verifyfile(); | |
e0519353 KM |
113 | extern char *rindex(); |
114 | extern char *index(); | |
16e2b8d5 | 115 | extern char *strcat(); |
7432ff81 | 116 | extern char *strncat(); |
16e2b8d5 | 117 | extern char *strcpy(); |
7432ff81 KM |
118 | extern char *strncpy(); |
119 | extern char *fgets(); | |
16e2b8d5 KM |
120 | extern char *mktemp(); |
121 | extern char *malloc(); | |
122 | extern char *calloc(); | |
7432ff81 | 123 | extern char *realloc(); |
16e2b8d5 | 124 | extern long lseek(); |
e0519353 KM |
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 | ||
2cb5dabb KM |
138 | #define GOOD 1 |
139 | #define FAIL 0 |