1 /* $OpenBSD: dump.h,v 1.16 2007/06/03 20:16:08 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 /* 36 * Dump maps used to describe what is to be dumped. 37 */ 38 int mapsize; /* size of the state maps */ 39 char *usedinomap; /* map of allocated inodes */ 40 char *dumpdirmap; /* map of directories to be dumped */ 41 char *dumpinomap; /* map of files to be dumped */ 42 /* 43 * Map manipulation macros. 44 */ 45 #define SETINO(ino, map) \ 46 map[(u_int)((ino) - 1) / NBBY] |= 1 << ((u_int)((ino) - 1) % NBBY) 47 #define CLRINO(ino, map) \ 48 map[(u_int)((ino) - 1) / NBBY] &= ~(1 << ((u_int)((ino) - 1) % NBBY)) 49 #define TSTINO(ino, map) \ 50 (map[(u_int)((ino) - 1) / NBBY] & (1 << ((u_int)((ino) - 1) % NBBY))) 51 52 /* 53 * All calculations done in 0.1" units! 54 */ 55 char *disk; /* name of the disk file */ 56 char *tape; /* name of the tape file */ 57 char *dumpdates; /* name of the file containing dump date information*/ 58 char *temp; /* name of the file for doing rewrite of dumpdates */ 59 char lastlevel; /* dump level of previous dump */ 60 char level; /* dump level of this dump */ 61 int uflag; /* update flag */ 62 int diskfd; /* disk file descriptor */ 63 int tapefd; /* tape file descriptor */ 64 int pipeout; /* true => output to standard output */ 65 ino_t curino; /* current inumber; used globally */ 66 int newtape; /* new tape flag */ 67 int density; /* density in 0.1" units */ 68 off_t tapesize; /* estimated tape size, blocks */ 69 off_t tsize; /* tape size in 0.1" units */ 70 int unlimited; /* if set, write to end of medium */ 71 off_t asize; /* number of 0.1" units written on current tape */ 72 int etapes; /* estimated number of tapes */ 73 int nonodump; /* if set, do not honor UF_NODUMP user flags */ 74 75 int notify; /* notify operator flag */ 76 int blockswritten; /* number of blocks written on current tape */ 77 int tapeno; /* current tape number */ 78 time_t tstart_writing; /* when started writing the first tape block */ 79 long xferrate; /* averaged transfer rate of all volumes */ 80 struct fs *sblock; /* the file system super block */ 81 char sblock_buf[MAXBSIZE]; 82 long dev_bsize; /* block size of underlying disk device */ 83 int dev_bshift; /* log2(dev_bsize) */ 84 int tp_bshift; /* log2(TP_BSIZE) */ 85 86 /* operator interface functions */ 87 void broadcast(char *message); 88 time_t do_stats(void); 89 void lastdump(int arg); /* int should be char */ 90 void msg(const char *fmt, ...) 91 __attribute__((__format__ (printf, 1, 2))); 92 void msgtail(const char *fmt, ...) 93 __attribute__((__format__ (printf, 1, 2))); 94 int query(char *question); 95 void quit(const char *fmt, ...); 96 void statussig(int); 97 void timeest(void); 98 99 /* mapping routines */ 100 union dinode; 101 off_t blockest(union dinode *dp); 102 void mapfileino(ino_t, off_t *, int *); 103 int mapfiles(ino_t maxino, off_t *tapesize, char *disk, char * const *dirv); 104 int mapdirs(ino_t maxino, off_t *tapesize); 105 106 /* file dumping routines */ 107 void ufs1_blksout(int32_t *blkp, int frags, ino_t ino); 108 void ufs2_blksout(daddr64_t *blkp, int frags, ino_t ino); 109 void bread(daddr64_t blkno, char *buf, int size); 110 void dumpino(union 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(daddr64_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 union dinode *getino(ino_t inum, int *mode); 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 (i = 0; i < nddates && (ddp = ddatev[i]); 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