xref: /csrg-svn/sbin/dump/dump.h (revision 5328)
11421Sroot /*
2*5328Smckusic  * "@(#)dump.h	1.4 (Berkeley) 01/05/82"
31421Sroot  */
4*5328Smckusic #define	NI		16
5*5328Smckusic #define	DIRPB(fs)	((fs)->fs_bsize / sizeof(struct direct))
6*5328Smckusic #define	MAXDIRPB	(MAXBSIZE / sizeof(struct direct))
7*5328Smckusic #define MAXINOPB	(MAXBSIZE / sizeof(struct dinode))
8*5328Smckusic #define MAXNINDIR	(MAXBSIZE / sizeof(daddr_t))
91421Sroot 
101421Sroot #include <stdio.h>
111421Sroot #include <ctype.h>
124701Smckusic #include "../../h/param.h"
134701Smckusic #include "../../h/stat.h"
144701Smckusic #include "../../h/fs.h"
154701Smckusic #include "../../h/inode.h"
164701Smckusic #include "../../h/dir.h"
174774Smckusic #include "../../h/dumprestor.h"
181421Sroot #include <utmp.h>
191421Sroot #include <time.h>
201421Sroot #include <signal.h>
214701Smckusic int (*signal())();
221421Sroot #include <fstab.h>
231421Sroot 
24*5328Smckusic #define	MWORD(m,i)	(m[(unsigned)(i-1)/NBBY])
25*5328Smckusic #define	MBIT(i)		(1<<((unsigned)(i-1)%NBBY))
261421Sroot #define	BIS(i,w)	(MWORD(w,i) |=  MBIT(i))
271421Sroot #define	BIC(i,w)	(MWORD(w,i) &= ~MBIT(i))
281421Sroot #define	BIT(i,w)	(MWORD(w,i) & MBIT(i))
291421Sroot 
30*5328Smckusic int	msiz;
31*5328Smckusic char	*clrmap;
32*5328Smckusic char	*dirmap;
33*5328Smckusic char	*nodmap;
341421Sroot 
351421Sroot /*
361421Sroot  *	All calculations done in 0.1" units!
371421Sroot  */
381421Sroot 
391421Sroot char	*disk;		/* name of the disk file */
401421Sroot char	*tape;		/* name of the tape file */
411421Sroot char	*increm;	/* name of the file containing incremental information*/
421421Sroot char	incno;		/* increment number */
431421Sroot int	uflag;		/* update flag */
441421Sroot int	fi;		/* disk file descriptor */
451421Sroot int	to;		/* tape file descriptor */
461421Sroot ino_t	ino;		/* current inumber; used globally */
471421Sroot int	nsubdir;
481421Sroot int	newtape;	/* new tape flag */
491421Sroot int	nadded;		/* number of added sub directories */
501421Sroot int	dadded;		/* directory added flag */
511421Sroot int	density;	/* density in 0.1" units */
521421Sroot long	tsize;		/* tape size in 0.1" units */
531421Sroot long	esize;		/* estimated tape size, blocks */
541421Sroot long	asize;		/* number of 0.1" units written on current tape */
551421Sroot int	etapes;		/* estimated number of tapes */
561421Sroot 
571421Sroot int	notify;		/* notify operator flag */
581421Sroot int	blockswritten;	/* number of blocks written on current tape */
591421Sroot int	tapeno;		/* current tape number */
601421Sroot time_t	tstart_writing;	/* when started writing the first tape block */
611421Sroot char	*processname;
62*5328Smckusic struct fs *sblock;	/* the file system super block */
63*5328Smckusic char	buf[MAXBSIZE];
641421Sroot 
651421Sroot char	*ctime();
661421Sroot char	*prdate();
671421Sroot long	atol();
681421Sroot int	mark();
691421Sroot int	add();
701421Sroot int	dump();
711421Sroot int	tapsrec();
721421Sroot int	dmpspc();
731421Sroot int	dsrch();
741421Sroot int	nullf();
751421Sroot char	*getsuffix();
761421Sroot char	*rawname();
774701Smckusic struct dinode *getino();
781421Sroot 
791421Sroot int	interrupt();		/* in case operator bangs on console */
801421Sroot 
811421Sroot #define	HOUR	(60L*60L)
821421Sroot #define	DAY	(24L*HOUR)
831421Sroot #define	YEAR	(365L*DAY)
841421Sroot 
851421Sroot /*
861421Sroot  *	Exit status codes
871421Sroot  */
881421Sroot #define	X_FINOK		1	/* normal exit */
891421Sroot #define	X_REWRITE	2	/* restart writing from the check point */
901421Sroot #define	X_ABORT		3	/* abort all of dump; don't attempt checkpointing*/
911421Sroot 
921421Sroot #ifdef DEBUG
931421Sroot #define	OINCREM	"./ddate"		/*old format incremental info*/
941421Sroot #define	NINCREM	"./dumpdates"		/*new format incremental info*/
951421Sroot #else not DEBUG
961421Sroot #define	OINCREM	"/etc/ddate"		/*old format incremental info*/
971421Sroot #define	NINCREM	"/etc/dumpdates"	/*new format incremental info*/
981421Sroot #endif
991421Sroot 
1001421Sroot #define	TAPE	"/dev/rmt8"		/* default tape device */
1011421Sroot #define	DISK	"/dev/rrp1g"		/* default disk */
1021421Sroot #define	OPGRENT	"operator"		/* group entry to notify */
1031421Sroot #define DIALUP	"ttyd"			/* prefix for dialups */
1041421Sroot 
1051421Sroot #define	MAXFSTAB		32
1061421Sroot struct	fstab	fstab[MAXFSTAB];
1071421Sroot struct	fstab	*fstabsearch();	/* search in fs_file and fs_spec */
1081421Sroot int	nfstab;
1091421Sroot 
1101421Sroot /*
1111421Sroot  *	The contents of the file NINCREM is maintained both on
1121421Sroot  *	a linked list, and then (eventually) arrayified.
1131421Sroot  */
1141421Sroot struct	itime{
1151421Sroot 	struct	idates	it_value;
1161421Sroot 	struct	itime	*it_next;
1171421Sroot };
1181421Sroot struct	itime	*ithead;	/* head of the list version */
1191421Sroot int	nidates;		/* number of records (might be zero) */
1201421Sroot int	idates_in;		/* we have read the increment file */
1211421Sroot struct	idates	**idatev;	/* the arrayfied version */
1221421Sroot #define	ITITERATE(i, ip) for (i = 0,ip = idatev[0]; i < nidates; i++, ip = idatev[i])
1231421Sroot 
1241421Sroot /*
1251421Sroot  *	We catch these interrupts
1261421Sroot  */
1271421Sroot int	sighup();
1281421Sroot int	sigquit();
1291421Sroot int	sigill();
1301421Sroot int	sigtrap();
1311421Sroot int	sigfpe();
1321421Sroot int	sigkill();
1331421Sroot int	sigbus();
1341421Sroot int	sigsegv();
1351421Sroot int	sigsys();
1361421Sroot int	sigalrm();
1371421Sroot int	sigterm();
138