xref: /csrg-svn/sbin/dump/dump.h (revision 8375)
11421Sroot /*
2*8375Smckusick  * "@(#)dump.h	1.7 (Berkeley) 10/07/82"
31421Sroot  */
45328Smckusic #define	NI		16
55328Smckusic #define MAXINOPB	(MAXBSIZE / sizeof(struct dinode))
65328Smckusic #define MAXNINDIR	(MAXBSIZE / sizeof(daddr_t))
71421Sroot 
81421Sroot #include <stdio.h>
91421Sroot #include <ctype.h>
106642Ssam #include <sys/param.h>
116642Ssam #include <sys/stat.h>
126642Ssam #include <sys/fs.h>
136642Ssam #include <sys/inode.h>
146642Ssam #include <dumprestor.h>
15*8375Smckusick #include <dir.h>
161421Sroot #include <utmp.h>
171421Sroot #include <time.h>
181421Sroot #include <signal.h>
194701Smckusic int (*signal())();
201421Sroot #include <fstab.h>
211421Sroot 
225328Smckusic #define	MWORD(m,i)	(m[(unsigned)(i-1)/NBBY])
235328Smckusic #define	MBIT(i)		(1<<((unsigned)(i-1)%NBBY))
241421Sroot #define	BIS(i,w)	(MWORD(w,i) |=  MBIT(i))
251421Sroot #define	BIC(i,w)	(MWORD(w,i) &= ~MBIT(i))
261421Sroot #define	BIT(i,w)	(MWORD(w,i) & MBIT(i))
271421Sroot 
285328Smckusic int	msiz;
295328Smckusic char	*clrmap;
305328Smckusic char	*dirmap;
315328Smckusic char	*nodmap;
321421Sroot 
331421Sroot /*
341421Sroot  *	All calculations done in 0.1" units!
351421Sroot  */
361421Sroot 
371421Sroot char	*disk;		/* name of the disk file */
381421Sroot char	*tape;		/* name of the tape file */
391421Sroot char	*increm;	/* name of the file containing incremental information*/
401421Sroot char	incno;		/* increment number */
411421Sroot int	uflag;		/* update flag */
421421Sroot int	fi;		/* disk file descriptor */
431421Sroot int	to;		/* tape file descriptor */
441421Sroot ino_t	ino;		/* current inumber; used globally */
451421Sroot int	nsubdir;
461421Sroot int	newtape;	/* new tape flag */
471421Sroot int	nadded;		/* number of added sub directories */
481421Sroot int	dadded;		/* directory added flag */
491421Sroot int	density;	/* density in 0.1" units */
501421Sroot long	tsize;		/* tape size in 0.1" units */
511421Sroot long	esize;		/* estimated tape size, blocks */
521421Sroot long	asize;		/* number of 0.1" units written on current tape */
531421Sroot int	etapes;		/* estimated number of tapes */
541421Sroot 
551421Sroot int	notify;		/* notify operator flag */
561421Sroot int	blockswritten;	/* number of blocks written on current tape */
571421Sroot int	tapeno;		/* current tape number */
581421Sroot time_t	tstart_writing;	/* when started writing the first tape block */
591421Sroot char	*processname;
605328Smckusic struct fs *sblock;	/* the file system super block */
615328Smckusic char	buf[MAXBSIZE];
621421Sroot 
631421Sroot char	*ctime();
641421Sroot char	*prdate();
651421Sroot long	atol();
661421Sroot int	mark();
671421Sroot int	add();
681421Sroot int	dump();
691421Sroot int	tapsrec();
701421Sroot int	dmpspc();
711421Sroot int	dsrch();
721421Sroot int	nullf();
731421Sroot char	*getsuffix();
741421Sroot char	*rawname();
754701Smckusic struct dinode *getino();
761421Sroot 
771421Sroot int	interrupt();		/* in case operator bangs on console */
781421Sroot 
791421Sroot #define	HOUR	(60L*60L)
801421Sroot #define	DAY	(24L*HOUR)
811421Sroot #define	YEAR	(365L*DAY)
821421Sroot 
831421Sroot /*
841421Sroot  *	Exit status codes
851421Sroot  */
861421Sroot #define	X_FINOK		1	/* normal exit */
871421Sroot #define	X_REWRITE	2	/* restart writing from the check point */
881421Sroot #define	X_ABORT		3	/* abort all of dump; don't attempt checkpointing*/
891421Sroot 
901421Sroot #ifdef DEBUG
911421Sroot #define	OINCREM	"./ddate"		/*old format incremental info*/
921421Sroot #define	NINCREM	"./dumpdates"		/*new format incremental info*/
931421Sroot #else not DEBUG
941421Sroot #define	OINCREM	"/etc/ddate"		/*old format incremental info*/
951421Sroot #define	NINCREM	"/etc/dumpdates"	/*new format incremental info*/
961421Sroot #endif
971421Sroot 
981421Sroot #define	TAPE	"/dev/rmt8"		/* default tape device */
991421Sroot #define	DISK	"/dev/rrp1g"		/* default disk */
1001421Sroot #define	OPGRENT	"operator"		/* group entry to notify */
1011421Sroot #define DIALUP	"ttyd"			/* prefix for dialups */
1021421Sroot 
1031421Sroot #define	MAXFSTAB		32
1041421Sroot struct	fstab	fstab[MAXFSTAB];
1051421Sroot struct	fstab	*fstabsearch();	/* search in fs_file and fs_spec */
1061421Sroot int	nfstab;
1071421Sroot 
1081421Sroot /*
1091421Sroot  *	The contents of the file NINCREM is maintained both on
1101421Sroot  *	a linked list, and then (eventually) arrayified.
1111421Sroot  */
112*8375Smckusick struct	idates {
113*8375Smckusick 	char	id_name[MAXNAMLEN+3];
114*8375Smckusick 	char	id_incno;
115*8375Smckusick 	time_t	id_ddate;
116*8375Smckusick };
1171421Sroot struct	itime{
1181421Sroot 	struct	idates	it_value;
1191421Sroot 	struct	itime	*it_next;
1201421Sroot };
1211421Sroot struct	itime	*ithead;	/* head of the list version */
1221421Sroot int	nidates;		/* number of records (might be zero) */
1231421Sroot int	idates_in;		/* we have read the increment file */
1241421Sroot struct	idates	**idatev;	/* the arrayfied version */
1251421Sroot #define	ITITERATE(i, ip) for (i = 0,ip = idatev[0]; i < nidates; i++, ip = idatev[i])
1261421Sroot 
1271421Sroot /*
1281421Sroot  *	We catch these interrupts
1291421Sroot  */
1301421Sroot int	sighup();
1311421Sroot int	sigquit();
1321421Sroot int	sigill();
1331421Sroot int	sigtrap();
1341421Sroot int	sigfpe();
1351421Sroot int	sigkill();
1361421Sroot int	sigbus();
1371421Sroot int	sigsegv();
1381421Sroot int	sigsys();
1391421Sroot int	sigalrm();
1401421Sroot int	sigterm();
141