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