xref: /csrg-svn/sbin/dump/dump.h (revision 68991)
147082Smckusick /*-
261484Sbostic  * Copyright (c) 1980, 1993
361484Sbostic  *	The Regents of the University of California.  All rights reserved.
422043Sdist  *
547082Smckusick  * %sccs.include.redist.c%
647082Smckusick  *
7*68991Sbostic  *	@(#)dump.h	8.2 (Berkeley) 04/28/95
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 */
5059927Storek int	nonodump;	/* if set, do not honor UF_NODUMP user flags */
511421Sroot 
521421Sroot int	notify;		/* notify operator flag */
531421Sroot int	blockswritten;	/* number of blocks written on current tape */
541421Sroot int	tapeno;		/* current tape number */
551421Sroot time_t	tstart_writing;	/* when started writing the first tape block */
5646790Smckusick struct	fs *sblock;	/* the file system super block */
5754071Smckusick char	sblock_buf[MAXBSIZE];
5846589Storek long	dev_bsize;	/* block size of underlying disk device */
5946589Storek int	dev_bshift;	/* log2(dev_bsize) */
6046589Storek int	tp_bshift;	/* log2(TP_BSIZE) */
611421Sroot 
6259927Storek #ifndef __P
6359927Storek #include <sys/cdefs.h>
6459927Storek #endif
6559927Storek 
6646589Storek /* operator interface functions */
6754071Smckusick void	broadcast __P((char *message));
6854071Smckusick void	lastdump __P((int arg));	/* int should be char */
6955288Sbostic void	msg __P((const char *fmt, ...));
7055288Sbostic void	msgtail __P((const char *fmt, ...));
7155288Sbostic int	query __P((char *question));
7255288Sbostic void	quit __P((const char *fmt, ...));
7355288Sbostic void	set_operators __P((void));
7455288Sbostic void	timeest __P((void));
7554071Smckusick time_t	unctime __P((char *str));
7646589Storek 
7746589Storek /* mapping rouintes */
7854071Smckusick struct	dinode;
7954071Smckusick long	blockest __P((struct dinode *dp));
8054071Smckusick int	mapfiles __P((ino_t maxino, long *tapesize));
8154071Smckusick int	mapdirs __P((ino_t maxino, long *tapesize));
8246589Storek 
8346589Storek /* file dumping routines */
8455288Sbostic void	blksout __P((daddr_t *blkp, int frags, ino_t ino));
8555288Sbostic void	bread __P((daddr_t blkno, char *buf, int size));
8654071Smckusick void	dumpino __P((struct dinode *dp, ino_t ino));
8754071Smckusick void	dumpmap __P((char *map, int type, ino_t ino));
8854071Smckusick void	writeheader __P((ino_t ino));
8946589Storek 
9046589Storek /* tape writing routines */
9155288Sbostic int	alloctape __P((void));
9255288Sbostic void	close_rewind __P((void));
9355288Sbostic void	dumpblock __P((daddr_t blkno, int size));
9455288Sbostic void	startnewtape __P((int top));
9555288Sbostic void	trewind __P((void));
9654594Smckusick void	writerec __P((char *dp, int isspcl));
9746589Storek 
9859927Storek __dead void Exit __P((int status));
9955288Sbostic void	dumpabort __P((int signo));
10055288Sbostic void	getfstab __P((void));
10146589Storek 
10254071Smckusick char	*rawname __P((char *cp));
10354071Smckusick struct	dinode *getino __P((ino_t inum));
1041421Sroot 
10557725Smckusick /* rdump routines */
10657725Smckusick #ifdef RDUMP
10757725Smckusick void	rmtclose __P((void));
10857725Smckusick int	rmthost __P((char *host));
10957725Smckusick int	rmtopen __P((char *tape, int mode));
11057725Smckusick int	rmtwrite __P((char *buf, int count));
11157725Smckusick #endif /* RDUMP */
11257725Smckusick 
11355288Sbostic void	interrupt __P((int signo));	/* in case operator bangs on console */
1141421Sroot 
1151421Sroot /*
1161421Sroot  *	Exit status codes
1171421Sroot  */
11828641Smckusick #define	X_FINOK		0	/* normal exit */
1191421Sroot #define	X_REWRITE	2	/* restart writing from the check point */
12054071Smckusick #define	X_ABORT		3	/* abort dump; don't attempt checkpointing */
1211421Sroot 
1221421Sroot #define	OPGRENT	"operator"		/* group entry to notify */
1231421Sroot #define DIALUP	"ttyd"			/* prefix for dialups */
1241421Sroot 
12554071Smckusick struct	fstab *fstabsearch __P((char *key));	/* search fs_file and fs_spec */
1261421Sroot 
12754071Smckusick #ifndef NAME_MAX
12854071Smckusick #define NAME_MAX 255
12954071Smckusick #endif
13054071Smckusick 
1311421Sroot /*
13237266Sbostic  *	The contents of the file _PATH_DUMPDATES is maintained both on
1331421Sroot  *	a linked list, and then (eventually) arrayified.
1341421Sroot  */
13546790Smckusick struct dumpdates {
13650506Smckusick 	char	dd_name[NAME_MAX+3];
13746790Smckusick 	char	dd_level;
13846790Smckusick 	time_t	dd_ddate;
1398375Smckusick };
14046790Smckusick struct dumptime {
14146790Smckusick 	struct	dumpdates dt_value;
14246790Smckusick 	struct	dumptime *dt_next;
1431421Sroot };
14446790Smckusick struct	dumptime *dthead;	/* head of the list version */
14546790Smckusick int	nddates;		/* number of records (might be zero) */
14646790Smckusick int	ddates_in;		/* we have read the increment file */
14746790Smckusick struct	dumpdates **ddatev;	/* the arrayfied version */
14855288Sbostic void	initdumptimes __P((void));
14955288Sbostic void	getdumptime __P((void));
15055288Sbostic void	putdumptime __P((void));
15146790Smckusick #define	ITITERATE(i, ddp) \
15246790Smckusick 	for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i])
1531421Sroot 
15455288Sbostic void	sig __P((int signo));
15546807Smckusick 
15646807Smckusick /*
15746807Smckusick  * Compatibility with old systems.
15846807Smckusick  */
15959927Storek #ifdef COMPAT
16046807Smckusick #include <sys/file.h>
161*68991Sbostic #define	strchr(a,b)	index(a,b)
162*68991Sbostic #define	strrchr(a,b)	rindex(a,b)
163*68991Sbostic extern char *strdup(), *ctime();
16459927Storek extern int read(), write();
16546807Smckusick extern int errno;
16646807Smckusick #endif
16754071Smckusick 
16859927Storek #ifndef	_PATH_UTMP
16959927Storek #define	_PATH_UTMP	"/etc/utmp"
17059927Storek #endif
17159927Storek #ifndef	_PATH_FSTAB
17259927Storek #define	_PATH_FSTAB	"/etc/fstab"
17359927Storek #endif
17459927Storek 
17554071Smckusick #ifdef sunos
17654071Smckusick extern char *calloc();
17754071Smckusick extern char *malloc();
17854071Smckusick extern long atol();
17954071Smckusick extern char *strcpy();
18054071Smckusick extern char *strncpy();
18154071Smckusick extern char *strcat();
18254071Smckusick extern time_t time();
18354071Smckusick extern void endgrent();
18457725Smckusick extern __dead void exit();
18554071Smckusick extern off_t lseek();
18659927Storek extern const char *strerror();
18754071Smckusick #endif
188