dump.h revision 138314
11558Srgrimes/*- 21558Srgrimes * Copyright (c) 1980, 1993 31558Srgrimes * The Regents of the University of California. All rights reserved. 41558Srgrimes * 51558Srgrimes * Redistribution and use in source and binary forms, with or without 61558Srgrimes * modification, are permitted provided that the following conditions 71558Srgrimes * are met: 81558Srgrimes * 1. Redistributions of source code must retain the above copyright 91558Srgrimes * notice, this list of conditions and the following disclaimer. 101558Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 111558Srgrimes * notice, this list of conditions and the following disclaimer in the 121558Srgrimes * documentation and/or other materials provided with the distribution. 131558Srgrimes * 4. Neither the name of the University nor the names of its contributors 141558Srgrimes * may be used to endorse or promote products derived from this software 151558Srgrimes * without specific prior written permission. 161558Srgrimes * 171558Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 181558Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 191558Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 201558Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 211558Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 221558Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 231558Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 241558Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 251558Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 261558Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 271558Srgrimes * SUCH DAMAGE. 281558Srgrimes * 2923672Speter * @(#)dump.h 8.2 (Berkeley) 4/28/95 3071787Sphk * 3171787Sphk * $FreeBSD: head/sbin/dump/dump.h 138314 2004-12-02 13:56:53Z maxim $ 321558Srgrimes */ 331558Srgrimes 341558Srgrimes/* 351558Srgrimes * Dump maps used to describe what is to be dumped. 361558Srgrimes */ 371558Srgrimesint mapsize; /* size of the state maps */ 381558Srgrimeschar *usedinomap; /* map of allocated inodes */ 391558Srgrimeschar *dumpdirmap; /* map of directories to be dumped */ 401558Srgrimeschar *dumpinomap; /* map of files to be dumped */ 411558Srgrimes/* 421558Srgrimes * Map manipulation macros. 431558Srgrimes */ 441558Srgrimes#define SETINO(ino, map) \ 45103949Smike map[(u_int)((ino) - 1) / CHAR_BIT] |= \ 46103949Smike 1 << ((u_int)((ino) - 1) % CHAR_BIT) 471558Srgrimes#define CLRINO(ino, map) \ 48103949Smike map[(u_int)((ino) - 1) / CHAR_BIT] &= \ 49103949Smike ~(1 << ((u_int)((ino) - 1) % CHAR_BIT)) 501558Srgrimes#define TSTINO(ino, map) \ 51103949Smike (map[(u_int)((ino) - 1) / CHAR_BIT] & \ 52103949Smike (1 << ((u_int)((ino) - 1) % CHAR_BIT))) 531558Srgrimes 541558Srgrimes/* 551558Srgrimes * All calculations done in 0.1" units! 561558Srgrimes */ 571558Srgrimeschar *disk; /* name of the disk file */ 581558Srgrimeschar *tape; /* name of the tape file */ 59128175Sgreenchar *popenout; /* popen(3) per-"tape" command */ 601558Srgrimeschar *dumpdates; /* name of the file containing dump date information*/ 611558Srgrimeschar *temp; /* name of the file for doing rewrite of dumpdates */ 621558Srgrimeschar lastlevel; /* dump level of previous dump */ 631558Srgrimeschar level; /* dump level of this dump */ 641558Srgrimesint uflag; /* update flag */ 651558Srgrimesint diskfd; /* disk file descriptor */ 661558Srgrimesint tapefd; /* tape file descriptor */ 671558Srgrimesint pipeout; /* true => output to standard output */ 681558Srgrimesino_t curino; /* current inumber; used globally */ 691558Srgrimesint newtape; /* new tape flag */ 701558Srgrimesint density; /* density in 0.1" units */ 711558Srgrimeslong tapesize; /* estimated tape size, blocks */ 721558Srgrimeslong tsize; /* tape size in 0.1" units */ 731558Srgrimeslong asize; /* number of 0.1" units written on current tape */ 741558Srgrimesint etapes; /* estimated number of tapes */ 751558Srgrimesint nonodump; /* if set, do not honor UF_NODUMP user flags */ 7622192Sjoergint unlimited; /* if set, write to end of medium */ 77109187Sdillonint cachesize; /* size of block cache in bytes */ 781558Srgrimes 791558Srgrimesint notify; /* notify operator flag */ 801558Srgrimesint blockswritten; /* number of blocks written on current tape */ 811558Srgrimesint tapeno; /* current tape number */ 821558Srgrimestime_t tstart_writing; /* when started writing the first tape block */ 8312377Sjoergtime_t tend_writing; /* after writing the last tape block */ 8490743Siedowseint passno; /* current dump pass number */ 85102231Strhodesstruct fs *sblock; /* the file system super block */ 861558Srgrimeschar sblock_buf[MAXBSIZE]; 871558Srgrimeslong dev_bsize; /* block size of underlying disk device */ 881558Srgrimesint dev_bshift; /* log2(dev_bsize) */ 891558Srgrimesint tp_bshift; /* log2(TP_BSIZE) */ 901558Srgrimes 911558Srgrimes/* operator interface functions */ 9292837Simpvoid broadcast(const char *message); 9392837Simpvoid infosch(int); 9492837Simpvoid lastdump(int arg); /* int should be char */ 9592837Simpvoid msg(const char *fmt, ...) __printflike(1, 2); 9692837Simpvoid msgtail(const char *fmt, ...) __printflike(1, 2); 9792837Simpint query(const char *question); 9892837Simpvoid quit(const char *fmt, ...) __printflike(1, 2); 9992837Simpvoid timeest(void); 10092837Simptime_t unctime(char *str); 1011558Srgrimes 1021558Srgrimes/* mapping rouintes */ 10398542Smckusickunion dinode; 10492837Simpint mapfiles(ino_t maxino, long *tapesize); 10592837Simpint mapdirs(ino_t maxino, long *tapesize); 1061558Srgrimes 1071558Srgrimes/* file dumping routines */ 10898542Smckusickvoid ufs1_blksout(ufs1_daddr_t *blkp, int frags, ino_t ino); 10998542Smckusickvoid ufs2_blksout(ufs2_daddr_t *blkp, int frags, ino_t ino); 11098542Smckusickvoid bread(ufs2_daddr_t blkno, char *buf, int size); 111122047Siedowsessize_t cread(int fd, void *buf, size_t nbytes, off_t offset); 11298542Smckusickvoid dumpino(union dinode *dp, ino_t ino); 11392837Simpvoid dumpmap(char *map, int type, ino_t ino); 11492837Simpvoid writeheader(ino_t ino); 1151558Srgrimes 1161558Srgrimes/* tape writing routines */ 11792837Simpint alloctape(void); 11892837Simpvoid close_rewind(void); 11998542Smckusickvoid dumpblock(ufs2_daddr_t blkno, int size); 12092837Simpvoid startnewtape(int top); 12192837Simpvoid trewind(void); 12292837Simpvoid writerec(char *dp, int isspcl); 1231558Srgrimes 12492837Simpvoid Exit(int status) __dead2; 12592837Simpvoid dumpabort(int signo); 126113214Smdoddvoid dump_getfstab(void); 1271558Srgrimes 12892837Simpchar *rawname(char *cp); 12998542Smckusickunion dinode *getino(ino_t inum, int *mode); 1301558Srgrimes 1311558Srgrimes/* rdump routines */ 1321558Srgrimes#ifdef RDUMP 13392837Simpvoid rmtclose(void); 13492837Simpint rmthost(const char *host); 13592837Simpint rmtopen(const char *tape, int mode); 13692837Simpint rmtwrite(const char *buf, int count); 1371558Srgrimes#endif /* RDUMP */ 1381558Srgrimes 13992837Simpvoid interrupt(int signo); /* in case operator bangs on console */ 1401558Srgrimes 1411558Srgrimes/* 1421558Srgrimes * Exit status codes 1431558Srgrimes */ 1441558Srgrimes#define X_FINOK 0 /* normal exit */ 14537635Sjkoshy#define X_STARTUP 1 /* startup error */ 1461558Srgrimes#define X_REWRITE 2 /* restart writing from the check point */ 1471558Srgrimes#define X_ABORT 3 /* abort dump; don't attempt checkpointing */ 1481558Srgrimes 1491558Srgrimes#define OPGRENT "operator" /* group entry to notify */ 1501558Srgrimes 15192837Simpstruct fstab *fstabsearch(const char *key); /* search fs_file and fs_spec */ 1521558Srgrimes 1531558Srgrimes#ifndef NAME_MAX 1541558Srgrimes#define NAME_MAX 255 1551558Srgrimes#endif 1561558Srgrimes 1571558Srgrimes/* 1581558Srgrimes * The contents of the file _PATH_DUMPDATES is maintained both on 1591558Srgrimes * a linked list, and then (eventually) arrayified. 1601558Srgrimes */ 1611558Srgrimesstruct dumpdates { 1621558Srgrimes char dd_name[NAME_MAX+3]; 1631558Srgrimes char dd_level; 1641558Srgrimes time_t dd_ddate; 1651558Srgrimes}; 1661558Srgrimesint nddates; /* number of records (might be zero) */ 1671558Srgrimesstruct dumpdates **ddatev; /* the arrayfied version */ 16892837Simpvoid initdumptimes(void); 16992837Simpvoid getdumptime(void); 17092837Simpvoid putdumptime(void); 1711558Srgrimes#define ITITERATE(i, ddp) \ 172138314Smaxim if (ddatev != NULL) \ 173138314Smaxim for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i]) 1741558Srgrimes 17592837Simpvoid sig(int signo); 1761558Srgrimes 1771558Srgrimes#ifndef _PATH_FSTAB 1781558Srgrimes#define _PATH_FSTAB "/etc/fstab" 1791558Srgrimes#endif 180