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*37946Sbostic * @(#)dump.h 5.6 (Berkeley) 05/11/89 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> 156642Ssam #include <sys/fs.h> 166642Ssam #include <sys/inode.h> 1723543Smckusick #include <protocols/dumprestore.h> 1813544Ssam #include <sys/dir.h> 191421Sroot #include <utmp.h> 2013592Ssam #include <sys/time.h> 21*37946Sbostic #include <sys/signal.h> 221421Sroot #include <fstab.h> 23*37946Sbostic #include <stdio.h> 24*37946Sbostic #include <ctype.h> 251421Sroot 265328Smckusic #define MWORD(m,i) (m[(unsigned)(i-1)/NBBY]) 275328Smckusic #define MBIT(i) (1<<((unsigned)(i-1)%NBBY)) 281421Sroot #define BIS(i,w) (MWORD(w,i) |= MBIT(i)) 291421Sroot #define BIC(i,w) (MWORD(w,i) &= ~MBIT(i)) 301421Sroot #define BIT(i,w) (MWORD(w,i) & MBIT(i)) 311421Sroot 325328Smckusic int msiz; 335328Smckusic char *clrmap; 345328Smckusic char *dirmap; 355328Smckusic char *nodmap; 361421Sroot 371421Sroot /* 381421Sroot * All calculations done in 0.1" units! 391421Sroot */ 401421Sroot 411421Sroot char *disk; /* name of the disk file */ 421421Sroot char *tape; /* name of the tape file */ 431421Sroot char *increm; /* name of the file containing incremental information*/ 4413150Ssam char *temp; /* name of the file for doing rewrite of increm */ 4513150Ssam char lastincno; /* increment number of previous dump */ 461421Sroot char incno; /* increment number */ 471421Sroot int uflag; /* update flag */ 481421Sroot int fi; /* disk file descriptor */ 491421Sroot int to; /* tape file descriptor */ 5012331Smckusick int pipeout; /* true => output to standard output */ 511421Sroot ino_t ino; /* current inumber; used globally */ 521421Sroot int nsubdir; 531421Sroot int newtape; /* new tape flag */ 541421Sroot int nadded; /* number of added sub directories */ 551421Sroot int dadded; /* directory added flag */ 561421Sroot int density; /* density in 0.1" units */ 571421Sroot long tsize; /* tape size in 0.1" units */ 581421Sroot long esize; /* estimated tape size, blocks */ 591421Sroot long asize; /* number of 0.1" units written on current tape */ 601421Sroot int etapes; /* estimated number of tapes */ 611421Sroot 621421Sroot int notify; /* notify operator flag */ 631421Sroot int blockswritten; /* number of blocks written on current tape */ 641421Sroot int tapeno; /* current tape number */ 651421Sroot time_t tstart_writing; /* when started writing the first tape block */ 661421Sroot char *processname; 675328Smckusic struct fs *sblock; /* the file system super block */ 685328Smckusic char buf[MAXBSIZE]; 6930559Smckusick long dev_bsize; 701421Sroot 711421Sroot char *ctime(); 721421Sroot char *prdate(); 731421Sroot long atol(); 741421Sroot int mark(); 751421Sroot int add(); 7617234Smckusick int dirdump(); 771421Sroot int dump(); 781421Sroot int tapsrec(); 791421Sroot int dmpspc(); 801421Sroot int dsrch(); 811421Sroot int nullf(); 821421Sroot char *getsuffix(); 831421Sroot char *rawname(); 844701Smckusic struct dinode *getino(); 851421Sroot 861421Sroot int interrupt(); /* in case operator bangs on console */ 871421Sroot 881421Sroot #define HOUR (60L*60L) 891421Sroot #define DAY (24L*HOUR) 901421Sroot #define YEAR (365L*DAY) 911421Sroot 921421Sroot /* 931421Sroot * Exit status codes 941421Sroot */ 9528641Smckusick #define X_FINOK 0 /* normal exit */ 961421Sroot #define X_REWRITE 2 /* restart writing from the check point */ 971421Sroot #define X_ABORT 3 /* abort all of dump; don't attempt checkpointing*/ 981421Sroot 991421Sroot #define OPGRENT "operator" /* group entry to notify */ 1001421Sroot #define DIALUP "ttyd" /* prefix for dialups */ 1011421Sroot 1021421Sroot struct fstab *fstabsearch(); /* search in fs_file and fs_spec */ 1031421Sroot 1041421Sroot /* 10537266Sbostic * The contents of the file _PATH_DUMPDATES is maintained both on 1061421Sroot * a linked list, and then (eventually) arrayified. 1071421Sroot */ 1088375Smckusick struct idates { 1098375Smckusick char id_name[MAXNAMLEN+3]; 1108375Smckusick char id_incno; 1118375Smckusick time_t id_ddate; 1128375Smckusick }; 1131421Sroot struct itime{ 1141421Sroot struct idates it_value; 1151421Sroot struct itime *it_next; 1161421Sroot }; 1171421Sroot struct itime *ithead; /* head of the list version */ 1181421Sroot int nidates; /* number of records (might be zero) */ 1191421Sroot int idates_in; /* we have read the increment file */ 1201421Sroot struct idates **idatev; /* the arrayfied version */ 1211421Sroot #define ITITERATE(i, ip) for (i = 0,ip = idatev[0]; i < nidates; i++, ip = idatev[i]) 1221421Sroot 1231421Sroot /* 1241421Sroot * We catch these interrupts 1251421Sroot */ 1261421Sroot int sighup(); 1271421Sroot int sigquit(); 1281421Sroot int sigill(); 1291421Sroot int sigtrap(); 1301421Sroot int sigfpe(); 1311421Sroot int sigkill(); 1321421Sroot int sigbus(); 1331421Sroot int sigsegv(); 1341421Sroot int sigsys(); 1351421Sroot int sigalrm(); 1361421Sroot int sigterm(); 137