xref: /original-bsd/sbin/dump/dump.h (revision f0fd5f8a)
1 /*
2  * "@(#)dump.h	1.7 (Berkeley) 10/07/82"
3  */
4 #define	NI		16
5 #define MAXINOPB	(MAXBSIZE / sizeof(struct dinode))
6 #define MAXNINDIR	(MAXBSIZE / sizeof(daddr_t))
7 
8 #include <stdio.h>
9 #include <ctype.h>
10 #include <sys/param.h>
11 #include <sys/stat.h>
12 #include <sys/fs.h>
13 #include <sys/inode.h>
14 #include <dumprestor.h>
15 #include <dir.h>
16 #include <utmp.h>
17 #include <time.h>
18 #include <signal.h>
19 int (*signal())();
20 #include <fstab.h>
21 
22 #define	MWORD(m,i)	(m[(unsigned)(i-1)/NBBY])
23 #define	MBIT(i)		(1<<((unsigned)(i-1)%NBBY))
24 #define	BIS(i,w)	(MWORD(w,i) |=  MBIT(i))
25 #define	BIC(i,w)	(MWORD(w,i) &= ~MBIT(i))
26 #define	BIT(i,w)	(MWORD(w,i) & MBIT(i))
27 
28 int	msiz;
29 char	*clrmap;
30 char	*dirmap;
31 char	*nodmap;
32 
33 /*
34  *	All calculations done in 0.1" units!
35  */
36 
37 char	*disk;		/* name of the disk file */
38 char	*tape;		/* name of the tape file */
39 char	*increm;	/* name of the file containing incremental information*/
40 char	incno;		/* increment number */
41 int	uflag;		/* update flag */
42 int	fi;		/* disk file descriptor */
43 int	to;		/* tape file descriptor */
44 ino_t	ino;		/* current inumber; used globally */
45 int	nsubdir;
46 int	newtape;	/* new tape flag */
47 int	nadded;		/* number of added sub directories */
48 int	dadded;		/* directory added flag */
49 int	density;	/* density in 0.1" units */
50 long	tsize;		/* tape size in 0.1" units */
51 long	esize;		/* estimated tape size, blocks */
52 long	asize;		/* number of 0.1" units written on current tape */
53 int	etapes;		/* estimated number of tapes */
54 
55 int	notify;		/* notify operator flag */
56 int	blockswritten;	/* number of blocks written on current tape */
57 int	tapeno;		/* current tape number */
58 time_t	tstart_writing;	/* when started writing the first tape block */
59 char	*processname;
60 struct fs *sblock;	/* the file system super block */
61 char	buf[MAXBSIZE];
62 
63 char	*ctime();
64 char	*prdate();
65 long	atol();
66 int	mark();
67 int	add();
68 int	dump();
69 int	tapsrec();
70 int	dmpspc();
71 int	dsrch();
72 int	nullf();
73 char	*getsuffix();
74 char	*rawname();
75 struct dinode *getino();
76 
77 int	interrupt();		/* in case operator bangs on console */
78 
79 #define	HOUR	(60L*60L)
80 #define	DAY	(24L*HOUR)
81 #define	YEAR	(365L*DAY)
82 
83 /*
84  *	Exit status codes
85  */
86 #define	X_FINOK		1	/* normal exit */
87 #define	X_REWRITE	2	/* restart writing from the check point */
88 #define	X_ABORT		3	/* abort all of dump; don't attempt checkpointing*/
89 
90 #ifdef DEBUG
91 #define	OINCREM	"./ddate"		/*old format incremental info*/
92 #define	NINCREM	"./dumpdates"		/*new format incremental info*/
93 #else not DEBUG
94 #define	OINCREM	"/etc/ddate"		/*old format incremental info*/
95 #define	NINCREM	"/etc/dumpdates"	/*new format incremental info*/
96 #endif
97 
98 #define	TAPE	"/dev/rmt8"		/* default tape device */
99 #define	DISK	"/dev/rrp1g"		/* default disk */
100 #define	OPGRENT	"operator"		/* group entry to notify */
101 #define DIALUP	"ttyd"			/* prefix for dialups */
102 
103 #define	MAXFSTAB		32
104 struct	fstab	fstab[MAXFSTAB];
105 struct	fstab	*fstabsearch();	/* search in fs_file and fs_spec */
106 int	nfstab;
107 
108 /*
109  *	The contents of the file NINCREM is maintained both on
110  *	a linked list, and then (eventually) arrayified.
111  */
112 struct	idates {
113 	char	id_name[MAXNAMLEN+3];
114 	char	id_incno;
115 	time_t	id_ddate;
116 };
117 struct	itime{
118 	struct	idates	it_value;
119 	struct	itime	*it_next;
120 };
121 struct	itime	*ithead;	/* head of the list version */
122 int	nidates;		/* number of records (might be zero) */
123 int	idates_in;		/* we have read the increment file */
124 struct	idates	**idatev;	/* the arrayfied version */
125 #define	ITITERATE(i, ip) for (i = 0,ip = idatev[0]; i < nidates; i++, ip = idatev[i])
126 
127 /*
128  *	We catch these interrupts
129  */
130 int	sighup();
131 int	sigquit();
132 int	sigill();
133 int	sigtrap();
134 int	sigfpe();
135 int	sigkill();
136 int	sigbus();
137 int	sigsegv();
138 int	sigsys();
139 int	sigalrm();
140 int	sigterm();
141