xref: /original-bsd/sbin/dump/dump.h (revision 42f60e33)
1 /*-
2  * Copyright (c) 1980, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)dump.h	8.1 (Berkeley) 06/05/93
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 int	nonodump;	/* if set, do not honor UF_NODUMP user flags */
51 
52 int	notify;		/* notify operator flag */
53 int	blockswritten;	/* number of blocks written on current tape */
54 int	tapeno;		/* current tape number */
55 time_t	tstart_writing;	/* when started writing the first tape block */
56 struct	fs *sblock;	/* the file system super block */
57 char	sblock_buf[MAXBSIZE];
58 long	dev_bsize;	/* block size of underlying disk device */
59 int	dev_bshift;	/* log2(dev_bsize) */
60 int	tp_bshift;	/* log2(TP_BSIZE) */
61 
62 #ifndef __P
63 #include <sys/cdefs.h>
64 #endif
65 
66 /* operator interface functions */
67 void	broadcast __P((char *message));
68 void	lastdump __P((int arg));	/* int should be char */
69 void	msg __P((const char *fmt, ...));
70 void	msgtail __P((const char *fmt, ...));
71 int	query __P((char *question));
72 void	quit __P((const char *fmt, ...));
73 void	set_operators __P((void));
74 void	timeest __P((void));
75 time_t	unctime __P((char *str));
76 
77 /* mapping rouintes */
78 struct	dinode;
79 long	blockest __P((struct dinode *dp));
80 int	mapfiles __P((ino_t maxino, long *tapesize));
81 int	mapdirs __P((ino_t maxino, long *tapesize));
82 
83 /* file dumping routines */
84 void	blksout __P((daddr_t *blkp, int frags, ino_t ino));
85 void	bread __P((daddr_t blkno, char *buf, int size));
86 void	dumpino __P((struct dinode *dp, ino_t ino));
87 void	dumpmap __P((char *map, int type, ino_t ino));
88 void	writeheader __P((ino_t ino));
89 
90 /* tape writing routines */
91 int	alloctape __P((void));
92 void	close_rewind __P((void));
93 void	dumpblock __P((daddr_t blkno, int size));
94 void	startnewtape __P((int top));
95 void	trewind __P((void));
96 void	writerec __P((char *dp, int isspcl));
97 
98 __dead void Exit __P((int status));
99 void	dumpabort __P((int signo));
100 void	getfstab __P((void));
101 
102 char	*rawname __P((char *cp));
103 struct	dinode *getino __P((ino_t inum));
104 
105 /* rdump routines */
106 #ifdef RDUMP
107 void	rmtclose __P((void));
108 int	rmthost __P((char *host));
109 int	rmtopen __P((char *tape, int mode));
110 int	rmtwrite __P((char *buf, int count));
111 #endif /* RDUMP */
112 
113 void	interrupt __P((int signo));	/* in case operator bangs on console */
114 
115 /*
116  *	Exit status codes
117  */
118 #define	X_FINOK		0	/* normal exit */
119 #define	X_REWRITE	2	/* restart writing from the check point */
120 #define	X_ABORT		3	/* abort dump; don't attempt checkpointing */
121 
122 #define	OPGRENT	"operator"		/* group entry to notify */
123 #define DIALUP	"ttyd"			/* prefix for dialups */
124 
125 struct	fstab *fstabsearch __P((char *key));	/* search fs_file and fs_spec */
126 
127 #ifndef NAME_MAX
128 #define NAME_MAX 255
129 #endif
130 
131 /*
132  *	The contents of the file _PATH_DUMPDATES is maintained both on
133  *	a linked list, and then (eventually) arrayified.
134  */
135 struct dumpdates {
136 	char	dd_name[NAME_MAX+3];
137 	char	dd_level;
138 	time_t	dd_ddate;
139 };
140 struct dumptime {
141 	struct	dumpdates dt_value;
142 	struct	dumptime *dt_next;
143 };
144 struct	dumptime *dthead;	/* head of the list version */
145 int	nddates;		/* number of records (might be zero) */
146 int	ddates_in;		/* we have read the increment file */
147 struct	dumpdates **ddatev;	/* the arrayfied version */
148 void	initdumptimes __P((void));
149 void	getdumptime __P((void));
150 void	putdumptime __P((void));
151 #define	ITITERATE(i, ddp) \
152 	for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i])
153 
154 void	sig __P((int signo));
155 
156 /*
157  * Compatibility with old systems.
158  */
159 #ifdef COMPAT
160 #include <sys/file.h>
161 extern char *index(), *rindex(), *strdup();
162 extern char *ctime();
163 extern int read(), write();
164 extern int errno;
165 #endif
166 
167 #ifndef	_PATH_UTMP
168 #define	_PATH_UTMP	"/etc/utmp"
169 #endif
170 #ifndef	_PATH_FSTAB
171 #define	_PATH_FSTAB	"/etc/fstab"
172 #endif
173 
174 #ifdef sunos
175 extern char *calloc();
176 extern char *malloc();
177 extern long atol();
178 extern char *strcpy();
179 extern char *strncpy();
180 extern char *strcat();
181 extern time_t time();
182 extern void endgrent();
183 extern __dead void exit();
184 extern off_t lseek();
185 extern const char *strerror();
186 #endif
187