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*46589Storek * @(#)dump.h 5.9 (Berkeley) 02/23/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> 15*46589Storek #include <sys/time.h> 1639129Smckusick #include <ufs/fs.h> 1740096Smckusick #include <ufs/dinode.h> 18*46589Storek #include <ufs/dir.h> 1923543Smckusick #include <protocols/dumprestore.h> 201421Sroot #include <utmp.h> 21*46589Storek #include <signal.h> 221421Sroot #include <fstab.h> 2337946Sbostic #include <stdio.h> 24*46589Storek #include <stdlib.h> 25*46589Storek #include <string.h> 2637946Sbostic #include <ctype.h> 271421Sroot 285328Smckusic #define MWORD(m,i) (m[(unsigned)(i-1)/NBBY]) 295328Smckusic #define MBIT(i) (1<<((unsigned)(i-1)%NBBY)) 301421Sroot #define BIS(i,w) (MWORD(w,i) |= MBIT(i)) 311421Sroot #define BIC(i,w) (MWORD(w,i) &= ~MBIT(i)) 321421Sroot #define BIT(i,w) (MWORD(w,i) & MBIT(i)) 331421Sroot 345328Smckusic int msiz; 355328Smckusic char *clrmap; 365328Smckusic char *dirmap; 375328Smckusic char *nodmap; 381421Sroot 391421Sroot /* 401421Sroot * All calculations done in 0.1" units! 411421Sroot */ 421421Sroot 431421Sroot char *disk; /* name of the disk file */ 441421Sroot char *tape; /* name of the tape file */ 451421Sroot char *increm; /* name of the file containing incremental information*/ 4613150Ssam char *temp; /* name of the file for doing rewrite of increm */ 4713150Ssam char lastincno; /* increment number of previous dump */ 481421Sroot char incno; /* increment number */ 491421Sroot int uflag; /* update flag */ 501421Sroot int fi; /* disk file descriptor */ 511421Sroot int to; /* tape file descriptor */ 5212331Smckusick int pipeout; /* true => output to standard output */ 531421Sroot ino_t ino; /* current inumber; used globally */ 541421Sroot int nsubdir; 551421Sroot int newtape; /* new tape flag */ 561421Sroot int nadded; /* number of added sub directories */ 571421Sroot int dadded; /* directory added flag */ 581421Sroot int density; /* density in 0.1" units */ 591421Sroot long tsize; /* tape size in 0.1" units */ 601421Sroot long esize; /* estimated tape size, blocks */ 611421Sroot long asize; /* number of 0.1" units written on current tape */ 621421Sroot int etapes; /* estimated number of tapes */ 631421Sroot 641421Sroot int notify; /* notify operator flag */ 651421Sroot int blockswritten; /* number of blocks written on current tape */ 661421Sroot int tapeno; /* current tape number */ 671421Sroot time_t tstart_writing; /* when started writing the first tape block */ 681421Sroot char *processname; 695328Smckusic struct fs *sblock; /* the file system super block */ 705328Smckusic char buf[MAXBSIZE]; 71*46589Storek long dev_bsize; /* block size of underlying disk device */ 72*46589Storek int dev_bshift; /* log2(dev_bsize) */ 73*46589Storek int tp_bshift; /* log2(TP_BSIZE) */ 741421Sroot 75*46589Storek /* operator interface functions */ 76*46589Storek void broadcast(); 77*46589Storek void lastdump(); 78*46589Storek void msg(); 79*46589Storek void msgtail(); 80*46589Storek int query(); 81*46589Storek void set_operators(); 82*46589Storek void timeest(); 83*46589Storek 84*46589Storek /* mapping rouintes */ 85*46589Storek void est(); 86*46589Storek void bmapest(); 87*46589Storek void pass(); 88*46589Storek void mark(); 89*46589Storek void add(); 90*46589Storek 91*46589Storek /* file dumping routines */ 92*46589Storek void dirdump(); 93*46589Storek void dump(); 94*46589Storek void blksout(); 95*46589Storek void bitmap(); 96*46589Storek void spclrec(); 97*46589Storek void bread(); 98*46589Storek 99*46589Storek /* tape writing routines */ 100*46589Storek int alloctape(); 101*46589Storek void taprec(); 102*46589Storek void dmpblk(); 103*46589Storek void tflush(); 104*46589Storek void trewind(); 105*46589Storek void close_rewind(); 106*46589Storek void otape(); 107*46589Storek 108*46589Storek void dumpabort(); 109*46589Storek void Exit(); 110*46589Storek void getfstab(); 111*46589Storek void quit(); 112*46589Storek 1131421Sroot char *prdate(); 1141421Sroot char *rawname(); 1154701Smckusic struct dinode *getino(); 1161421Sroot 117*46589Storek void interrupt(); /* in case operator bangs on console */ 1181421Sroot 1191421Sroot #define HOUR (60L*60L) 1201421Sroot #define DAY (24L*HOUR) 1211421Sroot #define YEAR (365L*DAY) 1221421Sroot 1231421Sroot /* 1241421Sroot * Exit status codes 1251421Sroot */ 12628641Smckusick #define X_FINOK 0 /* normal exit */ 1271421Sroot #define X_REWRITE 2 /* restart writing from the check point */ 1281421Sroot #define X_ABORT 3 /* abort all of dump; don't attempt checkpointing*/ 1291421Sroot 1301421Sroot #define OPGRENT "operator" /* group entry to notify */ 1311421Sroot #define DIALUP "ttyd" /* prefix for dialups */ 1321421Sroot 1331421Sroot struct fstab *fstabsearch(); /* search in fs_file and fs_spec */ 1341421Sroot 1351421Sroot /* 13637266Sbostic * The contents of the file _PATH_DUMPDATES is maintained both on 1371421Sroot * a linked list, and then (eventually) arrayified. 1381421Sroot */ 1398375Smckusick struct idates { 1408375Smckusick char id_name[MAXNAMLEN+3]; 1418375Smckusick char id_incno; 1428375Smckusick time_t id_ddate; 1438375Smckusick }; 144*46589Storek struct itime { 1451421Sroot struct idates it_value; 1461421Sroot struct itime *it_next; 1471421Sroot }; 1481421Sroot struct itime *ithead; /* head of the list version */ 1491421Sroot int nidates; /* number of records (might be zero) */ 1501421Sroot int idates_in; /* we have read the increment file */ 1511421Sroot struct idates **idatev; /* the arrayfied version */ 152*46589Storek void inititimes(); 153*46589Storek void getitime(); 154*46589Storek void putitime(); 155*46589Storek #define ITITERATE(i, ip) for (ip = idatev[i = 0]; i < nidates; ip = idatev[++i]) 1561421Sroot 1571421Sroot /* 1581421Sroot * We catch these interrupts 1591421Sroot */ 160*46589Storek void sighup(); 161*46589Storek void sigquit(); 162*46589Storek void sigill(); 163*46589Storek void sigtrap(); 164*46589Storek void sigfpe(); 165*46589Storek void sigkill(); 166*46589Storek void sigbus(); 167*46589Storek void sigsegv(); 168*46589Storek void sigsys(); 169*46589Storek void sigalrm(); 170*46589Storek void sigterm(); 171