147082Smckusick /*- 247082Smckusick * Copyright (c) 1980 The Regents of the University of California. 347082Smckusick * All rights reserved. 422043Sdist * 547082Smckusick * %sccs.include.redist.c% 647082Smckusick * 7*54594Smckusick * @(#)dump.h 5.20 (Berkeley) 07/02/92 822043Sdist */ 913592Ssam 105328Smckusic #define MAXINOPB (MAXBSIZE / sizeof(struct dinode)) 115328Smckusic #define MAXNINDIR (MAXBSIZE / sizeof(daddr_t)) 121421Sroot 1346790Smckusick /* 1446790Smckusick * Dump maps used to describe what is to be dumped. 1546790Smckusick */ 1646790Smckusick int mapsize; /* size of the state maps */ 1746790Smckusick char *usedinomap; /* map of allocated inodes */ 1846790Smckusick char *dumpdirmap; /* map of directories to be dumped */ 1946790Smckusick char *dumpinomap; /* map of files to be dumped */ 2046790Smckusick /* 2146790Smckusick * Map manipulation macros. 2246790Smckusick */ 2346790Smckusick #define SETINO(ino, map) \ 2446790Smckusick map[(u_int)((ino) - 1) / NBBY] |= 1 << ((u_int)((ino) - 1) % NBBY) 2546790Smckusick #define CLRINO(ino, map) \ 2646790Smckusick map[(u_int)((ino) - 1) / NBBY] &= ~(1 << ((u_int)((ino) - 1) % NBBY)) 2746790Smckusick #define TSTINO(ino, map) \ 2846790Smckusick (map[(u_int)((ino) - 1) / NBBY] & (1 << ((u_int)((ino) - 1) % NBBY))) 291421Sroot 301421Sroot /* 311421Sroot * All calculations done in 0.1" units! 321421Sroot */ 331421Sroot char *disk; /* name of the disk file */ 341421Sroot char *tape; /* name of the tape file */ 3546790Smckusick char *dumpdates; /* name of the file containing dump date information*/ 3646790Smckusick char *temp; /* name of the file for doing rewrite of dumpdates */ 3746790Smckusick char lastlevel; /* dump level of previous dump */ 3846790Smckusick char level; /* dump level of this dump */ 391421Sroot int uflag; /* update flag */ 4046790Smckusick int diskfd; /* disk file descriptor */ 4146790Smckusick int tapefd; /* tape file descriptor */ 4212331Smckusick int pipeout; /* true => output to standard output */ 4346790Smckusick ino_t curino; /* current inumber; used globally */ 441421Sroot int newtape; /* new tape flag */ 451421Sroot int density; /* density in 0.1" units */ 4646790Smckusick long tapesize; /* estimated tape size, blocks */ 471421Sroot long tsize; /* tape size in 0.1" units */ 481421Sroot long asize; /* number of 0.1" units written on current tape */ 491421Sroot int etapes; /* estimated number of tapes */ 501421Sroot 511421Sroot int notify; /* notify operator flag */ 521421Sroot int blockswritten; /* number of blocks written on current tape */ 531421Sroot int tapeno; /* current tape number */ 541421Sroot time_t tstart_writing; /* when started writing the first tape block */ 5546790Smckusick struct fs *sblock; /* the file system super block */ 5654071Smckusick char sblock_buf[MAXBSIZE]; 5746589Storek long dev_bsize; /* block size of underlying disk device */ 5846589Storek int dev_bshift; /* log2(dev_bsize) */ 5946589Storek int tp_bshift; /* log2(TP_BSIZE) */ 601421Sroot 6146589Storek /* operator interface functions */ 6254071Smckusick void broadcast __P((char *message)); 6354071Smckusick void lastdump __P((int arg)); /* int should be char */ 6454071Smckusick time_t unctime __P((char *str)); 6550643Storek #if __STDC__ 6650643Storek void msg(const char *fmt, ...); 6750643Storek void msgtail(const char *fmt, ...); 6850643Storek void quit(const char *fmt, ...); 6950643Storek #else 7046589Storek void msg(); 7146589Storek void msgtail(); 7250643Storek void quit(); 7350643Storek #endif 7454071Smckusick int query __P((char *question)); 7554071Smckusick void set_operators __P(()); 7654071Smckusick void timeest __P(()); 7746589Storek 7846589Storek /* mapping rouintes */ 7954071Smckusick struct dinode; 8054071Smckusick long blockest __P((struct dinode *dp)); 8154071Smckusick int mapfiles __P((ino_t maxino, long *tapesize)); 8254071Smckusick int mapdirs __P((ino_t maxino, long *tapesize)); 8346589Storek 8446589Storek /* file dumping routines */ 8554071Smckusick void dumpino __P((struct dinode *dp, ino_t ino)); 8654071Smckusick void blksout __P((daddr_t *blkp, int frags, ino_t ino)); 8754071Smckusick void dumpmap __P((char *map, int type, ino_t ino)); 8854071Smckusick void writeheader __P((ino_t ino)); 8954071Smckusick void bread __P((daddr_t blkno, char *buf, int size)); 9046589Storek 9146589Storek /* tape writing routines */ 9254071Smckusick int alloctape __P(()); 93*54594Smckusick void writerec __P((char *dp, int isspcl)); 9454071Smckusick void dumpblock __P((daddr_t blkno, int size)); 9554071Smckusick void flushtape __P(()); 9654071Smckusick void trewind __P(()); 9754071Smckusick void close_rewind __P(()); 9854071Smckusick void startnewtape __P(()); 9946589Storek 10054071Smckusick void dumpabort __P(()); 10154071Smckusick void Exit __P((int status)); 10254071Smckusick void getfstab __P(()); 10346589Storek 10454071Smckusick char *rawname __P((char *cp)); 10554071Smckusick struct dinode *getino __P((ino_t inum)); 1061421Sroot 10754071Smckusick void interrupt __P(()); /* in case operator bangs on console */ 1081421Sroot 1091421Sroot /* 1101421Sroot * Exit status codes 1111421Sroot */ 11228641Smckusick #define X_FINOK 0 /* normal exit */ 1131421Sroot #define X_REWRITE 2 /* restart writing from the check point */ 11454071Smckusick #define X_ABORT 3 /* abort dump; don't attempt checkpointing */ 1151421Sroot 1161421Sroot #define OPGRENT "operator" /* group entry to notify */ 1171421Sroot #define DIALUP "ttyd" /* prefix for dialups */ 1181421Sroot 11954071Smckusick struct fstab *fstabsearch __P((char *key)); /* search fs_file and fs_spec */ 1201421Sroot 12154071Smckusick #ifndef NAME_MAX 12254071Smckusick #define NAME_MAX 255 12354071Smckusick #endif 12454071Smckusick 1251421Sroot /* 12637266Sbostic * The contents of the file _PATH_DUMPDATES is maintained both on 1271421Sroot * a linked list, and then (eventually) arrayified. 1281421Sroot */ 12946790Smckusick struct dumpdates { 13050506Smckusick char dd_name[NAME_MAX+3]; 13146790Smckusick char dd_level; 13246790Smckusick time_t dd_ddate; 1338375Smckusick }; 13446790Smckusick struct dumptime { 13546790Smckusick struct dumpdates dt_value; 13646790Smckusick struct dumptime *dt_next; 1371421Sroot }; 13846790Smckusick struct dumptime *dthead; /* head of the list version */ 13946790Smckusick int nddates; /* number of records (might be zero) */ 14046790Smckusick int ddates_in; /* we have read the increment file */ 14146790Smckusick struct dumpdates **ddatev; /* the arrayfied version */ 14254071Smckusick void initdumptimes __P(()); 14354071Smckusick void getdumptime __P(()); 14454071Smckusick void putdumptime __P(()); 14546790Smckusick #define ITITERATE(i, ddp) \ 14646790Smckusick for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i]) 1471421Sroot 1481421Sroot /* 1491421Sroot * We catch these interrupts 1501421Sroot */ 15154071Smckusick void sighup __P(()); 15254071Smckusick void sigtrap __P(()); 15354071Smckusick void sigfpe __P(()); 15454071Smckusick void sigbus __P(()); 15554071Smckusick void sigsegv __P(()); 15654071Smckusick void sigalrm __P(()); 15754071Smckusick void sigterm __P(()); 15846807Smckusick 15946807Smckusick /* 16046807Smckusick * Compatibility with old systems. 16146807Smckusick */ 16246807Smckusick #ifndef __STDC__ 16346807Smckusick #include <sys/file.h> 16446807Smckusick #define _PATH_FSTAB "/etc/fstab" 16549932Smckusick extern char *index(), *strdup(); 16646807Smckusick extern char *ctime(); 16746807Smckusick extern int errno; 16846807Smckusick #endif 16954071Smckusick 17054071Smckusick #ifdef sunos 17154071Smckusick extern char *calloc(); 17254071Smckusick extern char *malloc(); 17354071Smckusick extern long atol(); 17454071Smckusick extern char *strcpy(); 17554071Smckusick extern char *strncpy(); 17654071Smckusick extern char *strcat(); 17754071Smckusick extern time_t time(); 17854071Smckusick extern void endgrent(); 17954071Smckusick extern void exit(); 18054071Smckusick extern off_t lseek(); 18154071Smckusick extern char *strerror(); 18254071Smckusick #endif 183