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