122043Sdist /* 222043Sdist * Copyright (c) 1980 Regents of the University of California. 322043Sdist * All rights reserved. The Berkeley software License Agreement 422043Sdist * specifies the terms and conditions for redistribution. 522043Sdist * 6*46790Smckusick * @(#)dump.h 5.10 (Berkeley) 02/28/91 722043Sdist */ 813592Ssam 95328Smckusic #define NI 16 105328Smckusic #define MAXINOPB (MAXBSIZE / sizeof(struct dinode)) 115328Smckusic #define MAXNINDIR (MAXBSIZE / sizeof(daddr_t)) 121421Sroot 136642Ssam #include <sys/param.h> 146642Ssam #include <sys/stat.h> 1546589Storek #include <sys/time.h> 1639129Smckusick #include <ufs/fs.h> 1740096Smckusick #include <ufs/dinode.h> 1846589Storek #include <ufs/dir.h> 1923543Smckusick #include <protocols/dumprestore.h> 201421Sroot #include <utmp.h> 2146589Storek #include <signal.h> 221421Sroot #include <fstab.h> 2337946Sbostic #include <stdio.h> 2446589Storek #include <stdlib.h> 2546589Storek #include <string.h> 2637946Sbostic #include <ctype.h> 271421Sroot 28*46790Smckusick /* 29*46790Smckusick * Dump maps used to describe what is to be dumped. 30*46790Smckusick */ 31*46790Smckusick int mapsize; /* size of the state maps */ 32*46790Smckusick char *usedinomap; /* map of allocated inodes */ 33*46790Smckusick char *dumpdirmap; /* map of directories to be dumped */ 34*46790Smckusick char *dumpinomap; /* map of files to be dumped */ 35*46790Smckusick /* 36*46790Smckusick * Map manipulation macros. 37*46790Smckusick */ 38*46790Smckusick #define SETINO(ino, map) \ 39*46790Smckusick map[(u_int)((ino) - 1) / NBBY] |= 1 << ((u_int)((ino) - 1) % NBBY) 40*46790Smckusick #define CLRINO(ino, map) \ 41*46790Smckusick map[(u_int)((ino) - 1) / NBBY] &= ~(1 << ((u_int)((ino) - 1) % NBBY)) 42*46790Smckusick #define TSTINO(ino, map) \ 43*46790Smckusick (map[(u_int)((ino) - 1) / NBBY] & (1 << ((u_int)((ino) - 1) % NBBY))) 441421Sroot 451421Sroot /* 461421Sroot * All calculations done in 0.1" units! 471421Sroot */ 481421Sroot char *disk; /* name of the disk file */ 491421Sroot char *tape; /* name of the tape file */ 50*46790Smckusick char *dumpdates; /* name of the file containing dump date information*/ 51*46790Smckusick char *temp; /* name of the file for doing rewrite of dumpdates */ 52*46790Smckusick char lastlevel; /* dump level of previous dump */ 53*46790Smckusick char level; /* dump level of this dump */ 541421Sroot int uflag; /* update flag */ 55*46790Smckusick int diskfd; /* disk file descriptor */ 56*46790Smckusick int tapefd; /* tape file descriptor */ 5712331Smckusick int pipeout; /* true => output to standard output */ 58*46790Smckusick ino_t curino; /* current inumber; used globally */ 591421Sroot int newtape; /* new tape flag */ 601421Sroot int density; /* density in 0.1" units */ 61*46790Smckusick long tapesize; /* estimated tape size, blocks */ 621421Sroot long tsize; /* tape size in 0.1" units */ 631421Sroot long asize; /* number of 0.1" units written on current tape */ 641421Sroot int etapes; /* estimated number of tapes */ 651421Sroot 661421Sroot int notify; /* notify operator flag */ 671421Sroot int blockswritten; /* number of blocks written on current tape */ 681421Sroot int tapeno; /* current tape number */ 691421Sroot time_t tstart_writing; /* when started writing the first tape block */ 701421Sroot char *processname; 71*46790Smckusick struct fs *sblock; /* the file system super block */ 725328Smckusic char buf[MAXBSIZE]; 7346589Storek long dev_bsize; /* block size of underlying disk device */ 7446589Storek int dev_bshift; /* log2(dev_bsize) */ 7546589Storek int tp_bshift; /* log2(TP_BSIZE) */ 761421Sroot 7746589Storek /* operator interface functions */ 7846589Storek void broadcast(); 7946589Storek void lastdump(); 8046589Storek void msg(); 8146589Storek void msgtail(); 8246589Storek int query(); 8346589Storek void set_operators(); 8446589Storek void timeest(); 8546589Storek 8646589Storek /* mapping rouintes */ 87*46790Smckusick long blockest(); 88*46790Smckusick int mapfiles(); 89*46790Smckusick int mapdirs(); 9046589Storek 9146589Storek /* file dumping routines */ 9246589Storek void dirdump(); 9346589Storek void blksout(); 94*46790Smckusick void dumpmap(); 95*46790Smckusick void writeheader(); 9646589Storek void bread(); 9746589Storek 9846589Storek /* tape writing routines */ 9946589Storek int alloctape(); 100*46790Smckusick void writerec(); 101*46790Smckusick void dumpblock(); 102*46790Smckusick void flushtape(); 10346589Storek void trewind(); 10446589Storek void close_rewind(); 105*46790Smckusick void startnewtape(); 10646589Storek 10746589Storek void dumpabort(); 10846589Storek void Exit(); 10946589Storek void getfstab(); 11046589Storek void quit(); 11146589Storek 1121421Sroot char *rawname(); 1134701Smckusic struct dinode *getino(); 1141421Sroot 11546589Storek void interrupt(); /* in case operator bangs on console */ 1161421Sroot 1171421Sroot #define HOUR (60L*60L) 1181421Sroot #define DAY (24L*HOUR) 1191421Sroot #define YEAR (365L*DAY) 1201421Sroot 1211421Sroot /* 1221421Sroot * Exit status codes 1231421Sroot */ 12428641Smckusick #define X_FINOK 0 /* normal exit */ 1251421Sroot #define X_REWRITE 2 /* restart writing from the check point */ 1261421Sroot #define X_ABORT 3 /* abort all of dump; don't attempt checkpointing*/ 1271421Sroot 1281421Sroot #define OPGRENT "operator" /* group entry to notify */ 1291421Sroot #define DIALUP "ttyd" /* prefix for dialups */ 1301421Sroot 1311421Sroot struct fstab *fstabsearch(); /* search in fs_file and fs_spec */ 1321421Sroot 1331421Sroot /* 13437266Sbostic * The contents of the file _PATH_DUMPDATES is maintained both on 1351421Sroot * a linked list, and then (eventually) arrayified. 1361421Sroot */ 137*46790Smckusick struct dumpdates { 138*46790Smckusick char dd_name[MAXNAMLEN+3]; 139*46790Smckusick char dd_level; 140*46790Smckusick time_t dd_ddate; 1418375Smckusick }; 142*46790Smckusick struct dumptime { 143*46790Smckusick struct dumpdates dt_value; 144*46790Smckusick struct dumptime *dt_next; 1451421Sroot }; 146*46790Smckusick struct dumptime *dthead; /* head of the list version */ 147*46790Smckusick int nddates; /* number of records (might be zero) */ 148*46790Smckusick int ddates_in; /* we have read the increment file */ 149*46790Smckusick struct dumpdates **ddatev; /* the arrayfied version */ 150*46790Smckusick void initdumptimes(); 151*46790Smckusick void getdumptime(); 152*46790Smckusick void putdumptime(); 153*46790Smckusick #define ITITERATE(i, ddp) \ 154*46790Smckusick for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i]) 1551421Sroot 1561421Sroot /* 1571421Sroot * We catch these interrupts 1581421Sroot */ 15946589Storek void sighup(); 16046589Storek void sigquit(); 16146589Storek void sigill(); 16246589Storek void sigtrap(); 16346589Storek void sigfpe(); 16446589Storek void sigkill(); 16546589Storek void sigbus(); 16646589Storek void sigsegv(); 16746589Storek void sigsys(); 16846589Storek void sigalrm(); 16946589Storek void sigterm(); 170