xref: /original-bsd/sbin/dump/dump.h (revision 4463b7c2)
1 /*-
2  * Copyright (c) 1980 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)dump.h	5.21 (Berkeley) 07/16/92
8  */
9 
10 #define MAXINOPB	(MAXBSIZE / sizeof(struct dinode))
11 #define MAXNINDIR	(MAXBSIZE / sizeof(daddr_t))
12 
13 /*
14  * Dump maps used to describe what is to be dumped.
15  */
16 int	mapsize;	/* size of the state maps */
17 char	*usedinomap;	/* map of allocated inodes */
18 char	*dumpdirmap;	/* map of directories to be dumped */
19 char	*dumpinomap;	/* map of files to be dumped */
20 /*
21  * Map manipulation macros.
22  */
23 #define	SETINO(ino, map) \
24 	map[(u_int)((ino) - 1) / NBBY] |=  1 << ((u_int)((ino) - 1) % NBBY)
25 #define	CLRINO(ino, map) \
26 	map[(u_int)((ino) - 1) / NBBY] &=  ~(1 << ((u_int)((ino) - 1) % NBBY))
27 #define	TSTINO(ino, map) \
28 	(map[(u_int)((ino) - 1) / NBBY] &  (1 << ((u_int)((ino) - 1) % NBBY)))
29 
30 /*
31  *	All calculations done in 0.1" units!
32  */
33 char	*disk;		/* name of the disk file */
34 char	*tape;		/* name of the tape file */
35 char	*dumpdates;	/* name of the file containing dump date information*/
36 char	*temp;		/* name of the file for doing rewrite of dumpdates */
37 char	lastlevel;	/* dump level of previous dump */
38 char	level;		/* dump level of this dump */
39 int	uflag;		/* update flag */
40 int	diskfd;		/* disk file descriptor */
41 int	tapefd;		/* tape file descriptor */
42 int	pipeout;	/* true => output to standard output */
43 ino_t	curino;		/* current inumber; used globally */
44 int	newtape;	/* new tape flag */
45 int	density;	/* density in 0.1" units */
46 long	tapesize;	/* estimated tape size, blocks */
47 long	tsize;		/* tape size in 0.1" units */
48 long	asize;		/* number of 0.1" units written on current tape */
49 int	etapes;		/* estimated number of tapes */
50 
51 int	notify;		/* notify operator flag */
52 int	blockswritten;	/* number of blocks written on current tape */
53 int	tapeno;		/* current tape number */
54 time_t	tstart_writing;	/* when started writing the first tape block */
55 struct	fs *sblock;	/* the file system super block */
56 char	sblock_buf[MAXBSIZE];
57 long	dev_bsize;	/* block size of underlying disk device */
58 int	dev_bshift;	/* log2(dev_bsize) */
59 int	tp_bshift;	/* log2(TP_BSIZE) */
60 
61 /* operator interface functions */
62 void	broadcast __P((char *message));
63 void	lastdump __P((int arg));	/* int should be char */
64 void	msg __P((const char *fmt, ...));
65 void	msgtail __P((const char *fmt, ...));
66 int	query __P((char *question));
67 void	quit __P((const char *fmt, ...));
68 void	set_operators __P((void));
69 void	timeest __P((void));
70 time_t	unctime __P((char *str));
71 
72 /* mapping rouintes */
73 struct	dinode;
74 long	blockest __P((struct dinode *dp));
75 int	mapfiles __P((ino_t maxino, long *tapesize));
76 int	mapdirs __P((ino_t maxino, long *tapesize));
77 
78 /* file dumping routines */
79 void	blksout __P((daddr_t *blkp, int frags, ino_t ino));
80 void	bread __P((daddr_t blkno, char *buf, int size));
81 void	dumpino __P((struct dinode *dp, ino_t ino));
82 void	dumpmap __P((char *map, int type, ino_t ino));
83 void	writeheader __P((ino_t ino));
84 
85 /* tape writing routines */
86 int	alloctape __P((void));
87 void	close_rewind __P((void));
88 void	dumpblock __P((daddr_t blkno, int size));
89 void	flushtape __P((void));
90 void	startnewtape __P((int top));
91 void	trewind __P((void));
92 void	writerec __P((char *dp, int isspcl));
93 
94 void	Exit __P((int status));
95 void	dumpabort __P((int signo));
96 void	getfstab __P((void));
97 
98 char	*rawname __P((char *cp));
99 struct	dinode *getino __P((ino_t inum));
100 
101 void	interrupt __P((int signo));	/* in case operator bangs on console */
102 
103 /*
104  *	Exit status codes
105  */
106 #define	X_FINOK		0	/* normal exit */
107 #define	X_REWRITE	2	/* restart writing from the check point */
108 #define	X_ABORT		3	/* abort dump; don't attempt checkpointing */
109 
110 #define	OPGRENT	"operator"		/* group entry to notify */
111 #define DIALUP	"ttyd"			/* prefix for dialups */
112 
113 struct	fstab *fstabsearch __P((char *key));	/* search fs_file and fs_spec */
114 
115 #ifndef NAME_MAX
116 #define NAME_MAX 255
117 #endif
118 
119 /*
120  *	The contents of the file _PATH_DUMPDATES is maintained both on
121  *	a linked list, and then (eventually) arrayified.
122  */
123 struct dumpdates {
124 	char	dd_name[NAME_MAX+3];
125 	char	dd_level;
126 	time_t	dd_ddate;
127 };
128 struct dumptime {
129 	struct	dumpdates dt_value;
130 	struct	dumptime *dt_next;
131 };
132 struct	dumptime *dthead;	/* head of the list version */
133 int	nddates;		/* number of records (might be zero) */
134 int	ddates_in;		/* we have read the increment file */
135 struct	dumpdates **ddatev;	/* the arrayfied version */
136 void	initdumptimes __P((void));
137 void	getdumptime __P((void));
138 void	putdumptime __P((void));
139 #define	ITITERATE(i, ddp) \
140 	for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i])
141 
142 void	sig __P((int signo));
143 
144 /*
145  * Compatibility with old systems.
146  */
147 #ifndef __STDC__
148 #include <sys/file.h>
149 #define _PATH_FSTAB	"/etc/fstab"
150 extern char *index(), *strdup();
151 extern char *ctime();
152 extern int errno;
153 #endif
154 
155 #ifdef sunos
156 extern char *calloc();
157 extern char *malloc();
158 extern long atol();
159 extern char *strcpy();
160 extern char *strncpy();
161 extern char *strcat();
162 extern time_t time();
163 extern void endgrent();
164 extern void exit();
165 extern off_t lseek();
166 extern char *strerror();
167 #endif
168