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