1 /*- 2 * Copyright (c) 1980, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of the University nor the names of its contributors 14 * may be used to endorse or promote products derived from this software 15 * without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)dump.h 8.2 (Berkeley) 4/28/95 30 * 31 * $FreeBSD: src/sbin/dump/dump.h,v 1.7.6.4 2003/01/25 18:54:59 dillon Exp $ 32 */ 33 34 #include <sys/param.h> 35 36 #define MAXINOPB (MAXBSIZE / sizeof(struct ufs1_dinode)) 37 #define MAXNINDIR (MAXBSIZE / sizeof(daddr_t)) 38 39 /* 40 * Dump maps used to describe what is to be dumped. 41 */ 42 extern int mapsize; /* size of the state maps */ 43 extern char *usedinomap; /* map of allocated inodes */ 44 extern char *dumpdirmap; /* map of directories to be dumped */ 45 extern char *dumpinomap; /* map of files to be dumped */ 46 /* 47 * Map manipulation macros. 48 */ 49 #define SETINO(ino, map) setbit(map, (u_int)((ino) - 1)) 50 #define CLRINO(ino, map) clrbit(map, (u_int)((ino) - 1)) 51 #define TSTINO(ino, map) isset(map, (u_int)((ino) - 1)) 52 53 /* 54 * All calculations done in 0.1" units! 55 */ 56 extern char *disk; /* name of the disk file */ 57 extern const char *tape; /* name of the tape file */ 58 extern const char *dumpdates; /* name of the file containing dump date information*/ 59 extern int lastlevel; /* dump level of previous dump */ 60 extern int level; /* dump level of this dump */ 61 extern int uflag; /* update flag */ 62 extern int diskfd; /* disk file descriptor */ 63 extern int pipeout; /* true => output to standard output */ 64 extern ufs1_ino_t curino; /* current inumber; used globally */ 65 extern int newtape; /* new tape flag */ 66 extern long tapesize; /* estimated tape size, blocks */ 67 extern long tsize; /* tape size in 0.1" units */ 68 extern int etapes; /* estimated number of tapes */ 69 extern int nonodump; /* if set, do not honor UF_NODUMP user flags */ 70 extern int unlimited; /* if set, write to end of medium */ 71 extern int tapeno; /* current tape number */ 72 extern int density; /* density in 0.1" units */ 73 extern int cachesize; /* size of block cache */ 74 extern int dokerberos; 75 #ifdef NTREC_LONG 76 extern long ntrec; /* used by sbin/restore */ 77 #else 78 extern int ntrec; /* blocking factor on tape */ 79 #endif 80 extern int cartridge; 81 extern const char *host; 82 extern long blocksperfile; /* number of blocks per output file */ 83 extern int notify; /* notify operator flag */ 84 extern int blockswritten; /* number of blocks written on current tape */ 85 extern long dev_bsize; /* block size of underlying disk device */ 86 87 extern time_t tstart_writing; /* when started writing the first tape block */ 88 extern time_t tend_writing; /* after writing the last tape block */ 89 extern int passno; /* current dump pass number */ 90 extern struct fs *sblock; /* the file system super block */ 91 extern int dev_bshift; /* log2(dev_bsize) */ 92 extern int tp_bshift; /* log2(TP_BSIZE) */ 93 94 /* operator interface functions */ 95 void broadcast(const char *); 96 void infosch(int); 97 void lastdump(int); /* int should be char */ 98 void msg(const char *, ...) __printflike(1, 2); 99 void msgtail(const char *, ...) __printflike(1, 2); 100 int query(const char *); 101 void quit(const char *, ...) __dead2 __printflike(1, 2); 102 void timeest(void); 103 time_t unctime(const char *); 104 105 /* mapping rouintes */ 106 struct ufs1_dinode; 107 long blockest(struct ufs1_dinode *); 108 int mapfiles(ufs1_ino_t maxino, long *); 109 int mapdirs(ufs1_ino_t maxino, long *); 110 111 /* file dumping routines */ 112 void blksout(daddr_t *, int, ufs1_ino_t); 113 void bread(daddr_t, char *, int); 114 ssize_t cread(int, void *, size_t, off_t); 115 void dumpino(struct ufs1_dinode *, ufs1_ino_t); 116 void dumpmap(const char *, int, ufs1_ino_t); 117 void writeheader(ufs1_ino_t); 118 119 /* tape writing routines */ 120 int alloctape(void); 121 void close_rewind(void); 122 void dumpblock(daddr_t, int); 123 void startnewtape(int); 124 void trewind(void); 125 void writerec(const void *, int); 126 127 void Exit(int) __dead2; 128 void dumpabort(int) __dead2; 129 void dump_getfstab(void); 130 131 char *rawname(char *); 132 struct ufs1_dinode *getino(ufs1_ino_t); 133 134 /* rdump routines */ 135 #if defined(RDUMP) || defined(RRESTORE) 136 void rmtclose(void); 137 int rmthost(const char *); 138 int rmtopen(const char *, int); 139 int rmtwrite(const void *, int); 140 #endif /* RDUMP || RRESTORE */ 141 142 /* rrestore routines */ 143 #ifdef RRESTORE 144 int rmtread(char *, int); 145 int rmtseek(int, int); 146 int rmtioctl(int, int); 147 #endif /* RRESTORE */ 148 149 void interrupt(int); /* in case operator bangs on console */ 150 151 /* 152 * Exit status codes 153 */ 154 #define X_FINOK 0 /* normal exit */ 155 #define X_STARTUP 1 /* startup error */ 156 #define X_REWRITE 2 /* restart writing from the check point */ 157 #define X_ABORT 3 /* abort dump; don't attempt checkpointing */ 158 159 #define OPGRENT "operator" /* group entry to notify */ 160 161 struct fstab *fstabsearch(const char *); /* search fs_file and fs_spec */ 162 163 #ifndef NAME_MAX 164 #define NAME_MAX 255 165 #endif 166 167 /* 168 * The contents of the file _PATH_DUMPDATES is maintained both on 169 * a linked list, and then (eventually) arrayified. 170 */ 171 struct dumpdates { 172 char dd_name[NAME_MAX+3]; 173 char dd_level; 174 time_t dd_ddate; 175 }; 176 extern int nddates; /* number of records (might be zero) */ 177 extern struct dumpdates **ddatev; /* the arrayfied version */ 178 void initdumptimes(void); 179 void getdumptime(void); 180 void putdumptime(void); 181 #define ITITERATE(i, ddp) \ 182 if (ddatev != NULL) \ 183 for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i]) 184 185 void sig(int); 186