xref: /original-bsd/sbin/dump/dump.h (revision 68549010)
1 /*-
2  * Copyright (c) 1980 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)dump.h	5.18 (Berkeley) 07/29/91
8  */
9 
10 #define MAXINOPB	(MAXBSIZE / sizeof(struct dinode))
11 #define MAXNINDIR	(MAXBSIZE / sizeof(daddr_t))
12 
13 /*
14  * Dump maps used to describe what is to be dumped.
15  */
16 int	mapsize;	/* size of the state maps */
17 char	*usedinomap;	/* map of allocated inodes */
18 char	*dumpdirmap;	/* map of directories to be dumped */
19 char	*dumpinomap;	/* map of files to be dumped */
20 /*
21  * Map manipulation macros.
22  */
23 #define	SETINO(ino, map) \
24 	map[(u_int)((ino) - 1) / NBBY] |=  1 << ((u_int)((ino) - 1) % NBBY)
25 #define	CLRINO(ino, map) \
26 	map[(u_int)((ino) - 1) / NBBY] &=  ~(1 << ((u_int)((ino) - 1) % NBBY))
27 #define	TSTINO(ino, map) \
28 	(map[(u_int)((ino) - 1) / NBBY] &  (1 << ((u_int)((ino) - 1) % NBBY)))
29 
30 /*
31  *	All calculations done in 0.1" units!
32  */
33 char	*disk;		/* name of the disk file */
34 char	*tape;		/* name of the tape file */
35 char	*dumpdates;	/* name of the file containing dump date information*/
36 char	*temp;		/* name of the file for doing rewrite of dumpdates */
37 char	lastlevel;	/* dump level of previous dump */
38 char	level;		/* dump level of this dump */
39 int	uflag;		/* update flag */
40 int	diskfd;		/* disk file descriptor */
41 int	tapefd;		/* tape file descriptor */
42 int	pipeout;	/* true => output to standard output */
43 ino_t	curino;		/* current inumber; used globally */
44 int	newtape;	/* new tape flag */
45 int	density;	/* density in 0.1" units */
46 long	tapesize;	/* estimated tape size, blocks */
47 long	tsize;		/* tape size in 0.1" units */
48 long	asize;		/* number of 0.1" units written on current tape */
49 int	etapes;		/* estimated number of tapes */
50 
51 int	notify;		/* notify operator flag */
52 int	blockswritten;	/* number of blocks written on current tape */
53 int	tapeno;		/* current tape number */
54 time_t	tstart_writing;	/* when started writing the first tape block */
55 char	*processname;
56 struct	fs *sblock;	/* the file system super block */
57 char	buf[MAXBSIZE];
58 long	dev_bsize;	/* block size of underlying disk device */
59 int	dev_bshift;	/* log2(dev_bsize) */
60 int	tp_bshift;	/* log2(TP_BSIZE) */
61 
62 /* operator interface functions */
63 void	broadcast();
64 void	lastdump();
65 #if __STDC__
66 void	msg(const char *fmt, ...);
67 void	msgtail(const char *fmt, ...);
68 void	quit(const char *fmt, ...);
69 #else
70 void	msg();
71 void	msgtail();
72 void	quit();
73 #endif
74 int	query();
75 void	set_operators();
76 void	timeest();
77 
78 /* mapping rouintes */
79 long	blockest();
80 int	mapfiles();
81 int	mapdirs();
82 
83 /* file dumping routines */
84 void	dirdump();
85 void	blksout();
86 void	dumpmap();
87 void	writeheader();
88 void	bread();
89 
90 /* tape writing routines */
91 int	alloctape();
92 void	writerec();
93 void	dumpblock();
94 void	flushtape();
95 void	trewind();
96 void	close_rewind();
97 void	startnewtape();
98 
99 void	dumpabort();
100 void	Exit();
101 void	getfstab();
102 
103 char	*rawname();
104 struct dinode *getino();
105 
106 void	interrupt();		/* in case operator bangs on console */
107 
108 /*
109  *	Exit status codes
110  */
111 #define	X_FINOK		0	/* normal exit */
112 #define	X_REWRITE	2	/* restart writing from the check point */
113 #define	X_ABORT		3	/* abort all of dump; don't attempt checkpointing*/
114 
115 #define	OPGRENT	"operator"		/* group entry to notify */
116 #define DIALUP	"ttyd"			/* prefix for dialups */
117 
118 struct	fstab	*fstabsearch();	/* search in fs_file and fs_spec */
119 
120 /*
121  *	The contents of the file _PATH_DUMPDATES is maintained both on
122  *	a linked list, and then (eventually) arrayified.
123  */
124 struct dumpdates {
125 	char	dd_name[NAME_MAX+3];
126 	char	dd_level;
127 	time_t	dd_ddate;
128 };
129 struct dumptime {
130 	struct	dumpdates dt_value;
131 	struct	dumptime *dt_next;
132 };
133 struct	dumptime *dthead;	/* head of the list version */
134 int	nddates;		/* number of records (might be zero) */
135 int	ddates_in;		/* we have read the increment file */
136 struct	dumpdates **ddatev;	/* the arrayfied version */
137 void	initdumptimes();
138 void	getdumptime();
139 void	putdumptime();
140 #define	ITITERATE(i, ddp) \
141 	for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i])
142 
143 /*
144  *	We catch these interrupts
145  */
146 void	sighup();
147 void	sigquit();
148 void	sigill();
149 void	sigtrap();
150 void	sigfpe();
151 void	sigkill();
152 void	sigbus();
153 void	sigsegv();
154 void	sigsys();
155 void	sigalrm();
156 void	sigterm();
157 
158 /*
159  * Compatibility with old systems.
160  */
161 #ifndef __STDC__
162 #include <sys/file.h>
163 #define _PATH_FSTAB	"/etc/fstab"
164 extern char *index(), *strdup();
165 extern char *ctime();
166 extern int errno;
167 #endif
168