xref: /original-bsd/sbin/dump/dump.h (revision 89214f7d)
1 /*
2  * Copyright (c) 1980 Regents of the University of California.
3  * All rights reserved.  The Berkeley software License Agreement
4  * specifies the terms and conditions for redistribution.
5  *
6  *	@(#)dump.h	5.9 (Berkeley) 02/23/91
7  */
8 
9 #define	NI		16
10 #define MAXINOPB	(MAXBSIZE / sizeof(struct dinode))
11 #define MAXNINDIR	(MAXBSIZE / sizeof(daddr_t))
12 
13 #include <sys/param.h>
14 #include <sys/stat.h>
15 #include <sys/time.h>
16 #include <ufs/fs.h>
17 #include <ufs/dinode.h>
18 #include <ufs/dir.h>
19 #include <protocols/dumprestore.h>
20 #include <utmp.h>
21 #include <signal.h>
22 #include <fstab.h>
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <ctype.h>
27 
28 #define	MWORD(m,i)	(m[(unsigned)(i-1)/NBBY])
29 #define	MBIT(i)		(1<<((unsigned)(i-1)%NBBY))
30 #define	BIS(i,w)	(MWORD(w,i) |=  MBIT(i))
31 #define	BIC(i,w)	(MWORD(w,i) &= ~MBIT(i))
32 #define	BIT(i,w)	(MWORD(w,i) & MBIT(i))
33 
34 int	msiz;
35 char	*clrmap;
36 char	*dirmap;
37 char	*nodmap;
38 
39 /*
40  *	All calculations done in 0.1" units!
41  */
42 
43 char	*disk;		/* name of the disk file */
44 char	*tape;		/* name of the tape file */
45 char	*increm;	/* name of the file containing incremental information*/
46 char	*temp;		/* name of the file for doing rewrite of increm */
47 char	lastincno;	/* increment number of previous dump */
48 char	incno;		/* increment number */
49 int	uflag;		/* update flag */
50 int	fi;		/* disk file descriptor */
51 int	to;		/* tape file descriptor */
52 int	pipeout;	/* true => output to standard output */
53 ino_t	ino;		/* current inumber; used globally */
54 int	nsubdir;
55 int	newtape;	/* new tape flag */
56 int	nadded;		/* number of added sub directories */
57 int	dadded;		/* directory added flag */
58 int	density;	/* density in 0.1" units */
59 long	tsize;		/* tape size in 0.1" units */
60 long	esize;		/* estimated tape size, blocks */
61 long	asize;		/* number of 0.1" units written on current tape */
62 int	etapes;		/* estimated number of tapes */
63 
64 int	notify;		/* notify operator flag */
65 int	blockswritten;	/* number of blocks written on current tape */
66 int	tapeno;		/* current tape number */
67 time_t	tstart_writing;	/* when started writing the first tape block */
68 char	*processname;
69 struct fs *sblock;	/* the file system super block */
70 char	buf[MAXBSIZE];
71 long	dev_bsize;	/* block size of underlying disk device */
72 int	dev_bshift;	/* log2(dev_bsize) */
73 int	tp_bshift;	/* log2(TP_BSIZE) */
74 
75 /* operator interface functions */
76 void	broadcast();
77 void	lastdump();
78 void	msg();
79 void	msgtail();
80 int	query();
81 void	set_operators();
82 void	timeest();
83 
84 /* mapping rouintes */
85 void	est();
86 void	bmapest();
87 void	pass();
88 void	mark();
89 void	add();
90 
91 /* file dumping routines */
92 void	dirdump();
93 void	dump();
94 void	blksout();
95 void	bitmap();
96 void	spclrec();
97 void	bread();
98 
99 /* tape writing routines */
100 int	alloctape();
101 void	taprec();
102 void	dmpblk();
103 void	tflush();
104 void	trewind();
105 void	close_rewind();
106 void	otape();
107 
108 void	dumpabort();
109 void	Exit();
110 void	getfstab();
111 void	quit();
112 
113 char	*prdate();
114 char	*rawname();
115 struct dinode *getino();
116 
117 void	interrupt();		/* in case operator bangs on console */
118 
119 #define	HOUR	(60L*60L)
120 #define	DAY	(24L*HOUR)
121 #define	YEAR	(365L*DAY)
122 
123 /*
124  *	Exit status codes
125  */
126 #define	X_FINOK		0	/* normal exit */
127 #define	X_REWRITE	2	/* restart writing from the check point */
128 #define	X_ABORT		3	/* abort all of dump; don't attempt checkpointing*/
129 
130 #define	OPGRENT	"operator"		/* group entry to notify */
131 #define DIALUP	"ttyd"			/* prefix for dialups */
132 
133 struct	fstab	*fstabsearch();	/* search in fs_file and fs_spec */
134 
135 /*
136  *	The contents of the file _PATH_DUMPDATES is maintained both on
137  *	a linked list, and then (eventually) arrayified.
138  */
139 struct	idates {
140 	char	id_name[MAXNAMLEN+3];
141 	char	id_incno;
142 	time_t	id_ddate;
143 };
144 struct	itime {
145 	struct	idates	it_value;
146 	struct	itime	*it_next;
147 };
148 struct	itime	*ithead;	/* head of the list version */
149 int	nidates;		/* number of records (might be zero) */
150 int	idates_in;		/* we have read the increment file */
151 struct	idates	**idatev;	/* the arrayfied version */
152 void	inititimes();
153 void	getitime();
154 void	putitime();
155 #define	ITITERATE(i, ip) for (ip = idatev[i = 0]; i < nidates; ip = idatev[++i])
156 
157 /*
158  *	We catch these interrupts
159  */
160 void	sighup();
161 void	sigquit();
162 void	sigill();
163 void	sigtrap();
164 void	sigfpe();
165 void	sigkill();
166 void	sigbus();
167 void	sigsegv();
168 void	sigsys();
169 void	sigalrm();
170 void	sigterm();
171