147082Smckusick /*- 247082Smckusick * Copyright (c) 1980 The Regents of the University of California. 347082Smckusick * All rights reserved. 422043Sdist * 547082Smckusick * %sccs.include.redist.c% 647082Smckusick * 7*55288Sbostic * @(#)dump.h 5.21 (Berkeley) 07/16/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 */ 64*55288Sbostic void msg __P((const char *fmt, ...)); 65*55288Sbostic void msgtail __P((const char *fmt, ...)); 66*55288Sbostic int query __P((char *question)); 67*55288Sbostic void quit __P((const char *fmt, ...)); 68*55288Sbostic void set_operators __P((void)); 69*55288Sbostic void timeest __P((void)); 7054071Smckusick time_t unctime __P((char *str)); 7146589Storek 7246589Storek /* mapping rouintes */ 7354071Smckusick struct dinode; 7454071Smckusick long blockest __P((struct dinode *dp)); 7554071Smckusick int mapfiles __P((ino_t maxino, long *tapesize)); 7654071Smckusick int mapdirs __P((ino_t maxino, long *tapesize)); 7746589Storek 7846589Storek /* file dumping routines */ 79*55288Sbostic void blksout __P((daddr_t *blkp, int frags, ino_t ino)); 80*55288Sbostic void bread __P((daddr_t blkno, char *buf, int size)); 8154071Smckusick void dumpino __P((struct dinode *dp, ino_t ino)); 8254071Smckusick void dumpmap __P((char *map, int type, ino_t ino)); 8354071Smckusick void writeheader __P((ino_t ino)); 8446589Storek 8546589Storek /* tape writing routines */ 86*55288Sbostic int alloctape __P((void)); 87*55288Sbostic void close_rewind __P((void)); 88*55288Sbostic void dumpblock __P((daddr_t blkno, int size)); 89*55288Sbostic void flushtape __P((void)); 90*55288Sbostic void startnewtape __P((int top)); 91*55288Sbostic void trewind __P((void)); 9254594Smckusick void writerec __P((char *dp, int isspcl)); 9346589Storek 9454071Smckusick void Exit __P((int status)); 95*55288Sbostic void dumpabort __P((int signo)); 96*55288Sbostic void getfstab __P((void)); 9746589Storek 9854071Smckusick char *rawname __P((char *cp)); 9954071Smckusick struct dinode *getino __P((ino_t inum)); 1001421Sroot 101*55288Sbostic void interrupt __P((int signo)); /* in case operator bangs on console */ 1021421Sroot 1031421Sroot /* 1041421Sroot * Exit status codes 1051421Sroot */ 10628641Smckusick #define X_FINOK 0 /* normal exit */ 1071421Sroot #define X_REWRITE 2 /* restart writing from the check point */ 10854071Smckusick #define X_ABORT 3 /* abort dump; don't attempt checkpointing */ 1091421Sroot 1101421Sroot #define OPGRENT "operator" /* group entry to notify */ 1111421Sroot #define DIALUP "ttyd" /* prefix for dialups */ 1121421Sroot 11354071Smckusick struct fstab *fstabsearch __P((char *key)); /* search fs_file and fs_spec */ 1141421Sroot 11554071Smckusick #ifndef NAME_MAX 11654071Smckusick #define NAME_MAX 255 11754071Smckusick #endif 11854071Smckusick 1191421Sroot /* 12037266Sbostic * The contents of the file _PATH_DUMPDATES is maintained both on 1211421Sroot * a linked list, and then (eventually) arrayified. 1221421Sroot */ 12346790Smckusick struct dumpdates { 12450506Smckusick char dd_name[NAME_MAX+3]; 12546790Smckusick char dd_level; 12646790Smckusick time_t dd_ddate; 1278375Smckusick }; 12846790Smckusick struct dumptime { 12946790Smckusick struct dumpdates dt_value; 13046790Smckusick struct dumptime *dt_next; 1311421Sroot }; 13246790Smckusick struct dumptime *dthead; /* head of the list version */ 13346790Smckusick int nddates; /* number of records (might be zero) */ 13446790Smckusick int ddates_in; /* we have read the increment file */ 13546790Smckusick struct dumpdates **ddatev; /* the arrayfied version */ 136*55288Sbostic void initdumptimes __P((void)); 137*55288Sbostic void getdumptime __P((void)); 138*55288Sbostic void putdumptime __P((void)); 13946790Smckusick #define ITITERATE(i, ddp) \ 14046790Smckusick for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i]) 1411421Sroot 142*55288Sbostic void sig __P((int signo)); 14346807Smckusick 14446807Smckusick /* 14546807Smckusick * Compatibility with old systems. 14646807Smckusick */ 14746807Smckusick #ifndef __STDC__ 14846807Smckusick #include <sys/file.h> 14946807Smckusick #define _PATH_FSTAB "/etc/fstab" 15049932Smckusick extern char *index(), *strdup(); 15146807Smckusick extern char *ctime(); 15246807Smckusick extern int errno; 15346807Smckusick #endif 15454071Smckusick 15554071Smckusick #ifdef sunos 15654071Smckusick extern char *calloc(); 15754071Smckusick extern char *malloc(); 15854071Smckusick extern long atol(); 15954071Smckusick extern char *strcpy(); 16054071Smckusick extern char *strncpy(); 16154071Smckusick extern char *strcat(); 16254071Smckusick extern time_t time(); 16354071Smckusick extern void endgrent(); 16454071Smckusick extern void exit(); 16554071Smckusick extern off_t lseek(); 16654071Smckusick extern char *strerror(); 16754071Smckusick #endif 168