xref: /freebsd/sbin/dump/dump.h (revision 89fdc4e1)
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  *
33a37c38b8SPeter Wemm  *	@(#)dump.h	8.2 (Berkeley) 4/28/95
34941ee632SPoul-Henning Kamp  *
35941ee632SPoul-Henning Kamp  * $FreeBSD$
368fae3551SRodney W. Grimes  */
378fae3551SRodney W. Grimes 
388fae3551SRodney W. Grimes /*
398fae3551SRodney W. Grimes  * Dump maps used to describe what is to be dumped.
408fae3551SRodney W. Grimes  */
418fae3551SRodney W. Grimes int	mapsize;	/* size of the state maps */
428fae3551SRodney W. Grimes char	*usedinomap;	/* map of allocated inodes */
438fae3551SRodney W. Grimes char	*dumpdirmap;	/* map of directories to be dumped */
448fae3551SRodney W. Grimes char	*dumpinomap;	/* map of files to be dumped */
458fae3551SRodney W. Grimes /*
468fae3551SRodney W. Grimes  * Map manipulation macros.
478fae3551SRodney W. Grimes  */
488fae3551SRodney W. Grimes #define	SETINO(ino, map) \
4989fdc4e1SMike Barcroft 	map[(u_int)((ino) - 1) / CHAR_BIT] |= \
5089fdc4e1SMike Barcroft 	    1 << ((u_int)((ino) - 1) % CHAR_BIT)
518fae3551SRodney W. Grimes #define	CLRINO(ino, map) \
5289fdc4e1SMike Barcroft 	map[(u_int)((ino) - 1) / CHAR_BIT] &= \
5389fdc4e1SMike Barcroft 	    ~(1 << ((u_int)((ino) - 1) % CHAR_BIT))
548fae3551SRodney W. Grimes #define	TSTINO(ino, map) \
5589fdc4e1SMike Barcroft 	(map[(u_int)((ino) - 1) / CHAR_BIT] & \
5689fdc4e1SMike Barcroft 	    (1 << ((u_int)((ino) - 1) % CHAR_BIT)))
578fae3551SRodney W. Grimes 
588fae3551SRodney W. Grimes /*
598fae3551SRodney W. Grimes  *	All calculations done in 0.1" units!
608fae3551SRodney W. Grimes  */
618fae3551SRodney W. Grimes char	*disk;		/* name of the disk file */
628fae3551SRodney W. Grimes char	*tape;		/* name of the tape file */
638fae3551SRodney W. Grimes char	*dumpdates;	/* name of the file containing dump date information*/
648fae3551SRodney W. Grimes char	*temp;		/* name of the file for doing rewrite of dumpdates */
658fae3551SRodney W. Grimes char	lastlevel;	/* dump level of previous dump */
668fae3551SRodney W. Grimes char	level;		/* dump level of this dump */
678fae3551SRodney W. Grimes int	uflag;		/* update flag */
688fae3551SRodney W. Grimes int	diskfd;		/* disk file descriptor */
698fae3551SRodney W. Grimes int	tapefd;		/* tape file descriptor */
708fae3551SRodney W. Grimes int	pipeout;	/* true => output to standard output */
718fae3551SRodney W. Grimes ino_t	curino;		/* current inumber; used globally */
728fae3551SRodney W. Grimes int	newtape;	/* new tape flag */
738fae3551SRodney W. Grimes int	density;	/* density in 0.1" units */
748fae3551SRodney W. Grimes long	tapesize;	/* estimated tape size, blocks */
758fae3551SRodney W. Grimes long	tsize;		/* tape size in 0.1" units */
768fae3551SRodney W. Grimes long	asize;		/* number of 0.1" units written on current tape */
778fae3551SRodney W. Grimes int	etapes;		/* estimated number of tapes */
788fae3551SRodney W. Grimes int	nonodump;	/* if set, do not honor UF_NODUMP user flags */
79af00957eSJoerg Wunsch int	unlimited;	/* if set, write to end of medium */
808fae3551SRodney W. Grimes 
818fae3551SRodney W. Grimes int	notify;		/* notify operator flag */
828fae3551SRodney W. Grimes int	blockswritten;	/* number of blocks written on current tape */
838fae3551SRodney W. Grimes int	tapeno;		/* current tape number */
848fae3551SRodney W. Grimes time_t	tstart_writing;	/* when started writing the first tape block */
85019420a5SJoerg Wunsch time_t	tend_writing;	/* after writing the last tape block */
862bb823d2SIan Dowse int	passno;		/* current dump pass number */
878fae3551SRodney W. Grimes struct	fs *sblock;	/* the file system super block */
888fae3551SRodney W. Grimes char	sblock_buf[MAXBSIZE];
898fae3551SRodney W. Grimes long	dev_bsize;	/* block size of underlying disk device */
908fae3551SRodney W. Grimes int	dev_bshift;	/* log2(dev_bsize) */
918fae3551SRodney W. Grimes int	tp_bshift;	/* log2(TP_BSIZE) */
928fae3551SRodney W. Grimes 
938fae3551SRodney W. Grimes /* operator interface functions */
942db673abSWarner Losh void	broadcast(const char *message);
952db673abSWarner Losh void	infosch(int);
962db673abSWarner Losh void	lastdump(int arg);	/* int should be char */
972db673abSWarner Losh void	msg(const char *fmt, ...) __printflike(1, 2);
982db673abSWarner Losh void	msgtail(const char *fmt, ...) __printflike(1, 2);
992db673abSWarner Losh int	query(const char *question);
1002db673abSWarner Losh void	quit(const char *fmt, ...) __printflike(1, 2);
1012db673abSWarner Losh void	timeest(void);
1022db673abSWarner Losh time_t	unctime(char *str);
1038fae3551SRodney W. Grimes 
1048fae3551SRodney W. Grimes /* mapping rouintes */
1051c85e6a3SKirk McKusick union	dinode;
1061c85e6a3SKirk McKusick long	blockest(union dinode *dp);
1072db673abSWarner Losh int	mapfiles(ino_t maxino, long *tapesize);
1082db673abSWarner Losh int	mapdirs(ino_t maxino, long *tapesize);
1098fae3551SRodney W. Grimes 
1108fae3551SRodney W. Grimes /* file dumping routines */
1111c85e6a3SKirk McKusick void	ufs1_blksout(ufs1_daddr_t *blkp, int frags, ino_t ino);
1121c85e6a3SKirk McKusick void	ufs2_blksout(ufs2_daddr_t *blkp, int frags, ino_t ino);
1131c85e6a3SKirk McKusick void	bread(ufs2_daddr_t blkno, char *buf, int size);
1141c85e6a3SKirk McKusick void	dumpino(union dinode *dp, ino_t ino);
1152db673abSWarner Losh void	dumpmap(char *map, int type, ino_t ino);
1162db673abSWarner Losh void	writeheader(ino_t ino);
1178fae3551SRodney W. Grimes 
1188fae3551SRodney W. Grimes /* tape writing routines */
1192db673abSWarner Losh int	alloctape(void);
1202db673abSWarner Losh void	close_rewind(void);
1211c85e6a3SKirk McKusick void	dumpblock(ufs2_daddr_t blkno, int size);
1222db673abSWarner Losh void	startnewtape(int top);
1232db673abSWarner Losh void	trewind(void);
1242db673abSWarner Losh void	writerec(char *dp, int isspcl);
1258fae3551SRodney W. Grimes 
1262db673abSWarner Losh void	Exit(int status) __dead2;
1272db673abSWarner Losh void	dumpabort(int signo);
1282db673abSWarner Losh void	getfstab(void);
1298fae3551SRodney W. Grimes 
1302db673abSWarner Losh char	*rawname(char *cp);
1311c85e6a3SKirk McKusick union	dinode *getino(ino_t inum, int *mode);
1328fae3551SRodney W. Grimes 
1338fae3551SRodney W. Grimes /* rdump routines */
1348fae3551SRodney W. Grimes #ifdef RDUMP
1352db673abSWarner Losh void	rmtclose(void);
1362db673abSWarner Losh int	rmthost(const char *host);
1372db673abSWarner Losh int	rmtopen(const char *tape, int mode);
1382db673abSWarner Losh int	rmtwrite(const char *buf, int count);
1398fae3551SRodney W. Grimes #endif /* RDUMP */
1408fae3551SRodney W. Grimes 
1412db673abSWarner Losh void	interrupt(int signo);	/* in case operator bangs on console */
1428fae3551SRodney W. Grimes 
1438fae3551SRodney W. Grimes /*
1448fae3551SRodney W. Grimes  *	Exit status codes
1458fae3551SRodney W. Grimes  */
1468fae3551SRodney W. Grimes #define	X_FINOK		0	/* normal exit */
147f69e804dSJoseph Koshy #define	X_STARTUP	1	/* startup error */
1488fae3551SRodney W. Grimes #define	X_REWRITE	2	/* restart writing from the check point */
1498fae3551SRodney W. Grimes #define	X_ABORT		3	/* abort dump; don't attempt checkpointing */
1508fae3551SRodney W. Grimes 
1518fae3551SRodney W. Grimes #define	OPGRENT	"operator"		/* group entry to notify */
1528fae3551SRodney W. Grimes 
1532db673abSWarner Losh struct	fstab *fstabsearch(const char *key); /* search fs_file and fs_spec */
1548fae3551SRodney W. Grimes 
1558fae3551SRodney W. Grimes #ifndef NAME_MAX
1568fae3551SRodney W. Grimes #define NAME_MAX 255
1578fae3551SRodney W. Grimes #endif
1588fae3551SRodney W. Grimes 
1598fae3551SRodney W. Grimes /*
1608fae3551SRodney W. Grimes  *	The contents of the file _PATH_DUMPDATES is maintained both on
1618fae3551SRodney W. Grimes  *	a linked list, and then (eventually) arrayified.
1628fae3551SRodney W. Grimes  */
1638fae3551SRodney W. Grimes struct dumpdates {
1648fae3551SRodney W. Grimes 	char	dd_name[NAME_MAX+3];
1658fae3551SRodney W. Grimes 	char	dd_level;
1668fae3551SRodney W. Grimes 	time_t	dd_ddate;
1678fae3551SRodney W. Grimes };
1688fae3551SRodney W. Grimes int	nddates;		/* number of records (might be zero) */
1698fae3551SRodney W. Grimes int	ddates_in;		/* we have read the increment file */
1708fae3551SRodney W. Grimes struct	dumpdates **ddatev;	/* the arrayfied version */
1712db673abSWarner Losh void	initdumptimes(void);
1722db673abSWarner Losh void	getdumptime(void);
1732db673abSWarner Losh void	putdumptime(void);
1748fae3551SRodney W. Grimes #define	ITITERATE(i, ddp) \
1758fae3551SRodney W. Grimes 	for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i])
1768fae3551SRodney W. Grimes 
1772db673abSWarner Losh void	sig(int signo);
1788fae3551SRodney W. Grimes 
1798fae3551SRodney W. Grimes #ifndef	_PATH_FSTAB
1808fae3551SRodney W. Grimes #define	_PATH_FSTAB	"/etc/fstab"
1818fae3551SRodney W. Grimes #endif
182