xref: /csrg-svn/sbin/dump/dump.h (revision 54071)
147082Smckusick /*-
247082Smckusick  * Copyright (c) 1980 The Regents of the University of California.
347082Smckusick  * All rights reserved.
422043Sdist  *
547082Smckusick  * %sccs.include.redist.c%
647082Smckusick  *
7*54071Smckusick  *	@(#)dump.h	5.19 (Berkeley) 06/18/92
822043Sdist  */
913592Ssam 
105328Smckusic #define MAXINOPB	(MAXBSIZE / sizeof(struct dinode))
115328Smckusic #define MAXNINDIR	(MAXBSIZE / sizeof(daddr_t))
121421Sroot 
1346790Smckusick /*
1446790Smckusick  * Dump maps used to describe what is to be dumped.
1546790Smckusick  */
1646790Smckusick int	mapsize;	/* size of the state maps */
1746790Smckusick char	*usedinomap;	/* map of allocated inodes */
1846790Smckusick char	*dumpdirmap;	/* map of directories to be dumped */
1946790Smckusick char	*dumpinomap;	/* map of files to be dumped */
2046790Smckusick /*
2146790Smckusick  * Map manipulation macros.
2246790Smckusick  */
2346790Smckusick #define	SETINO(ino, map) \
2446790Smckusick 	map[(u_int)((ino) - 1) / NBBY] |=  1 << ((u_int)((ino) - 1) % NBBY)
2546790Smckusick #define	CLRINO(ino, map) \
2646790Smckusick 	map[(u_int)((ino) - 1) / NBBY] &=  ~(1 << ((u_int)((ino) - 1) % NBBY))
2746790Smckusick #define	TSTINO(ino, map) \
2846790Smckusick 	(map[(u_int)((ino) - 1) / NBBY] &  (1 << ((u_int)((ino) - 1) % NBBY)))
291421Sroot 
301421Sroot /*
311421Sroot  *	All calculations done in 0.1" units!
321421Sroot  */
331421Sroot char	*disk;		/* name of the disk file */
341421Sroot char	*tape;		/* name of the tape file */
3546790Smckusick char	*dumpdates;	/* name of the file containing dump date information*/
3646790Smckusick char	*temp;		/* name of the file for doing rewrite of dumpdates */
3746790Smckusick char	lastlevel;	/* dump level of previous dump */
3846790Smckusick char	level;		/* dump level of this dump */
391421Sroot int	uflag;		/* update flag */
4046790Smckusick int	diskfd;		/* disk file descriptor */
4146790Smckusick int	tapefd;		/* tape file descriptor */
4212331Smckusick int	pipeout;	/* true => output to standard output */
4346790Smckusick ino_t	curino;		/* current inumber; used globally */
441421Sroot int	newtape;	/* new tape flag */
451421Sroot int	density;	/* density in 0.1" units */
4646790Smckusick long	tapesize;	/* estimated tape size, blocks */
471421Sroot long	tsize;		/* tape size in 0.1" units */
481421Sroot long	asize;		/* number of 0.1" units written on current tape */
491421Sroot int	etapes;		/* estimated number of tapes */
501421Sroot 
511421Sroot int	notify;		/* notify operator flag */
521421Sroot int	blockswritten;	/* number of blocks written on current tape */
531421Sroot int	tapeno;		/* current tape number */
541421Sroot time_t	tstart_writing;	/* when started writing the first tape block */
5546790Smckusick struct	fs *sblock;	/* the file system super block */
56*54071Smckusick char	sblock_buf[MAXBSIZE];
5746589Storek long	dev_bsize;	/* block size of underlying disk device */
5846589Storek int	dev_bshift;	/* log2(dev_bsize) */
5946589Storek int	tp_bshift;	/* log2(TP_BSIZE) */
601421Sroot 
6146589Storek /* operator interface functions */
62*54071Smckusick void	broadcast __P((char *message));
63*54071Smckusick void	lastdump __P((int arg));	/* int should be char */
64*54071Smckusick time_t	unctime __P((char *str));
6550643Storek #if __STDC__
6650643Storek void	msg(const char *fmt, ...);
6750643Storek void	msgtail(const char *fmt, ...);
6850643Storek void	quit(const char *fmt, ...);
6950643Storek #else
7046589Storek void	msg();
7146589Storek void	msgtail();
7250643Storek void	quit();
7350643Storek #endif
74*54071Smckusick int	query __P((char *question));
75*54071Smckusick void	set_operators __P(());
76*54071Smckusick void	timeest __P(());
7746589Storek 
7846589Storek /* mapping rouintes */
79*54071Smckusick struct	dinode;
80*54071Smckusick long	blockest __P((struct dinode *dp));
81*54071Smckusick int	mapfiles __P((ino_t maxino, long *tapesize));
82*54071Smckusick int	mapdirs __P((ino_t maxino, long *tapesize));
8346589Storek 
8446589Storek /* file dumping routines */
85*54071Smckusick void	dumpino __P((struct dinode *dp, ino_t ino));
86*54071Smckusick void	blksout __P((daddr_t *blkp, int frags, ino_t ino));
87*54071Smckusick void	dumpmap __P((char *map, int type, ino_t ino));
88*54071Smckusick void	writeheader __P((ino_t ino));
89*54071Smckusick void	bread __P((daddr_t blkno, char *buf, int size));
9046589Storek 
9146589Storek /* tape writing routines */
92*54071Smckusick int	alloctape __P(());
93*54071Smckusick void	writerec __P((char *dp));
94*54071Smckusick void	dumpblock __P((daddr_t blkno, int size));
95*54071Smckusick void	flushtape __P(());
96*54071Smckusick void	trewind __P(());
97*54071Smckusick void	close_rewind __P(());
98*54071Smckusick void	startnewtape __P(());
9946589Storek 
100*54071Smckusick void	dumpabort __P(());
101*54071Smckusick void	Exit __P((int status));
102*54071Smckusick void	getfstab __P(());
10346589Storek 
104*54071Smckusick char	*rawname __P((char *cp));
105*54071Smckusick struct	dinode *getino __P((ino_t inum));
1061421Sroot 
107*54071Smckusick void	interrupt __P(());	/* in case operator bangs on console */
1081421Sroot 
1091421Sroot /*
1101421Sroot  *	Exit status codes
1111421Sroot  */
11228641Smckusick #define	X_FINOK		0	/* normal exit */
1131421Sroot #define	X_REWRITE	2	/* restart writing from the check point */
114*54071Smckusick #define	X_ABORT		3	/* abort dump; don't attempt checkpointing */
1151421Sroot 
1161421Sroot #define	OPGRENT	"operator"		/* group entry to notify */
1171421Sroot #define DIALUP	"ttyd"			/* prefix for dialups */
1181421Sroot 
119*54071Smckusick struct	fstab *fstabsearch __P((char *key));	/* search fs_file and fs_spec */
1201421Sroot 
121*54071Smckusick #ifndef NAME_MAX
122*54071Smckusick #define NAME_MAX 255
123*54071Smckusick #endif
124*54071Smckusick 
1251421Sroot /*
12637266Sbostic  *	The contents of the file _PATH_DUMPDATES is maintained both on
1271421Sroot  *	a linked list, and then (eventually) arrayified.
1281421Sroot  */
12946790Smckusick struct dumpdates {
13050506Smckusick 	char	dd_name[NAME_MAX+3];
13146790Smckusick 	char	dd_level;
13246790Smckusick 	time_t	dd_ddate;
1338375Smckusick };
13446790Smckusick struct dumptime {
13546790Smckusick 	struct	dumpdates dt_value;
13646790Smckusick 	struct	dumptime *dt_next;
1371421Sroot };
13846790Smckusick struct	dumptime *dthead;	/* head of the list version */
13946790Smckusick int	nddates;		/* number of records (might be zero) */
14046790Smckusick int	ddates_in;		/* we have read the increment file */
14146790Smckusick struct	dumpdates **ddatev;	/* the arrayfied version */
142*54071Smckusick void	initdumptimes __P(());
143*54071Smckusick void	getdumptime __P(());
144*54071Smckusick void	putdumptime __P(());
14546790Smckusick #define	ITITERATE(i, ddp) \
14646790Smckusick 	for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i])
1471421Sroot 
1481421Sroot /*
1491421Sroot  *	We catch these interrupts
1501421Sroot  */
151*54071Smckusick void	sighup __P(());
152*54071Smckusick void	sigtrap __P(());
153*54071Smckusick void	sigfpe __P(());
154*54071Smckusick void	sigbus __P(());
155*54071Smckusick void	sigsegv __P(());
156*54071Smckusick void	sigalrm __P(());
157*54071Smckusick void	sigterm __P(());
15846807Smckusick 
15946807Smckusick /*
16046807Smckusick  * Compatibility with old systems.
16146807Smckusick  */
16246807Smckusick #ifndef __STDC__
16346807Smckusick #include <sys/file.h>
16446807Smckusick #define _PATH_FSTAB	"/etc/fstab"
16549932Smckusick extern char *index(), *strdup();
16646807Smckusick extern char *ctime();
16746807Smckusick extern int errno;
16846807Smckusick #endif
169*54071Smckusick 
170*54071Smckusick #ifdef sunos
171*54071Smckusick extern char *calloc();
172*54071Smckusick extern char *malloc();
173*54071Smckusick extern long atol();
174*54071Smckusick extern char *strcpy();
175*54071Smckusick extern char *strncpy();
176*54071Smckusick extern char *strcat();
177*54071Smckusick extern time_t time();
178*54071Smckusick extern void endgrent();
179*54071Smckusick extern void exit();
180*54071Smckusick extern off_t lseek();
181*54071Smckusick extern char *strerror();
182*54071Smckusick #endif
183