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