]>
Commit | Line | Data |
---|---|---|
1227625a SP |
1 | /* |
2 | * Ported to Linux's Second Extended File System as part of the | |
3 | * dump and restore backup suit | |
b45f51d6 | 4 | * Remy Card <card@Linux.EU.Org>, 1994-1997 |
ebcbe7f6 | 5 | * Stelian Pop <pop@cybercable.fr>, 1999-2000 |
1227625a | 6 | * |
d3393043 | 7 | * $Id: dump.h,v 1.11 2000/02/26 01:35:48 stelian Exp $ |
1227625a SP |
8 | */ |
9 | ||
10 | /*- | |
11 | * Copyright (c) 1980, 1993 | |
12 | * The Regents of the University of California. All rights reserved. | |
13 | * | |
14 | * Redistribution and use in source and binary forms, with or without | |
15 | * modification, are permitted provided that the following conditions | |
16 | * are met: | |
17 | * 1. Redistributions of source code must retain the above copyright | |
18 | * notice, this list of conditions and the following disclaimer. | |
19 | * 2. Redistributions in binary form must reproduce the above copyright | |
20 | * notice, this list of conditions and the following disclaimer in the | |
21 | * documentation and/or other materials provided with the distribution. | |
22 | * 3. All advertising materials mentioning features or use of this software | |
23 | * must display the following acknowledgement: | |
24 | * This product includes software developed by the University of | |
25 | * California, Berkeley and its contributors. | |
26 | * 4. Neither the name of the University nor the names of its contributors | |
27 | * may be used to endorse or promote products derived from this software | |
28 | * without specific prior written permission. | |
29 | * | |
30 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
31 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
32 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
33 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
34 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
35 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
36 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
37 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
38 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
39 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
40 | * SUCH DAMAGE. | |
1227625a SP |
41 | */ |
42 | ||
43 | #define MAXINOPB (MAXBSIZE / sizeof(struct dinode)) | |
44 | #define MAXNINDIR (MAXBSIZE / sizeof(daddr_t)) | |
45 | ||
d1c73b9a SP |
46 | #ifndef NAME_MAX |
47 | #define NAME_MAX 255 | |
48 | #endif | |
49 | ||
1227625a SP |
50 | /* |
51 | * Dump maps used to describe what is to be dumped. | |
52 | */ | |
53 | int mapsize; /* size of the state maps */ | |
54 | char *usedinomap; /* map of allocated inodes */ | |
55 | char *dumpdirmap; /* map of directories to be dumped */ | |
56 | char *dumpinomap; /* map of files to be dumped */ | |
57 | /* | |
58 | * Map manipulation macros. | |
59 | */ | |
60 | #define SETINO(ino, map) \ | |
61 | map[(u_int)((ino) - 1) / NBBY] |= 1 << ((u_int)((ino) - 1) % NBBY) | |
62 | #define CLRINO(ino, map) \ | |
63 | map[(u_int)((ino) - 1) / NBBY] &= ~(1 << ((u_int)((ino) - 1) % NBBY)) | |
64 | #define TSTINO(ino, map) \ | |
65 | (map[(u_int)((ino) - 1) / NBBY] & (1 << ((u_int)((ino) - 1) % NBBY))) | |
66 | ||
67 | /* | |
68 | * All calculations done in 0.1" units! | |
69 | */ | |
70 | char *disk; /* name of the disk file */ | |
d1c73b9a SP |
71 | char tape[NAME_MAX]; /* name of the tape file */ |
72 | char *tapeprefix; /* prefix of the tape file */ | |
1227625a | 73 | char *dumpdates; /* name of the file containing dump date information*/ |
1227625a SP |
74 | char lastlevel; /* dump level of previous dump */ |
75 | char level; /* dump level of this dump */ | |
76 | int uflag; /* update flag */ | |
d1c73b9a | 77 | int Mflag; /* multi-volume flag */ |
1227625a SP |
78 | int diskfd; /* disk file descriptor */ |
79 | int tapefd; /* tape file descriptor */ | |
80 | int pipeout; /* true => output to standard output */ | |
81 | ino_t curino; /* current inumber; used globally */ | |
82 | int newtape; /* new tape flag */ | |
83 | int density; /* density in 0.1" units */ | |
84 | long tapesize; /* estimated tape size, blocks */ | |
85 | long tsize; /* tape size in 0.1" units */ | |
86 | long asize; /* number of 0.1" units written on current tape */ | |
87 | int etapes; /* estimated number of tapes */ | |
88 | int nonodump; /* if set, do not honor UF_NODUMP user flags */ | |
b45f51d6 | 89 | int unlimited; /* if set, write to end of medium */ |
1227625a SP |
90 | |
91 | int notify; /* notify operator flag */ | |
92 | int blockswritten; /* number of blocks written on current tape */ | |
93 | int tapeno; /* current tape number */ | |
94 | time_t tstart_writing; /* when started writing the first tape block */ | |
b45f51d6 | 95 | time_t tend_writing; /* after writing the last tape block */ |
1227625a | 96 | #ifdef __linux__ |
1227625a SP |
97 | ext2_filsys fs; |
98 | #else | |
99 | struct fs *sblock; /* the file system super block */ | |
100 | char sblock_buf[MAXBSIZE]; | |
101 | #endif | |
ddd2ef55 | 102 | long xferrate; /* averaged transfer rate of all volumes */ |
1227625a SP |
103 | long dev_bsize; /* block size of underlying disk device */ |
104 | int dev_bshift; /* log2(dev_bsize) */ | |
105 | int tp_bshift; /* log2(TP_BSIZE) */ | |
106 | ||
107 | #ifndef __P | |
108 | #include <sys/cdefs.h> | |
109 | #endif | |
110 | ||
111 | /* operator interface functions */ | |
ddd2ef55 SP |
112 | void broadcast __P((const char *message)); |
113 | time_t do_stats __P((void)); | |
114 | void lastdump __P((char arg)); | |
1227625a SP |
115 | void msg __P((const char *fmt, ...)); |
116 | void msgtail __P((const char *fmt, ...)); | |
ddd2ef55 | 117 | int query __P((const char *question)); |
1227625a SP |
118 | void quit __P((const char *fmt, ...)); |
119 | void set_operators __P((void)); | |
ddd2ef55 SP |
120 | #if defined(SIGINFO) |
121 | void statussig __P((int signo)); | |
122 | #endif | |
1227625a | 123 | void timeest __P((void)); |
ddd2ef55 | 124 | time_t unctime __P((const char *str)); |
1227625a SP |
125 | |
126 | /* mapping rouintes */ | |
127 | struct dinode; | |
128 | long blockest __P((struct dinode *dp)); | |
129 | int mapfiles __P((ino_t maxino, long *tapesize)); | |
130 | #ifdef __linux__ | |
131 | int mapfilesfromdir __P((ino_t maxino, long *tapesize, char *directory)); | |
132 | #endif | |
133 | int mapdirs __P((ino_t maxino, long *tapesize)); | |
134 | ||
135 | /* file dumping routines */ | |
136 | void blksout __P((daddr_t *blkp, int frags, ino_t ino)); | |
b45f51d6 | 137 | void bread __P((daddr_t blkno, char *buf, int size)); |
1227625a SP |
138 | void dumpino __P((struct dinode *dp, ino_t ino)); |
139 | #ifdef __linux__ | |
140 | void dumpdirino __P((struct dinode *dp, ino_t ino)); | |
141 | #endif | |
142 | void dumpmap __P((char *map, int type, ino_t ino)); | |
143 | void writeheader __P((ino_t ino)); | |
144 | ||
145 | /* tape writing routines */ | |
146 | int alloctape __P((void)); | |
147 | void close_rewind __P((void)); | |
148 | void dumpblock __P((daddr_t blkno, int size)); | |
149 | void startnewtape __P((int top)); | |
150 | void trewind __P((void)); | |
ddd2ef55 | 151 | void writerec __P((const void *dp, int isspcl)); |
1227625a | 152 | |
ddd2ef55 | 153 | void Exit __P((int status)); |
1227625a SP |
154 | void dumpabort __P((int signo)); |
155 | void getfstab __P((void)); | |
156 | ||
157 | char *rawname __P((char *cp)); | |
158 | struct dinode *getino __P((ino_t inum)); | |
159 | ||
160 | /* rdump routines */ | |
161 | #ifdef RDUMP | |
ddd2ef55 SP |
162 | int rmthost __P((const char *host)); |
163 | int rmtopen __P((const char *tape, int mode)); | |
1227625a | 164 | void rmtclose __P((void)); |
ddd2ef55 SP |
165 | int rmtread __P((char *buf, size_t count)); |
166 | int rmtwrite __P((const char *buf, size_t count)); | |
167 | int rmtseek __P((int offset, int pos)); | |
168 | struct mtget * rmtstatus __P((void)); | |
169 | int rmtioctl __P((int cmd, int count)); | |
1227625a SP |
170 | #endif /* RDUMP */ |
171 | ||
172 | void interrupt __P((int signo)); /* in case operator bangs on console */ | |
173 | ||
174 | /* | |
175 | * Exit status codes | |
176 | */ | |
177 | #define X_FINOK 0 /* normal exit */ | |
ddd2ef55 | 178 | #define X_STARTUP 1 /* startup error */ |
1227625a SP |
179 | #define X_REWRITE 2 /* restart writing from the check point */ |
180 | #define X_ABORT 3 /* abort dump; don't attempt checkpointing */ | |
181 | ||
182 | #define OPGRENT "operator" /* group entry to notify */ | |
183 | #ifdef __linux__ | |
184 | #define DIALUP "ttyS" /* prefix for dialups */ | |
185 | #else | |
186 | #define DIALUP "ttyd" /* prefix for dialups */ | |
187 | #endif | |
188 | ||
ddd2ef55 | 189 | struct fstab *fstabsearch __P((const char *key)); /* search fs_file and fs_spec */ |
1227625a | 190 | #ifdef __linux__ |
ddd2ef55 | 191 | struct fstab *fstabsearchdir __P((const char *key, char *dir)); /* search fs_file and fs_spec */ |
1227625a SP |
192 | #endif |
193 | ||
1227625a SP |
194 | /* |
195 | * The contents of the file _PATH_DUMPDATES is maintained both on | |
196 | * a linked list, and then (eventually) arrayified. | |
197 | */ | |
198 | struct dumpdates { | |
199 | char dd_name[NAME_MAX+3]; | |
200 | char dd_level; | |
201 | time_t dd_ddate; | |
202 | }; | |
203 | struct dumptime { | |
204 | struct dumpdates dt_value; | |
205 | struct dumptime *dt_next; | |
206 | }; | |
207 | struct dumptime *dthead; /* head of the list version */ | |
208 | int nddates; /* number of records (might be zero) */ | |
209 | int ddates_in; /* we have read the increment file */ | |
210 | struct dumpdates **ddatev; /* the arrayfied version */ | |
8d4197bb SP |
211 | void initdumptimes __P((int)); |
212 | void getdumptime __P((int)); | |
1227625a SP |
213 | void putdumptime __P((void)); |
214 | #define ITITERATE(i, ddp) \ | |
215 | for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i]) | |
216 | ||
217 | void sig __P((int signo)); | |
218 | ||
219 | /* | |
220 | * Compatibility with old systems. | |
221 | */ | |
222 | #ifdef COMPAT | |
223 | #include <sys/file.h> | |
224 | #define strchr(a,b) index(a,b) | |
225 | #define strrchr(a,b) rindex(a,b) | |
226 | extern char *strdup(), *ctime(); | |
227 | extern int read(), write(); | |
228 | extern int errno; | |
229 | #endif | |
230 | ||
231 | #ifdef __linux__ | |
8d4197bb | 232 | #define DUMP_CURRENT_REV 1 |
c930abff SP |
233 | |
234 | int dump_fs_open(const char *disk, ext2_filsys *fs); | |
1227625a SP |
235 | #endif |
236 | ||
237 | #ifndef __linux__ | |
238 | #ifndef _PATH_UTMP | |
239 | #define _PATH_UTMP "/etc/utmp" | |
240 | #endif | |
241 | #ifndef _PATH_FSTAB | |
242 | #define _PATH_FSTAB "/etc/fstab" | |
243 | #endif | |
244 | #endif | |
245 | ||
246 | #ifdef sunos | |
247 | extern char *calloc(); | |
248 | extern char *malloc(); | |
249 | extern long atol(); | |
250 | extern char *strcpy(); | |
251 | extern char *strncpy(); | |
252 | extern char *strcat(); | |
253 | extern time_t time(); | |
254 | extern void endgrent(); | |
b45f51d6 | 255 | extern void exit(); |
1227625a SP |
256 | extern off_t lseek(); |
257 | extern const char *strerror(); | |
258 | #endif | |
20c345aa SP |
259 | |
260 | /* 04-Feb-00 ILC */ | |
261 | #define IEXCLUDE_MAXNUM 256 /* max size of inode exclude list */ | |
262 |