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