xref: /freebsd/sbin/dump/dump.h (revision 8fae3551ec46402adf7ab034cf9e02bcbc7ca8ee)
18fae3551SRodney W. Grimes /*-
28fae3551SRodney W. Grimes  * Copyright (c) 1980, 1993
38fae3551SRodney W. Grimes  *	The Regents of the University of California.  All rights reserved.
48fae3551SRodney W. Grimes  *
58fae3551SRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
68fae3551SRodney W. Grimes  * modification, are permitted provided that the following conditions
78fae3551SRodney W. Grimes  * are met:
88fae3551SRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
98fae3551SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
108fae3551SRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
118fae3551SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
128fae3551SRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
138fae3551SRodney W. Grimes  * 3. All advertising materials mentioning features or use of this software
148fae3551SRodney W. Grimes  *    must display the following acknowledgement:
158fae3551SRodney W. Grimes  *	This product includes software developed by the University of
168fae3551SRodney W. Grimes  *	California, Berkeley and its contributors.
178fae3551SRodney W. Grimes  * 4. Neither the name of the University nor the names of its contributors
188fae3551SRodney W. Grimes  *    may be used to endorse or promote products derived from this software
198fae3551SRodney W. Grimes  *    without specific prior written permission.
208fae3551SRodney W. Grimes  *
218fae3551SRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
228fae3551SRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
238fae3551SRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
248fae3551SRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
258fae3551SRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
268fae3551SRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
278fae3551SRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
288fae3551SRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
298fae3551SRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
308fae3551SRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
318fae3551SRodney W. Grimes  * SUCH DAMAGE.
328fae3551SRodney W. Grimes  *
338fae3551SRodney W. Grimes  *	@(#)dump.h	8.1 (Berkeley) 6/5/93
348fae3551SRodney W. Grimes  */
358fae3551SRodney W. Grimes 
368fae3551SRodney W. Grimes #define MAXINOPB	(MAXBSIZE / sizeof(struct dinode))
378fae3551SRodney W. Grimes #define MAXNINDIR	(MAXBSIZE / sizeof(daddr_t))
388fae3551SRodney W. Grimes 
398fae3551SRodney W. Grimes /*
408fae3551SRodney W. Grimes  * Dump maps used to describe what is to be dumped.
418fae3551SRodney W. Grimes  */
428fae3551SRodney W. Grimes int	mapsize;	/* size of the state maps */
438fae3551SRodney W. Grimes char	*usedinomap;	/* map of allocated inodes */
448fae3551SRodney W. Grimes char	*dumpdirmap;	/* map of directories to be dumped */
458fae3551SRodney W. Grimes char	*dumpinomap;	/* map of files to be dumped */
468fae3551SRodney W. Grimes /*
478fae3551SRodney W. Grimes  * Map manipulation macros.
488fae3551SRodney W. Grimes  */
498fae3551SRodney W. Grimes #define	SETINO(ino, map) \
508fae3551SRodney W. Grimes 	map[(u_int)((ino) - 1) / NBBY] |=  1 << ((u_int)((ino) - 1) % NBBY)
518fae3551SRodney W. Grimes #define	CLRINO(ino, map) \
528fae3551SRodney W. Grimes 	map[(u_int)((ino) - 1) / NBBY] &=  ~(1 << ((u_int)((ino) - 1) % NBBY))
538fae3551SRodney W. Grimes #define	TSTINO(ino, map) \
548fae3551SRodney W. Grimes 	(map[(u_int)((ino) - 1) / NBBY] &  (1 << ((u_int)((ino) - 1) % NBBY)))
558fae3551SRodney W. Grimes 
568fae3551SRodney W. Grimes /*
578fae3551SRodney W. Grimes  *	All calculations done in 0.1" units!
588fae3551SRodney W. Grimes  */
598fae3551SRodney W. Grimes char	*disk;		/* name of the disk file */
608fae3551SRodney W. Grimes char	*tape;		/* name of the tape file */
618fae3551SRodney W. Grimes char	*dumpdates;	/* name of the file containing dump date information*/
628fae3551SRodney W. Grimes char	*temp;		/* name of the file for doing rewrite of dumpdates */
638fae3551SRodney W. Grimes char	lastlevel;	/* dump level of previous dump */
648fae3551SRodney W. Grimes char	level;		/* dump level of this dump */
658fae3551SRodney W. Grimes int	uflag;		/* update flag */
668fae3551SRodney W. Grimes int	diskfd;		/* disk file descriptor */
678fae3551SRodney W. Grimes int	tapefd;		/* tape file descriptor */
688fae3551SRodney W. Grimes int	pipeout;	/* true => output to standard output */
698fae3551SRodney W. Grimes ino_t	curino;		/* current inumber; used globally */
708fae3551SRodney W. Grimes int	newtape;	/* new tape flag */
718fae3551SRodney W. Grimes int	density;	/* density in 0.1" units */
728fae3551SRodney W. Grimes long	tapesize;	/* estimated tape size, blocks */
738fae3551SRodney W. Grimes long	tsize;		/* tape size in 0.1" units */
748fae3551SRodney W. Grimes long	asize;		/* number of 0.1" units written on current tape */
758fae3551SRodney W. Grimes int	etapes;		/* estimated number of tapes */
768fae3551SRodney W. Grimes int	nonodump;	/* if set, do not honor UF_NODUMP user flags */
778fae3551SRodney W. Grimes 
788fae3551SRodney W. Grimes int	notify;		/* notify operator flag */
798fae3551SRodney W. Grimes int	blockswritten;	/* number of blocks written on current tape */
808fae3551SRodney W. Grimes int	tapeno;		/* current tape number */
818fae3551SRodney W. Grimes time_t	tstart_writing;	/* when started writing the first tape block */
828fae3551SRodney W. Grimes struct	fs *sblock;	/* the file system super block */
838fae3551SRodney W. Grimes char	sblock_buf[MAXBSIZE];
848fae3551SRodney W. Grimes long	dev_bsize;	/* block size of underlying disk device */
858fae3551SRodney W. Grimes int	dev_bshift;	/* log2(dev_bsize) */
868fae3551SRodney W. Grimes int	tp_bshift;	/* log2(TP_BSIZE) */
878fae3551SRodney W. Grimes 
888fae3551SRodney W. Grimes #ifndef __P
898fae3551SRodney W. Grimes #include <sys/cdefs.h>
908fae3551SRodney W. Grimes #endif
918fae3551SRodney W. Grimes 
928fae3551SRodney W. Grimes /* operator interface functions */
938fae3551SRodney W. Grimes void	broadcast __P((char *message));
948fae3551SRodney W. Grimes void	lastdump __P((int arg));	/* int should be char */
958fae3551SRodney W. Grimes void	msg __P((const char *fmt, ...));
968fae3551SRodney W. Grimes void	msgtail __P((const char *fmt, ...));
978fae3551SRodney W. Grimes int	query __P((char *question));
988fae3551SRodney W. Grimes void	quit __P((const char *fmt, ...));
998fae3551SRodney W. Grimes void	set_operators __P((void));
1008fae3551SRodney W. Grimes void	timeest __P((void));
1018fae3551SRodney W. Grimes time_t	unctime __P((char *str));
1028fae3551SRodney W. Grimes 
1038fae3551SRodney W. Grimes /* mapping rouintes */
1048fae3551SRodney W. Grimes struct	dinode;
1058fae3551SRodney W. Grimes long	blockest __P((struct dinode *dp));
1068fae3551SRodney W. Grimes int	mapfiles __P((ino_t maxino, long *tapesize));
1078fae3551SRodney W. Grimes int	mapdirs __P((ino_t maxino, long *tapesize));
1088fae3551SRodney W. Grimes 
1098fae3551SRodney W. Grimes /* file dumping routines */
1108fae3551SRodney W. Grimes void	blksout __P((daddr_t *blkp, int frags, ino_t ino));
1118fae3551SRodney W. Grimes void	bread __P((daddr_t blkno, char *buf, int size));
1128fae3551SRodney W. Grimes void	dumpino __P((struct dinode *dp, ino_t ino));
1138fae3551SRodney W. Grimes void	dumpmap __P((char *map, int type, ino_t ino));
1148fae3551SRodney W. Grimes void	writeheader __P((ino_t ino));
1158fae3551SRodney W. Grimes 
1168fae3551SRodney W. Grimes /* tape writing routines */
1178fae3551SRodney W. Grimes int	alloctape __P((void));
1188fae3551SRodney W. Grimes void	close_rewind __P((void));
1198fae3551SRodney W. Grimes void	dumpblock __P((daddr_t blkno, int size));
1208fae3551SRodney W. Grimes void	startnewtape __P((int top));
1218fae3551SRodney W. Grimes void	trewind __P((void));
1228fae3551SRodney W. Grimes void	writerec __P((char *dp, int isspcl));
1238fae3551SRodney W. Grimes 
1248fae3551SRodney W. Grimes __dead void Exit __P((int status));
1258fae3551SRodney W. Grimes void	dumpabort __P((int signo));
1268fae3551SRodney W. Grimes void	getfstab __P((void));
1278fae3551SRodney W. Grimes 
1288fae3551SRodney W. Grimes char	*rawname __P((char *cp));
1298fae3551SRodney W. Grimes struct	dinode *getino __P((ino_t inum));
1308fae3551SRodney W. Grimes 
1318fae3551SRodney W. Grimes /* rdump routines */
1328fae3551SRodney W. Grimes #ifdef RDUMP
1338fae3551SRodney W. Grimes void	rmtclose __P((void));
1348fae3551SRodney W. Grimes int	rmthost __P((char *host));
1358fae3551SRodney W. Grimes int	rmtopen __P((char *tape, int mode));
1368fae3551SRodney W. Grimes int	rmtwrite __P((char *buf, int count));
1378fae3551SRodney W. Grimes #endif /* RDUMP */
1388fae3551SRodney W. Grimes 
1398fae3551SRodney W. Grimes void	interrupt __P((int signo));	/* in case operator bangs on console */
1408fae3551SRodney W. Grimes 
1418fae3551SRodney W. Grimes /*
1428fae3551SRodney W. Grimes  *	Exit status codes
1438fae3551SRodney W. Grimes  */
1448fae3551SRodney W. Grimes #define	X_FINOK		0	/* normal exit */
1458fae3551SRodney W. Grimes #define	X_REWRITE	2	/* restart writing from the check point */
1468fae3551SRodney W. Grimes #define	X_ABORT		3	/* abort dump; don't attempt checkpointing */
1478fae3551SRodney W. Grimes 
1488fae3551SRodney W. Grimes #define	OPGRENT	"operator"		/* group entry to notify */
1498fae3551SRodney W. Grimes #define DIALUP	"ttyd"			/* prefix for dialups */
1508fae3551SRodney W. Grimes 
1518fae3551SRodney W. Grimes struct	fstab *fstabsearch __P((char *key));	/* search fs_file and fs_spec */
1528fae3551SRodney W. Grimes 
1538fae3551SRodney W. Grimes #ifndef NAME_MAX
1548fae3551SRodney W. Grimes #define NAME_MAX 255
1558fae3551SRodney W. Grimes #endif
1568fae3551SRodney W. Grimes 
1578fae3551SRodney W. Grimes /*
1588fae3551SRodney W. Grimes  *	The contents of the file _PATH_DUMPDATES is maintained both on
1598fae3551SRodney W. Grimes  *	a linked list, and then (eventually) arrayified.
1608fae3551SRodney W. Grimes  */
1618fae3551SRodney W. Grimes struct dumpdates {
1628fae3551SRodney W. Grimes 	char	dd_name[NAME_MAX+3];
1638fae3551SRodney W. Grimes 	char	dd_level;
1648fae3551SRodney W. Grimes 	time_t	dd_ddate;
1658fae3551SRodney W. Grimes };
1668fae3551SRodney W. Grimes struct dumptime {
1678fae3551SRodney W. Grimes 	struct	dumpdates dt_value;
1688fae3551SRodney W. Grimes 	struct	dumptime *dt_next;
1698fae3551SRodney W. Grimes };
1708fae3551SRodney W. Grimes struct	dumptime *dthead;	/* head of the list version */
1718fae3551SRodney W. Grimes int	nddates;		/* number of records (might be zero) */
1728fae3551SRodney W. Grimes int	ddates_in;		/* we have read the increment file */
1738fae3551SRodney W. Grimes struct	dumpdates **ddatev;	/* the arrayfied version */
1748fae3551SRodney W. Grimes void	initdumptimes __P((void));
1758fae3551SRodney W. Grimes void	getdumptime __P((void));
1768fae3551SRodney W. Grimes void	putdumptime __P((void));
1778fae3551SRodney W. Grimes #define	ITITERATE(i, ddp) \
1788fae3551SRodney W. Grimes 	for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i])
1798fae3551SRodney W. Grimes 
1808fae3551SRodney W. Grimes void	sig __P((int signo));
1818fae3551SRodney W. Grimes 
1828fae3551SRodney W. Grimes /*
1838fae3551SRodney W. Grimes  * Compatibility with old systems.
1848fae3551SRodney W. Grimes  */
1858fae3551SRodney W. Grimes #ifdef COMPAT
1868fae3551SRodney W. Grimes #include <sys/file.h>
1878fae3551SRodney W. Grimes extern char *index(), *rindex(), *strdup();
1888fae3551SRodney W. Grimes extern char *ctime();
1898fae3551SRodney W. Grimes extern int read(), write();
1908fae3551SRodney W. Grimes extern int errno;
1918fae3551SRodney W. Grimes #endif
1928fae3551SRodney W. Grimes 
1938fae3551SRodney W. Grimes #ifndef	_PATH_UTMP
1948fae3551SRodney W. Grimes #define	_PATH_UTMP	"/etc/utmp"
1958fae3551SRodney W. Grimes #endif
1968fae3551SRodney W. Grimes #ifndef	_PATH_FSTAB
1978fae3551SRodney W. Grimes #define	_PATH_FSTAB	"/etc/fstab"
1988fae3551SRodney W. Grimes #endif
1998fae3551SRodney W. Grimes 
2008fae3551SRodney W. Grimes #ifdef sunos
2018fae3551SRodney W. Grimes extern char *calloc();
2028fae3551SRodney W. Grimes extern char *malloc();
2038fae3551SRodney W. Grimes extern long atol();
2048fae3551SRodney W. Grimes extern char *strcpy();
2058fae3551SRodney W. Grimes extern char *strncpy();
2068fae3551SRodney W. Grimes extern char *strcat();
2078fae3551SRodney W. Grimes extern time_t time();
2088fae3551SRodney W. Grimes extern void endgrent();
2098fae3551SRodney W. Grimes extern __dead void exit();
2108fae3551SRodney W. Grimes extern off_t lseek();
2118fae3551SRodney W. Grimes extern const char *strerror();
2128fae3551SRodney W. Grimes #endif
213