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