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.19 (Berkeley) 06/18/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 time_t unctime __P((char *str)); 65 #if __STDC__ 66 void msg(const char *fmt, ...); 67 void msgtail(const char *fmt, ...); 68 void quit(const char *fmt, ...); 69 #else 70 void msg(); 71 void msgtail(); 72 void quit(); 73 #endif 74 int query __P((char *question)); 75 void set_operators __P(()); 76 void timeest __P(()); 77 78 /* mapping rouintes */ 79 struct dinode; 80 long blockest __P((struct dinode *dp)); 81 int mapfiles __P((ino_t maxino, long *tapesize)); 82 int mapdirs __P((ino_t maxino, long *tapesize)); 83 84 /* file dumping routines */ 85 void dumpino __P((struct dinode *dp, ino_t ino)); 86 void blksout __P((daddr_t *blkp, int frags, ino_t ino)); 87 void dumpmap __P((char *map, int type, ino_t ino)); 88 void writeheader __P((ino_t ino)); 89 void bread __P((daddr_t blkno, char *buf, int size)); 90 91 /* tape writing routines */ 92 int alloctape __P(()); 93 void writerec __P((char *dp)); 94 void dumpblock __P((daddr_t blkno, int size)); 95 void flushtape __P(()); 96 void trewind __P(()); 97 void close_rewind __P(()); 98 void startnewtape __P(()); 99 100 void dumpabort __P(()); 101 void Exit __P((int status)); 102 void getfstab __P(()); 103 104 char *rawname __P((char *cp)); 105 struct dinode *getino __P((ino_t inum)); 106 107 void interrupt __P(()); /* in case operator bangs on console */ 108 109 /* 110 * Exit status codes 111 */ 112 #define X_FINOK 0 /* normal exit */ 113 #define X_REWRITE 2 /* restart writing from the check point */ 114 #define X_ABORT 3 /* abort dump; don't attempt checkpointing */ 115 116 #define OPGRENT "operator" /* group entry to notify */ 117 #define DIALUP "ttyd" /* prefix for dialups */ 118 119 struct fstab *fstabsearch __P((char *key)); /* search fs_file and fs_spec */ 120 121 #ifndef NAME_MAX 122 #define NAME_MAX 255 123 #endif 124 125 /* 126 * The contents of the file _PATH_DUMPDATES is maintained both on 127 * a linked list, and then (eventually) arrayified. 128 */ 129 struct dumpdates { 130 char dd_name[NAME_MAX+3]; 131 char dd_level; 132 time_t dd_ddate; 133 }; 134 struct dumptime { 135 struct dumpdates dt_value; 136 struct dumptime *dt_next; 137 }; 138 struct dumptime *dthead; /* head of the list version */ 139 int nddates; /* number of records (might be zero) */ 140 int ddates_in; /* we have read the increment file */ 141 struct dumpdates **ddatev; /* the arrayfied version */ 142 void initdumptimes __P(()); 143 void getdumptime __P(()); 144 void putdumptime __P(()); 145 #define ITITERATE(i, ddp) \ 146 for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i]) 147 148 /* 149 * We catch these interrupts 150 */ 151 void sighup __P(()); 152 void sigtrap __P(()); 153 void sigfpe __P(()); 154 void sigbus __P(()); 155 void sigsegv __P(()); 156 void sigalrm __P(()); 157 void sigterm __P(()); 158 159 /* 160 * Compatibility with old systems. 161 */ 162 #ifndef __STDC__ 163 #include <sys/file.h> 164 #define _PATH_FSTAB "/etc/fstab" 165 extern char *index(), *strdup(); 166 extern char *ctime(); 167 extern int errno; 168 #endif 169 170 #ifdef sunos 171 extern char *calloc(); 172 extern char *malloc(); 173 extern long atol(); 174 extern char *strcpy(); 175 extern char *strncpy(); 176 extern char *strcat(); 177 extern time_t time(); 178 extern void endgrent(); 179 extern void exit(); 180 extern off_t lseek(); 181 extern char *strerror(); 182 #endif 183