xref: /csrg-svn/sbin/dump/dump.h (revision 40096)
122043Sdist /*
222043Sdist  * Copyright (c) 1980 Regents of the University of California.
322043Sdist  * All rights reserved.  The Berkeley software License Agreement
422043Sdist  * specifies the terms and conditions for redistribution.
522043Sdist  *
6*40096Smckusick  *	@(#)dump.h	5.8 (Berkeley) 02/15/90
722043Sdist  */
813592Ssam 
95328Smckusic #define	NI		16
105328Smckusic #define MAXINOPB	(MAXBSIZE / sizeof(struct dinode))
115328Smckusic #define MAXNINDIR	(MAXBSIZE / sizeof(daddr_t))
121421Sroot 
136642Ssam #include <sys/param.h>
146642Ssam #include <sys/stat.h>
1539129Smckusick #include <ufs/fs.h>
16*40096Smckusick #include <ufs/dinode.h>
1723543Smckusick #include <protocols/dumprestore.h>
18*40096Smckusick #include <ufs/dir.h>
191421Sroot #include <utmp.h>
2037946Sbostic #include <sys/signal.h>
211421Sroot #include <fstab.h>
2237946Sbostic #include <stdio.h>
2337946Sbostic #include <ctype.h>
241421Sroot 
255328Smckusic #define	MWORD(m,i)	(m[(unsigned)(i-1)/NBBY])
265328Smckusic #define	MBIT(i)		(1<<((unsigned)(i-1)%NBBY))
271421Sroot #define	BIS(i,w)	(MWORD(w,i) |=  MBIT(i))
281421Sroot #define	BIC(i,w)	(MWORD(w,i) &= ~MBIT(i))
291421Sroot #define	BIT(i,w)	(MWORD(w,i) & MBIT(i))
301421Sroot 
315328Smckusic int	msiz;
325328Smckusic char	*clrmap;
335328Smckusic char	*dirmap;
345328Smckusic char	*nodmap;
351421Sroot 
361421Sroot /*
371421Sroot  *	All calculations done in 0.1" units!
381421Sroot  */
391421Sroot 
401421Sroot char	*disk;		/* name of the disk file */
411421Sroot char	*tape;		/* name of the tape file */
421421Sroot char	*increm;	/* name of the file containing incremental information*/
4313150Ssam char	*temp;		/* name of the file for doing rewrite of increm */
4413150Ssam char	lastincno;	/* increment number of previous dump */
451421Sroot char	incno;		/* increment number */
461421Sroot int	uflag;		/* update flag */
471421Sroot int	fi;		/* disk file descriptor */
481421Sroot int	to;		/* tape file descriptor */
4912331Smckusick int	pipeout;	/* true => output to standard output */
501421Sroot ino_t	ino;		/* current inumber; used globally */
511421Sroot int	nsubdir;
521421Sroot int	newtape;	/* new tape flag */
531421Sroot int	nadded;		/* number of added sub directories */
541421Sroot int	dadded;		/* directory added flag */
551421Sroot int	density;	/* density in 0.1" units */
561421Sroot long	tsize;		/* tape size in 0.1" units */
571421Sroot long	esize;		/* estimated tape size, blocks */
581421Sroot long	asize;		/* number of 0.1" units written on current tape */
591421Sroot int	etapes;		/* estimated number of tapes */
601421Sroot 
611421Sroot int	notify;		/* notify operator flag */
621421Sroot int	blockswritten;	/* number of blocks written on current tape */
631421Sroot int	tapeno;		/* current tape number */
641421Sroot time_t	tstart_writing;	/* when started writing the first tape block */
651421Sroot char	*processname;
665328Smckusic struct fs *sblock;	/* the file system super block */
675328Smckusic char	buf[MAXBSIZE];
6830559Smckusick long	dev_bsize;
691421Sroot 
701421Sroot char	*ctime();
711421Sroot char	*prdate();
721421Sroot long	atol();
731421Sroot int	mark();
741421Sroot int	add();
7517234Smckusick int	dirdump();
761421Sroot int	dump();
771421Sroot int	tapsrec();
781421Sroot int	dmpspc();
791421Sroot int	dsrch();
801421Sroot int	nullf();
811421Sroot char	*getsuffix();
821421Sroot char	*rawname();
834701Smckusic struct dinode *getino();
841421Sroot 
851421Sroot int	interrupt();		/* in case operator bangs on console */
861421Sroot 
871421Sroot #define	HOUR	(60L*60L)
881421Sroot #define	DAY	(24L*HOUR)
891421Sroot #define	YEAR	(365L*DAY)
901421Sroot 
911421Sroot /*
921421Sroot  *	Exit status codes
931421Sroot  */
9428641Smckusick #define	X_FINOK		0	/* normal exit */
951421Sroot #define	X_REWRITE	2	/* restart writing from the check point */
961421Sroot #define	X_ABORT		3	/* abort all of dump; don't attempt checkpointing*/
971421Sroot 
981421Sroot #define	OPGRENT	"operator"		/* group entry to notify */
991421Sroot #define DIALUP	"ttyd"			/* prefix for dialups */
1001421Sroot 
1011421Sroot struct	fstab	*fstabsearch();	/* search in fs_file and fs_spec */
1021421Sroot 
1031421Sroot /*
10437266Sbostic  *	The contents of the file _PATH_DUMPDATES is maintained both on
1051421Sroot  *	a linked list, and then (eventually) arrayified.
1061421Sroot  */
1078375Smckusick struct	idates {
1088375Smckusick 	char	id_name[MAXNAMLEN+3];
1098375Smckusick 	char	id_incno;
1108375Smckusick 	time_t	id_ddate;
1118375Smckusick };
1121421Sroot struct	itime{
1131421Sroot 	struct	idates	it_value;
1141421Sroot 	struct	itime	*it_next;
1151421Sroot };
1161421Sroot struct	itime	*ithead;	/* head of the list version */
1171421Sroot int	nidates;		/* number of records (might be zero) */
1181421Sroot int	idates_in;		/* we have read the increment file */
1191421Sroot struct	idates	**idatev;	/* the arrayfied version */
1201421Sroot #define	ITITERATE(i, ip) for (i = 0,ip = idatev[0]; i < nidates; i++, ip = idatev[i])
1211421Sroot 
1221421Sroot /*
1231421Sroot  *	We catch these interrupts
1241421Sroot  */
1251421Sroot int	sighup();
1261421Sroot int	sigquit();
1271421Sroot int	sigill();
1281421Sroot int	sigtrap();
1291421Sroot int	sigfpe();
1301421Sroot int	sigkill();
1311421Sroot int	sigbus();
1321421Sroot int	sigsegv();
1331421Sroot int	sigsys();
1341421Sroot int	sigalrm();
1351421Sroot int	sigterm();
136