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.22 (Berkeley) 01/25/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 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 startnewtape __P((int top)); 90 void trewind __P((void)); 91 void writerec __P((char *dp, int isspcl)); 92 93 void Exit __P((int status)); 94 void dumpabort __P((int signo)); 95 void getfstab __P((void)); 96 97 char *rawname __P((char *cp)); 98 struct dinode *getino __P((ino_t inum)); 99 100 /* rdump routines */ 101 #ifdef RDUMP 102 void rmtclose __P((void)); 103 int rmthost __P((char *host)); 104 int rmtopen __P((char *tape, int mode)); 105 int rmtwrite __P((char *buf, int count)); 106 #endif /* RDUMP */ 107 108 void interrupt __P((int signo)); /* in case operator bangs on console */ 109 110 /* 111 * Exit status codes 112 */ 113 #define X_FINOK 0 /* normal exit */ 114 #define X_REWRITE 2 /* restart writing from the check point */ 115 #define X_ABORT 3 /* abort dump; don't attempt checkpointing */ 116 117 #define OPGRENT "operator" /* group entry to notify */ 118 #define DIALUP "ttyd" /* prefix for dialups */ 119 120 struct fstab *fstabsearch __P((char *key)); /* search fs_file and fs_spec */ 121 122 #ifndef NAME_MAX 123 #define NAME_MAX 255 124 #endif 125 126 /* 127 * The contents of the file _PATH_DUMPDATES is maintained both on 128 * a linked list, and then (eventually) arrayified. 129 */ 130 struct dumpdates { 131 char dd_name[NAME_MAX+3]; 132 char dd_level; 133 time_t dd_ddate; 134 }; 135 struct dumptime { 136 struct dumpdates dt_value; 137 struct dumptime *dt_next; 138 }; 139 struct dumptime *dthead; /* head of the list version */ 140 int nddates; /* number of records (might be zero) */ 141 int ddates_in; /* we have read the increment file */ 142 struct dumpdates **ddatev; /* the arrayfied version */ 143 void initdumptimes __P((void)); 144 void getdumptime __P((void)); 145 void putdumptime __P((void)); 146 #define ITITERATE(i, ddp) \ 147 for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i]) 148 149 void sig __P((int signo)); 150 151 /* 152 * Compatibility with old systems. 153 */ 154 #ifndef __STDC__ 155 #include <sys/file.h> 156 #define _PATH_FSTAB "/etc/fstab" 157 extern char *index(), *strdup(); 158 extern char *ctime(); 159 extern int errno; 160 #endif 161 162 #ifdef sunos 163 extern char *calloc(); 164 extern char *malloc(); 165 extern long atol(); 166 extern char *strcpy(); 167 extern char *strncpy(); 168 extern char *strcat(); 169 extern time_t time(); 170 extern void endgrent(); 171 extern __dead void exit(); 172 extern off_t lseek(); 173 extern char *strerror(); 174 #endif 175