]> git.wh0rd.org - dump.git/blame - dump/dump.h
Initial revision
[dump.git] / dump / dump.h
CommitLineData
1227625a
SP
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 */
49int mapsize; /* size of the state maps */
50char *usedinomap; /* map of allocated inodes */
51char *dumpdirmap; /* map of directories to be dumped */
52char *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 */
66char *disk; /* name of the disk file */
67char *tape; /* name of the tape file */
68char *dumpdates; /* name of the file containing dump date information*/
69char *temp; /* name of the file for doing rewrite of dumpdates */
70char lastlevel; /* dump level of previous dump */
71char level; /* dump level of this dump */
72int uflag; /* update flag */
73int diskfd; /* disk file descriptor */
74int tapefd; /* tape file descriptor */
75int pipeout; /* true => output to standard output */
76ino_t curino; /* current inumber; used globally */
77int newtape; /* new tape flag */
78int density; /* density in 0.1" units */
79long tapesize; /* estimated tape size, blocks */
80long tsize; /* tape size in 0.1" units */
81long asize; /* number of 0.1" units written on current tape */
82int etapes; /* estimated number of tapes */
83int nonodump; /* if set, do not honor UF_NODUMP user flags */
84
85int notify; /* notify operator flag */
86int blockswritten; /* number of blocks written on current tape */
87int tapeno; /* current tape number */
88time_t tstart_writing; /* when started writing the first tape block */
89#ifdef __linux__
90time_t tend_writing; /* after writing the last tape block */
91ext2_filsys fs;
92#else
93struct fs *sblock; /* the file system super block */
94char sblock_buf[MAXBSIZE];
95#endif
96long dev_bsize; /* block size of underlying disk device */
97int dev_bshift; /* log2(dev_bsize) */
98int tp_bshift; /* log2(TP_BSIZE) */
99
100#ifndef __P
101#include <sys/cdefs.h>
102#endif
103
104/* operator interface functions */
105void broadcast __P((char *message));
106void lastdump __P((int arg)); /* int should be char */
107void msg __P((const char *fmt, ...));
108void msgtail __P((const char *fmt, ...));
109int query __P((char *question));
110void quit __P((const char *fmt, ...));
111void set_operators __P((void));
112void timeest __P((void));
113time_t unctime __P((char *str));
114
115/* mapping rouintes */
116struct dinode;
117long blockest __P((struct dinode *dp));
118int mapfiles __P((ino_t maxino, long *tapesize));
119#ifdef __linux__
120int mapfilesfromdir __P((ino_t maxino, long *tapesize, char *directory));
121#endif
122int mapdirs __P((ino_t maxino, long *tapesize));
123
124/* file dumping routines */
125void blksout __P((daddr_t *blkp, int frags, ino_t ino));
126void bread __P((daddr_t blkno, char *buf, int size));
127void dumpino __P((struct dinode *dp, ino_t ino));
128#ifdef __linux__
129void dumpdirino __P((struct dinode *dp, ino_t ino));
130#endif
131void dumpmap __P((char *map, int type, ino_t ino));
132void writeheader __P((ino_t ino));
133
134/* tape writing routines */
135int alloctape __P((void));
136void close_rewind __P((void));
137void dumpblock __P((daddr_t blkno, int size));
138void startnewtape __P((int top));
139void trewind __P((void));
140void writerec __P((char *dp, int isspcl));
141
142__dead void Exit __P((int status));
143void dumpabort __P((int signo));
144void getfstab __P((void));
145
146char *rawname __P((char *cp));
147struct dinode *getino __P((ino_t inum));
148
149/* rdump routines */
150#ifdef RDUMP
151void rmtclose __P((void));
152int rmthost __P((char *host));
153int rmtopen __P((char *tape, int mode));
154int rmtwrite __P((char *buf, int count));
155#endif /* RDUMP */
156
157void 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
173struct fstab *fstabsearch __P((char *key)); /* search fs_file and fs_spec */
174#ifdef __linux__
175struct 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 */
186struct dumpdates {
187 char dd_name[NAME_MAX+3];
188 char dd_level;
189 time_t dd_ddate;
190};
191struct dumptime {
192 struct dumpdates dt_value;
193 struct dumptime *dt_next;
194};
195struct dumptime *dthead; /* head of the list version */
196int nddates; /* number of records (might be zero) */
197int ddates_in; /* we have read the increment file */
198struct dumpdates **ddatev; /* the arrayfied version */
199void initdumptimes __P((void));
200void getdumptime __P((void));
201void putdumptime __P((void));
202#define ITITERATE(i, ddp) \
203 for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i])
204
205void 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)
214extern char *strdup(), *ctime();
215extern int read(), write();
216extern 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
233extern char *calloc();
234extern char *malloc();
235extern long atol();
236extern char *strcpy();
237extern char *strncpy();
238extern char *strcat();
239extern time_t time();
240extern void endgrent();
241extern __dead void exit();
242extern off_t lseek();
243extern const char *strerror();
244#endif