xref: /csrg-svn/sbin/dump/dump.h (revision 57725)
147082Smckusick /*-
247082Smckusick  * Copyright (c) 1980 The Regents of the University of California.
347082Smckusick  * All rights reserved.
422043Sdist  *
547082Smckusick  * %sccs.include.redist.c%
647082Smckusick  *
7*57725Smckusick  *	@(#)dump.h	5.22 (Berkeley) 01/25/93
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 */
5654071Smckusick 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 */
6254071Smckusick void	broadcast __P((char *message));
6354071Smckusick void	lastdump __P((int arg));	/* int should be char */
6455288Sbostic void	msg __P((const char *fmt, ...));
6555288Sbostic void	msgtail __P((const char *fmt, ...));
6655288Sbostic int	query __P((char *question));
6755288Sbostic void	quit __P((const char *fmt, ...));
6855288Sbostic void	set_operators __P((void));
6955288Sbostic void	timeest __P((void));
7054071Smckusick time_t	unctime __P((char *str));
7146589Storek 
7246589Storek /* mapping rouintes */
7354071Smckusick struct	dinode;
7454071Smckusick long	blockest __P((struct dinode *dp));
7554071Smckusick int	mapfiles __P((ino_t maxino, long *tapesize));
7654071Smckusick int	mapdirs __P((ino_t maxino, long *tapesize));
7746589Storek 
7846589Storek /* file dumping routines */
7955288Sbostic void	blksout __P((daddr_t *blkp, int frags, ino_t ino));
8055288Sbostic void	bread __P((daddr_t blkno, char *buf, int size));
8154071Smckusick void	dumpino __P((struct dinode *dp, ino_t ino));
8254071Smckusick void	dumpmap __P((char *map, int type, ino_t ino));
8354071Smckusick void	writeheader __P((ino_t ino));
8446589Storek 
8546589Storek /* tape writing routines */
8655288Sbostic int	alloctape __P((void));
8755288Sbostic void	close_rewind __P((void));
8855288Sbostic void	dumpblock __P((daddr_t blkno, int size));
8955288Sbostic void	startnewtape __P((int top));
9055288Sbostic void	trewind __P((void));
9154594Smckusick void	writerec __P((char *dp, int isspcl));
9246589Storek 
9354071Smckusick void	Exit __P((int status));
9455288Sbostic void	dumpabort __P((int signo));
9555288Sbostic void	getfstab __P((void));
9646589Storek 
9754071Smckusick char	*rawname __P((char *cp));
9854071Smckusick struct	dinode *getino __P((ino_t inum));
991421Sroot 
100*57725Smckusick /* rdump routines */
101*57725Smckusick #ifdef RDUMP
102*57725Smckusick void	rmtclose __P((void));
103*57725Smckusick int	rmthost __P((char *host));
104*57725Smckusick int	rmtopen __P((char *tape, int mode));
105*57725Smckusick int	rmtwrite __P((char *buf, int count));
106*57725Smckusick #endif /* RDUMP */
107*57725Smckusick 
10855288Sbostic void	interrupt __P((int signo));	/* in case operator bangs on console */
1091421Sroot 
1101421Sroot /*
1111421Sroot  *	Exit status codes
1121421Sroot  */
11328641Smckusick #define	X_FINOK		0	/* normal exit */
1141421Sroot #define	X_REWRITE	2	/* restart writing from the check point */
11554071Smckusick #define	X_ABORT		3	/* abort dump; don't attempt checkpointing */
1161421Sroot 
1171421Sroot #define	OPGRENT	"operator"		/* group entry to notify */
1181421Sroot #define DIALUP	"ttyd"			/* prefix for dialups */
1191421Sroot 
12054071Smckusick struct	fstab *fstabsearch __P((char *key));	/* search fs_file and fs_spec */
1211421Sroot 
12254071Smckusick #ifndef NAME_MAX
12354071Smckusick #define NAME_MAX 255
12454071Smckusick #endif
12554071Smckusick 
1261421Sroot /*
12737266Sbostic  *	The contents of the file _PATH_DUMPDATES is maintained both on
1281421Sroot  *	a linked list, and then (eventually) arrayified.
1291421Sroot  */
13046790Smckusick struct dumpdates {
13150506Smckusick 	char	dd_name[NAME_MAX+3];
13246790Smckusick 	char	dd_level;
13346790Smckusick 	time_t	dd_ddate;
1348375Smckusick };
13546790Smckusick struct dumptime {
13646790Smckusick 	struct	dumpdates dt_value;
13746790Smckusick 	struct	dumptime *dt_next;
1381421Sroot };
13946790Smckusick struct	dumptime *dthead;	/* head of the list version */
14046790Smckusick int	nddates;		/* number of records (might be zero) */
14146790Smckusick int	ddates_in;		/* we have read the increment file */
14246790Smckusick struct	dumpdates **ddatev;	/* the arrayfied version */
14355288Sbostic void	initdumptimes __P((void));
14455288Sbostic void	getdumptime __P((void));
14555288Sbostic void	putdumptime __P((void));
14646790Smckusick #define	ITITERATE(i, ddp) \
14746790Smckusick 	for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i])
1481421Sroot 
14955288Sbostic void	sig __P((int signo));
15046807Smckusick 
15146807Smckusick /*
15246807Smckusick  * Compatibility with old systems.
15346807Smckusick  */
15446807Smckusick #ifndef __STDC__
15546807Smckusick #include <sys/file.h>
15646807Smckusick #define _PATH_FSTAB	"/etc/fstab"
15749932Smckusick extern char *index(), *strdup();
15846807Smckusick extern char *ctime();
15946807Smckusick extern int errno;
16046807Smckusick #endif
16154071Smckusick 
16254071Smckusick #ifdef sunos
16354071Smckusick extern char *calloc();
16454071Smckusick extern char *malloc();
16554071Smckusick extern long atol();
16654071Smckusick extern char *strcpy();
16754071Smckusick extern char *strncpy();
16854071Smckusick extern char *strcat();
16954071Smckusick extern time_t time();
17054071Smckusick extern void endgrent();
171*57725Smckusick extern __dead void exit();
17254071Smckusick extern off_t lseek();
17354071Smckusick extern char *strerror();
17454071Smckusick #endif
175