jcs's openbsd hax
openbsd
1/* $OpenBSD: dump.h,v 1.25 2021/01/21 00:16:36 mortimer Exp $ */
2/* $NetBSD: dump.h,v 1.11 1997/06/05 11:13:20 lukem Exp $ */
3
4/*-
5 * Copyright (c) 1980, 1993
6 * The Regents of the University of California. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the University nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * @(#)dump.h 8.1 (Berkeley) 6/5/93
33 */
34
35/*
36 * Dump maps used to describe what is to be dumped.
37 */
38extern int mapsize; /* size of the state maps */
39extern char *usedinomap; /* map of allocated inodes */
40extern char *dumpdirmap; /* map of directories to be dumped */
41extern char *dumpinomap; /* map of files to be dumped */
42/*
43 * Map manipulation macros.
44 */
45#define SETINO(ino, map) \
46 map[(u_int)((ino) - 1) / NBBY] |= 1 << ((u_int)((ino) - 1) % NBBY)
47#define CLRINO(ino, map) \
48 map[(u_int)((ino) - 1) / NBBY] &= ~(1 << ((u_int)((ino) - 1) % NBBY))
49#define TSTINO(ino, map) \
50 (map[(u_int)((ino) - 1) / NBBY] & (1 << ((u_int)((ino) - 1) % NBBY)))
51
52/*
53 * All calculations done in 0.1" units!
54 */
55extern char *disk; /* name of the disk file */
56extern char *tape; /* name of the tape file */
57extern char *dumpdates; /* name of the file containing dump date information*/
58extern char *duid; /* duid of the disk being dumped */
59extern char lastlevel; /* dump level of previous dump */
60extern char level; /* dump level of this dump */
61extern int uflag; /* update flag */
62extern int diskfd; /* disk file descriptor */
63extern int pipeout; /* true => output to standard output */
64extern ino_t curino; /* current inumber; used globally */
65extern int newtape; /* new tape flag */
66extern int density; /* density in 0.1" units */
67extern int64_t tapesize; /* estimated tape size, blocks */
68extern int64_t tsize; /* tape size in 0.1" units */
69extern int unlimited; /* if set, write to end of medium */
70extern int etapes; /* estimated number of tapes */
71extern int nonodump; /* if set, do not honor UF_NODUMP user flags */
72extern int notify; /* notify operator flag */
73extern int64_t blockswritten; /* number of blocks written on current tape */
74extern int tapeno; /* current tape number */
75extern int ntrec; /* blocking factor on tape */
76extern int64_t blocksperfile; /* number of blocks per output file */
77extern int cartridge; /* assume non-cartridge tape */
78extern char *host; /* remote host (if any) */
79extern time_t tstart_writing; /* when started writing the first tape block */
80extern long xferrate; /* averaged transfer rate of all volumes */
81extern struct fs *sblock; /* the file system super block */
82extern char sblock_buf[MAXBSIZE];
83extern int tp_bshift; /* log2(TP_BSIZE) */
84
85/* operator interface functions */
86void broadcast(char *message);
87time_t do_stats(void);
88void lastdump(int arg); /* int should be char */
89void msg(const char *fmt, ...)
90 __attribute__((__format__ (printf, 1, 2)));
91void msgtail(const char *fmt, ...)
92 __attribute__((__format__ (printf, 1, 2)));
93int query(char *question);
94__dead void quit(const char *fmt, ...)
95 __attribute__((__format__ (printf, 1, 2)));
96void statussig(int);
97void timeest(void);
98
99/* mapping routines */
100union dinode;
101int64_t blockest(union dinode *dp);
102void mapfileino(ino_t, int64_t *, int *);
103int mapfiles(ino_t maxino, int64_t *tapesize, char *disk,
104 char * const *dirv);
105int mapdirs(ino_t maxino, int64_t *tapesize);
106
107/* file dumping routines */
108void ufs1_blksout(int32_t *blkp, int frags, ino_t ino);
109void ufs2_blksout(daddr_t *blkp, int frags, ino_t ino);
110void bread(daddr_t blkno, char *buf, int size);
111void dumpino(union dinode *dp, ino_t ino);
112void dumpmap(char *map, int type, ino_t ino);
113void writeheader(ino_t ino);
114
115/* tape writing routines */
116int alloctape(void);
117void close_rewind(void);
118void dumpblock(daddr_t blkno, int size);
119void startnewtape(int top);
120void trewind(void);
121void writerec(char *dp, int isspcl);
122
123__dead void Exit(int status);
124__dead void dumpabort(int signo);
125void getfstab(void);
126
127char *rawname(char *cp);
128char *getduid(char *path);
129union dinode *getino(ino_t inum, int *mode);
130
131/* rdump routines */
132#ifdef RDUMP
133void rmtclose(void);
134int rmthost(char *host);
135int rmtopen(char *tape, int mode);
136int rmtwrite(char *buf, int count);
137#endif /* RDUMP */
138
139void interrupt(int signo); /* in case operator bangs on console */
140
141/*
142 * Exit status codes
143 */
144#define X_FINOK 0 /* normal exit */
145#define X_STARTUP 1 /* startup error */
146#define X_REWRITE 2 /* restart writing from the check point */
147#define X_ABORT 3 /* abort dump; don't attempt checkpointing */
148
149#define OPGRENT "operator" /* group entry to notify */
150
151struct fstab *fstabsearch(char *key); /* search fs_file and fs_spec */
152
153/*
154 * The contents of the file _PATH_DUMPDATES is maintained both on
155 * a linked list, and then (eventually) arrayified.
156 */
157struct dumpdates {
158 char dd_name[NAME_MAX+3];
159 char dd_level;
160 time_t dd_ddate;
161};
162struct dumptime {
163 struct dumpdates dt_value;
164 struct dumptime *dt_next;
165};
166extern struct dumptime *dthead; /* head of the list version */
167extern int ddates_in; /* we have read the increment file */
168extern int nddates; /* number of records (might be zero) */
169extern struct dumpdates **ddatev; /* the arrayfied version */
170void initdumptimes(void);
171void getdumptime(void);
172void putdumptime(void);
173#define ITITERATE(i, ddp) \
174 for (i = 0; i < nddates && (ddp = ddatev[i]); i++)
175
176void sig(int signo);
177