dump.h revision 1.7 1 1.1 cgd /*-
2 1.7 mycroft * Copyright (c) 1980, 1993
3 1.7 mycroft * The Regents of the University of California. All rights reserved.
4 1.1 cgd *
5 1.1 cgd * Redistribution and use in source and binary forms, with or without
6 1.1 cgd * modification, are permitted provided that the following conditions
7 1.1 cgd * are met:
8 1.1 cgd * 1. Redistributions of source code must retain the above copyright
9 1.1 cgd * notice, this list of conditions and the following disclaimer.
10 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright
11 1.1 cgd * notice, this list of conditions and the following disclaimer in the
12 1.1 cgd * documentation and/or other materials provided with the distribution.
13 1.1 cgd * 3. All advertising materials mentioning features or use of this software
14 1.1 cgd * must display the following acknowledgement:
15 1.1 cgd * This product includes software developed by the University of
16 1.1 cgd * California, Berkeley and its contributors.
17 1.1 cgd * 4. Neither the name of the University nor the names of its contributors
18 1.1 cgd * may be used to endorse or promote products derived from this software
19 1.1 cgd * without specific prior written permission.
20 1.1 cgd *
21 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 1.1 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 1.1 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 1.1 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 1.1 cgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 1.1 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 1.1 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 1.1 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 1.1 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 1.1 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 1.1 cgd * SUCH DAMAGE.
32 1.1 cgd *
33 1.7 mycroft * from: @(#)dump.h 8.1 (Berkeley) 6/5/93
34 1.7 mycroft * $Id: dump.h,v 1.7 1994/06/08 18:57:33 mycroft Exp $
35 1.1 cgd */
36 1.1 cgd
37 1.1 cgd #define MAXINOPB (MAXBSIZE / sizeof(struct dinode))
38 1.1 cgd #define MAXNINDIR (MAXBSIZE / sizeof(daddr_t))
39 1.1 cgd
40 1.1 cgd /*
41 1.1 cgd * Dump maps used to describe what is to be dumped.
42 1.1 cgd */
43 1.1 cgd int mapsize; /* size of the state maps */
44 1.1 cgd char *usedinomap; /* map of allocated inodes */
45 1.1 cgd char *dumpdirmap; /* map of directories to be dumped */
46 1.1 cgd char *dumpinomap; /* map of files to be dumped */
47 1.1 cgd /*
48 1.1 cgd * Map manipulation macros.
49 1.1 cgd */
50 1.1 cgd #define SETINO(ino, map) \
51 1.1 cgd map[(u_int)((ino) - 1) / NBBY] |= 1 << ((u_int)((ino) - 1) % NBBY)
52 1.1 cgd #define CLRINO(ino, map) \
53 1.1 cgd map[(u_int)((ino) - 1) / NBBY] &= ~(1 << ((u_int)((ino) - 1) % NBBY))
54 1.1 cgd #define TSTINO(ino, map) \
55 1.1 cgd (map[(u_int)((ino) - 1) / NBBY] & (1 << ((u_int)((ino) - 1) % NBBY)))
56 1.1 cgd
57 1.1 cgd /*
58 1.1 cgd * All calculations done in 0.1" units!
59 1.1 cgd */
60 1.1 cgd char *disk; /* name of the disk file */
61 1.1 cgd char *tape; /* name of the tape file */
62 1.1 cgd char *dumpdates; /* name of the file containing dump date information*/
63 1.1 cgd char *temp; /* name of the file for doing rewrite of dumpdates */
64 1.1 cgd char lastlevel; /* dump level of previous dump */
65 1.1 cgd char level; /* dump level of this dump */
66 1.1 cgd int uflag; /* update flag */
67 1.1 cgd int diskfd; /* disk file descriptor */
68 1.1 cgd int tapefd; /* tape file descriptor */
69 1.1 cgd int pipeout; /* true => output to standard output */
70 1.1 cgd ino_t curino; /* current inumber; used globally */
71 1.1 cgd int newtape; /* new tape flag */
72 1.1 cgd int density; /* density in 0.1" units */
73 1.1 cgd long tapesize; /* estimated tape size, blocks */
74 1.1 cgd long tsize; /* tape size in 0.1" units */
75 1.1 cgd long asize; /* number of 0.1" units written on current tape */
76 1.1 cgd int etapes; /* estimated number of tapes */
77 1.7 mycroft int nonodump; /* if set, do not honor UF_NODUMP user flags */
78 1.1 cgd
79 1.1 cgd int notify; /* notify operator flag */
80 1.1 cgd int blockswritten; /* number of blocks written on current tape */
81 1.1 cgd int tapeno; /* current tape number */
82 1.1 cgd time_t tstart_writing; /* when started writing the first tape block */
83 1.1 cgd struct fs *sblock; /* the file system super block */
84 1.6 cgd char sblock_buf[MAXBSIZE];
85 1.1 cgd long dev_bsize; /* block size of underlying disk device */
86 1.1 cgd int dev_bshift; /* log2(dev_bsize) */
87 1.1 cgd int tp_bshift; /* log2(TP_BSIZE) */
88 1.1 cgd
89 1.7 mycroft #ifndef __P
90 1.7 mycroft #include <sys/cdefs.h>
91 1.7 mycroft #endif
92 1.7 mycroft
93 1.1 cgd /* operator interface functions */
94 1.6 cgd void broadcast __P((char *message));
95 1.6 cgd void lastdump __P((int arg)); /* int should be char */
96 1.6 cgd void msg __P((const char *fmt, ...));
97 1.6 cgd void msgtail __P((const char *fmt, ...));
98 1.6 cgd int query __P((char *question));
99 1.6 cgd void quit __P((const char *fmt, ...));
100 1.6 cgd void set_operators __P((void));
101 1.6 cgd void timeest __P((void));
102 1.6 cgd time_t unctime __P((char *str));
103 1.1 cgd
104 1.1 cgd /* mapping rouintes */
105 1.6 cgd struct dinode;
106 1.6 cgd long blockest __P((struct dinode *dp));
107 1.6 cgd int mapfiles __P((ino_t maxino, long *tapesize));
108 1.6 cgd int mapdirs __P((ino_t maxino, long *tapesize));
109 1.1 cgd
110 1.1 cgd /* file dumping routines */
111 1.6 cgd void blksout __P((daddr_t *blkp, int frags, ino_t ino));
112 1.6 cgd void bread __P((daddr_t blkno, char *buf, int size));
113 1.6 cgd void dumpino __P((struct dinode *dp, ino_t ino));
114 1.6 cgd void dumpmap __P((char *map, int type, ino_t ino));
115 1.6 cgd void writeheader __P((ino_t ino));
116 1.1 cgd
117 1.1 cgd /* tape writing routines */
118 1.6 cgd int alloctape __P((void));
119 1.6 cgd void close_rewind __P((void));
120 1.6 cgd void dumpblock __P((daddr_t blkno, int size));
121 1.6 cgd void startnewtape __P((int top));
122 1.6 cgd void trewind __P((void));
123 1.6 cgd void writerec __P((char *dp, int isspcl));
124 1.6 cgd
125 1.7 mycroft __dead void Exit __P((int status));
126 1.6 cgd void dumpabort __P((int signo));
127 1.6 cgd void getfstab __P((void));
128 1.1 cgd
129 1.6 cgd char *rawname __P((char *cp));
130 1.6 cgd struct dinode *getino __P((ino_t inum));
131 1.1 cgd
132 1.7 mycroft /* rdump routines */
133 1.7 mycroft #ifdef RDUMP
134 1.7 mycroft void rmtclose __P((void));
135 1.7 mycroft int rmthost __P((char *host));
136 1.7 mycroft int rmtopen __P((char *tape, int mode));
137 1.7 mycroft int rmtwrite __P((char *buf, int count));
138 1.7 mycroft #endif /* RDUMP */
139 1.7 mycroft
140 1.6 cgd void interrupt __P((int signo)); /* in case operator bangs on console */
141 1.1 cgd
142 1.1 cgd /*
143 1.1 cgd * Exit status codes
144 1.1 cgd */
145 1.1 cgd #define X_FINOK 0 /* normal exit */
146 1.1 cgd #define X_REWRITE 2 /* restart writing from the check point */
147 1.6 cgd #define X_ABORT 3 /* abort dump; don't attempt checkpointing */
148 1.1 cgd
149 1.1 cgd #define OPGRENT "operator" /* group entry to notify */
150 1.1 cgd #define DIALUP "ttyd" /* prefix for dialups */
151 1.1 cgd
152 1.6 cgd struct fstab *fstabsearch __P((char *key)); /* search fs_file and fs_spec */
153 1.6 cgd
154 1.6 cgd #ifndef NAME_MAX
155 1.6 cgd #define NAME_MAX 255
156 1.6 cgd #endif
157 1.1 cgd
158 1.1 cgd /*
159 1.1 cgd * The contents of the file _PATH_DUMPDATES is maintained both on
160 1.1 cgd * a linked list, and then (eventually) arrayified.
161 1.1 cgd */
162 1.1 cgd struct dumpdates {
163 1.6 cgd char dd_name[NAME_MAX+3];
164 1.1 cgd char dd_level;
165 1.1 cgd time_t dd_ddate;
166 1.1 cgd };
167 1.1 cgd struct dumptime {
168 1.1 cgd struct dumpdates dt_value;
169 1.1 cgd struct dumptime *dt_next;
170 1.1 cgd };
171 1.1 cgd struct dumptime *dthead; /* head of the list version */
172 1.1 cgd int nddates; /* number of records (might be zero) */
173 1.1 cgd int ddates_in; /* we have read the increment file */
174 1.1 cgd struct dumpdates **ddatev; /* the arrayfied version */
175 1.6 cgd void initdumptimes __P((void));
176 1.6 cgd void getdumptime __P((void));
177 1.6 cgd void putdumptime __P((void));
178 1.1 cgd #define ITITERATE(i, ddp) \
179 1.6 cgd for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i])
180 1.1 cgd
181 1.6 cgd void sig __P((int signo));
182 1.1 cgd
183 1.1 cgd /*
184 1.1 cgd * Compatibility with old systems.
185 1.1 cgd */
186 1.7 mycroft #ifdef COMPAT
187 1.1 cgd #include <sys/file.h>
188 1.7 mycroft extern char *index(), *rindex(), *strdup();
189 1.1 cgd extern char *ctime();
190 1.7 mycroft extern int read(), write();
191 1.1 cgd extern int errno;
192 1.6 cgd #endif
193 1.6 cgd
194 1.7 mycroft #ifndef _PATH_UTMP
195 1.7 mycroft #define _PATH_UTMP "/etc/utmp"
196 1.7 mycroft #endif
197 1.7 mycroft #ifndef _PATH_FSTAB
198 1.7 mycroft #define _PATH_FSTAB "/etc/fstab"
199 1.7 mycroft #endif
200 1.7 mycroft
201 1.6 cgd #ifdef sunos
202 1.6 cgd extern char *calloc();
203 1.6 cgd extern char *malloc();
204 1.6 cgd extern long atol();
205 1.6 cgd extern char *strcpy();
206 1.6 cgd extern char *strncpy();
207 1.6 cgd extern char *strcat();
208 1.6 cgd extern time_t time();
209 1.6 cgd extern void endgrent();
210 1.7 mycroft extern __dead void exit();
211 1.6 cgd extern off_t lseek();
212 1.7 mycroft extern const char *strerror();
213 1.1 cgd #endif
214