dump.h revision 90743
1133094Ssimon/*- 2165660Sbmah * Copyright (c) 1980, 1993 3133094Ssimon * The Regents of the University of California. All rights reserved. 4133094Ssimon * 5133094Ssimon * Redistribution and use in source and binary forms, with or without 6133094Ssimon * modification, are permitted provided that the following conditions 7133094Ssimon * are met: 8133094Ssimon * 1. Redistributions of source code must retain the above copyright 9133094Ssimon * notice, this list of conditions and the following disclaimer. 10133094Ssimon * 2. Redistributions in binary form must reproduce the above copyright 11133094Ssimon * notice, this list of conditions and the following disclaimer in the 12133094Ssimon * documentation and/or other materials provided with the distribution. 13133094Ssimon * 3. All advertising materials mentioning features or use of this software 14133094Ssimon * must display the following acknowledgement: 15133094Ssimon * This product includes software developed by the University of 16133094Ssimon * California, Berkeley and its contributors. 17133094Ssimon * 4. Neither the name of the University nor the names of its contributors 18133094Ssimon * may be used to endorse or promote products derived from this software 19133094Ssimon * without specific prior written permission. 20133094Ssimon * 21133094Ssimon * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22133094Ssimon * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23133094Ssimon * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24133094Ssimon * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25133094Ssimon * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26133094Ssimon * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27133094Ssimon * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28133094Ssimon * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29133094Ssimon * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30133094Ssimon * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31133094Ssimon * SUCH DAMAGE. 32133094Ssimon * 33133094Ssimon * @(#)dump.h 8.2 (Berkeley) 4/28/95 34133094Ssimon * 35133094Ssimon * $FreeBSD: head/sbin/dump/dump.h 90743 2002-02-16 21:05:16Z iedowse $ 36133094Ssimon */ 37133094Ssimon 38134652Sbrueffer#define MAXINOPB (MAXBSIZE / sizeof(struct dinode)) 39133094Ssimon#define MAXNINDIR (MAXBSIZE / sizeof(daddr_t)) 40133094Ssimon 41133094Ssimon/* 42133094Ssimon * Dump maps used to describe what is to be dumped. 43135126Sbrueffer */ 44133094Ssimonint mapsize; /* size of the state maps */ 45133343Ssimonchar *usedinomap; /* map of allocated inodes */ 46144426Sbruefferchar *dumpdirmap; /* map of directories to be dumped */ 47134264Ssimonchar *dumpinomap; /* map of files to be dumped */ 48171850Sbmah/* 49160862Sbrueffer * Map manipulation macros. 50160862Sbrueffer */ 51157648Sbrueffer#define SETINO(ino, map) \ 52153665Sbrueffer map[(u_int)((ino) - 1) / NBBY] |= 1 << ((u_int)((ino) - 1) % NBBY) 53139404Sbrueffer#define CLRINO(ino, map) \ 54133343Ssimon map[(u_int)((ino) - 1) / NBBY] &= ~(1 << ((u_int)((ino) - 1) % NBBY)) 55160862Sbrueffer#define TSTINO(ino, map) \ 56135126Sbrueffer (map[(u_int)((ino) - 1) / NBBY] & (1 << ((u_int)((ino) - 1) % NBBY))) 57155296Sbrueffer 58133094Ssimon/* 59135560Speter * All calculations done in 0.1" units! 60133094Ssimon */ 61133094Ssimonchar *disk; /* name of the disk file */ 62134826Ssimonchar *tape; /* name of the tape file */ 63160862Sbruefferchar *dumpdates; /* name of the file containing dump date information*/ 64133094Ssimonchar *temp; /* name of the file for doing rewrite of dumpdates */ 65167548Sbruefferchar lastlevel; /* dump level of previous dump */ 66165660Sbmahchar level; /* dump level of this dump */ 67135126Sbruefferint uflag; /* update flag */ 68135336Sbruefferint diskfd; /* disk file descriptor */ 69134786Sbruefferint tapefd; /* tape file descriptor */ 70150293Sbruefferint pipeout; /* true => output to standard output */ 71134772Ssimonino_t curino; /* current inumber; used globally */ 72133094Ssimonint newtape; /* new tape flag */ 73160862Sbruefferint density; /* density in 0.1" units */ 74135120Ssimonlong tapesize; /* estimated tape size, blocks */ 75169487Sbruefferlong tsize; /* tape size in 0.1" units */ 76149874Sbruefferlong asize; /* number of 0.1" units written on current tape */ 77174662Sbmahint etapes; /* estimated number of tapes */ 78133343Ssimonint nonodump; /* if set, do not honor UF_NODUMP user flags */ 79134772Ssimonint unlimited; /* if set, write to end of medium */ 80135126Sbrueffer 81133343Ssimonint notify; /* notify operator flag */ 82134218Sbruefferint blockswritten; /* number of blocks written on current tape */ 83160862Sbruefferint tapeno; /* current tape number */ 84134273Sbrueffertime_t tstart_writing; /* when started writing the first tape block */ 85165660Sbmahtime_t tend_writing; /* after writing the last tape block */ 86165660Sbmahint passno; /* current dump pass number */ 87135126Sbruefferstruct fs *sblock; /* the file system super block */ 88165157Sbruefferchar sblock_buf[MAXBSIZE]; 89159606Sbruefferlong dev_bsize; /* block size of underlying disk device */ 90133094Ssimonint dev_bshift; /* log2(dev_bsize) */ 91183776Ssimonint tp_bshift; /* log2(TP_BSIZE) */ 92133457Ssimon 93171111Sbrueffer#ifndef __P 94138967Sbrueffer#include <sys/cdefs.h> 95135143Sbrueffer#endif 96165660Sbmah 97133343Ssimon/* operator interface functions */ 98146397Sbrueffervoid broadcast __P((char *message)); 99171111Sbrueffervoid infosch __P((int)); 100165660Sbmahvoid lastdump __P((int arg)); /* int should be char */ 101141288Sbrueffervoid msg __P((const char *fmt, ...)) __printflike(1, 2); 102165660Sbmahvoid msgtail __P((const char *fmt, ...)) __printflike(1, 2); 103143338Ssimonint query __P((char *question)); 104143783Sbrueffervoid quit __P((const char *fmt, ...)) __printflike(1, 2); 105172129Sbrueffervoid timeest __P((void)); 106134316Sbrueffertime_t unctime __P((char *str)); 107172079Sbrueffer 108135120Ssimon/* mapping rouintes */ 109135126Sbruefferstruct dinode; 110165660Sbmahlong blockest __P((struct dinode *dp)); 111165660Sbmahint mapfiles __P((ino_t maxino, long *tapesize)); 112134786Sbruefferint mapdirs __P((ino_t maxino, long *tapesize)); 113134757Sbrueffer 114134414Ssimon/* file dumping routines */ 115144942Sbrueffervoid blksout __P((daddr_t *blkp, int frags, ino_t ino)); 116152888Sbrueffervoid bread __P((daddr_t blkno, char *buf, int size)); 117138846Ssimonvoid dumpino __P((struct dinode *dp, ino_t ino)); 118134414Ssimonvoid dumpmap __P((char *map, int type, ino_t ino)); 119134414Ssimonvoid writeheader __P((ino_t ino)); 120135082Ssimon 121134414Ssimon/* tape writing routines */ 122134414Ssimonint alloctape __P((void)); 123162930Sjoelvoid close_rewind __P((void)); 124159694Sbrueffervoid dumpblock __P((daddr_t blkno, int size)); 125162930Sjoelvoid startnewtape __P((int top)); 126151642Sbrueffervoid trewind __P((void)); 127135533Ssimonvoid writerec __P((char *dp, int isspcl)); 128144942Sbrueffer 129135082Ssimonvoid Exit __P((int status)) __dead2; 130162928Sjoelvoid dumpabort __P((int signo)); 131138133Ssimonvoid getfstab __P((void)); 132165660Sbmah 133165660Sbmahchar *rawname __P((char *cp)); 134151215Sjoelstruct dinode *getino __P((ino_t inum)); 135142583Ssimon 136165660Sbmah/* rdump routines */ 137134414Ssimon#ifdef RDUMP 138162930Sjoelvoid rmtclose __P((void)); 139149099Sjoelint rmthost __P((char *host)); 140149137Sjoelint rmtopen __P((char *tape, int mode)); 141143460Ssimonint rmtwrite __P((char *buf, int count)); 142143460Ssimon#endif /* RDUMP */ 143143783Sbrueffer 144165660Sbmahvoid interrupt __P((int signo)); /* in case operator bangs on console */ 145133343Ssimon 146160659Sbrueffer/* 147153777Ssimon * Exit status codes 148165660Sbmah */ 149133778Ssimon#define X_FINOK 0 /* normal exit */ 150134652Sbrueffer#define X_STARTUP 1 /* startup error */ 151134652Sbrueffer#define X_REWRITE 2 /* restart writing from the check point */ 152165660Sbmah#define X_ABORT 3 /* abort dump; don't attempt checkpointing */ 153134730Sbrueffer 154135120Ssimon#define OPGRENT "operator" /* group entry to notify */ 155135103Ssimon 156134864Sbruefferstruct fstab *fstabsearch __P((char *key)); /* search fs_file and fs_spec */ 157133094Ssimon 158134730Sbrueffer#ifndef NAME_MAX 159165660Sbmah#define NAME_MAX 255 160165660Sbmah#endif 161165660Sbmah 162134047Ssimon/* 163134730Sbrueffer * The contents of the file _PATH_DUMPDATES is maintained both on 164172129Sbrueffer * a linked list, and then (eventually) arrayified. 165160862Sbrueffer */ 166160862Sbruefferstruct dumpdates { 167135114Ssimon char dd_name[NAME_MAX+3]; 168134876Sbrueffer char dd_level; 169135057Ssimon time_t dd_ddate; 170138872Ssimon}; 171135126Sbruefferint nddates; /* number of records (might be zero) */ 172165660Sbmahint ddates_in; /* we have read the increment file */ 173133094Ssimonstruct dumpdates **ddatev; /* the arrayfied version */ 174172036Sbrueffervoid initdumptimes __P((void)); 175void getdumptime __P((void)); 176void putdumptime __P((void)); 177#define ITITERATE(i, ddp) \ 178 for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i]) 179 180void sig __P((int signo)); 181 182/* 183 * Compatibility with old systems. 184 */ 185#ifdef COMPAT 186#include <sys/file.h> 187#define strchr(a,b) index(a,b) 188#define strrchr(a,b) rindex(a,b) 189extern char *strdup(), *ctime(); 190extern int read(), write(); 191extern int errno; 192#endif 193 194#ifndef _PATH_UTMP 195#define _PATH_UTMP "/etc/utmp" 196#endif 197#ifndef _PATH_FSTAB 198#define _PATH_FSTAB "/etc/fstab" 199#endif 200