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