]> git.wh0rd.org - dump.git/blame - dump/dump.h
Made dump -w|-W report all recognized filesystems...
[dump.git] / dump / dump.h
CommitLineData
1227625a
SP
1/*
2 * Ported to Linux's Second Extended File System as part of the
3 * dump and restore backup suit
b45f51d6 4 * Remy Card <card@Linux.EU.Org>, 1994-1997
ebcbe7f6 5 * Stelian Pop <pop@cybercable.fr>, 1999-2000
1227625a 6 *
51b01afe 7 * $Id: dump.h,v 1.14 2000/11/10 11:48:31 stelian Exp $
1227625a
SP
8 */
9
10/*-
11 * Copyright (c) 1980, 1993
12 * The Regents of the University of California. All rights reserved.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 * 3. All advertising materials mentioning features or use of this software
23 * must display the following acknowledgement:
24 * This product includes software developed by the University of
25 * California, Berkeley and its contributors.
26 * 4. Neither the name of the University nor the names of its contributors
27 * may be used to endorse or promote products derived from this software
28 * without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
31 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
34 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
36 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
37 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 * SUCH DAMAGE.
1227625a
SP
41 */
42
43#define MAXINOPB (MAXBSIZE / sizeof(struct dinode))
44#define MAXNINDIR (MAXBSIZE / sizeof(daddr_t))
45
46/*
47 * Dump maps used to describe what is to be dumped.
48 */
49int mapsize; /* size of the state maps */
50char *usedinomap; /* map of allocated inodes */
51char *dumpdirmap; /* map of directories to be dumped */
52char *dumpinomap; /* map of files to be dumped */
53/*
54 * Map manipulation macros.
55 */
56#define SETINO(ino, map) \
57 map[(u_int)((ino) - 1) / NBBY] |= 1 << ((u_int)((ino) - 1) % NBBY)
58#define CLRINO(ino, map) \
59 map[(u_int)((ino) - 1) / NBBY] &= ~(1 << ((u_int)((ino) - 1) % NBBY))
60#define TSTINO(ino, map) \
61 (map[(u_int)((ino) - 1) / NBBY] & (1 << ((u_int)((ino) - 1) % NBBY)))
62
63/*
64 * All calculations done in 0.1" units!
65 */
66char *disk; /* name of the disk file */
92a9bf12 67char tape[MAXPATHLEN]; /* name of the tape file */
d1c73b9a 68char *tapeprefix; /* prefix of the tape file */
1227625a 69char *dumpdates; /* name of the file containing dump date information*/
1227625a
SP
70char lastlevel; /* dump level of previous dump */
71char level; /* dump level of this dump */
72int uflag; /* update flag */
d1c73b9a 73int Mflag; /* multi-volume flag */
0d7af9c5 74char *eot_script; /* end of volume script fiag */
1227625a
SP
75int diskfd; /* disk file descriptor */
76int tapefd; /* tape file descriptor */
77int pipeout; /* true => output to standard output */
78ino_t curino; /* current inumber; used globally */
79int newtape; /* new tape flag */
80int density; /* density in 0.1" units */
81long tapesize; /* estimated tape size, blocks */
82long tsize; /* tape size in 0.1" units */
83long asize; /* number of 0.1" units written on current tape */
84int etapes; /* estimated number of tapes */
85int nonodump; /* if set, do not honor UF_NODUMP user flags */
b45f51d6 86int unlimited; /* if set, write to end of medium */
1227625a
SP
87
88int notify; /* notify operator flag */
89int blockswritten; /* number of blocks written on current tape */
90int tapeno; /* current tape number */
91time_t tstart_writing; /* when started writing the first tape block */
b45f51d6 92time_t tend_writing; /* after writing the last tape block */
1227625a 93#ifdef __linux__
1227625a
SP
94ext2_filsys fs;
95#else
96struct fs *sblock; /* the file system super block */
97char sblock_buf[MAXBSIZE];
98#endif
ddd2ef55 99long xferrate; /* averaged transfer rate of all volumes */
1227625a
SP
100long dev_bsize; /* block size of underlying disk device */
101int dev_bshift; /* log2(dev_bsize) */
102int tp_bshift; /* log2(TP_BSIZE) */
103
104#ifndef __P
105#include <sys/cdefs.h>
106#endif
107
108/* operator interface functions */
ddd2ef55
SP
109void broadcast __P((const char *message));
110time_t do_stats __P((void));
111void lastdump __P((char arg));
1227625a
SP
112void msg __P((const char *fmt, ...));
113void msgtail __P((const char *fmt, ...));
ddd2ef55 114int query __P((const char *question));
1227625a
SP
115void quit __P((const char *fmt, ...));
116void set_operators __P((void));
ddd2ef55
SP
117#if defined(SIGINFO)
118void statussig __P((int signo));
119#endif
1227625a 120void timeest __P((void));
ddd2ef55 121time_t unctime __P((const char *str));
1227625a
SP
122
123/* mapping rouintes */
124struct dinode;
125long blockest __P((struct dinode *dp));
126int mapfiles __P((ino_t maxino, long *tapesize));
127#ifdef __linux__
128int mapfilesfromdir __P((ino_t maxino, long *tapesize, char *directory));
129#endif
130int mapdirs __P((ino_t maxino, long *tapesize));
131
132/* file dumping routines */
133void blksout __P((daddr_t *blkp, int frags, ino_t ino));
b45f51d6 134void bread __P((daddr_t blkno, char *buf, int size));
1227625a
SP
135void dumpino __P((struct dinode *dp, ino_t ino));
136#ifdef __linux__
137void dumpdirino __P((struct dinode *dp, ino_t ino));
138#endif
139void dumpmap __P((char *map, int type, ino_t ino));
140void writeheader __P((ino_t ino));
141
142/* tape writing routines */
143int alloctape __P((void));
144void close_rewind __P((void));
145void dumpblock __P((daddr_t blkno, int size));
146void startnewtape __P((int top));
0d7af9c5 147time_t trewind __P((void));
ddd2ef55 148void writerec __P((const void *dp, int isspcl));
1227625a 149
ddd2ef55 150void Exit __P((int status));
1227625a
SP
151void dumpabort __P((int signo));
152void getfstab __P((void));
153
154char *rawname __P((char *cp));
155struct dinode *getino __P((ino_t inum));
156
157/* rdump routines */
158#ifdef RDUMP
ddd2ef55
SP
159int rmthost __P((const char *host));
160int rmtopen __P((const char *tape, int mode));
1227625a 161void rmtclose __P((void));
ddd2ef55
SP
162int rmtread __P((char *buf, size_t count));
163int rmtwrite __P((const char *buf, size_t count));
164int rmtseek __P((int offset, int pos));
165struct mtget * rmtstatus __P((void));
166int rmtioctl __P((int cmd, int count));
1227625a
SP
167#endif /* RDUMP */
168
169void interrupt __P((int signo)); /* in case operator bangs on console */
170
171/*
172 * Exit status codes
173 */
174#define X_FINOK 0 /* normal exit */
ddd2ef55 175#define X_STARTUP 1 /* startup error */
1227625a
SP
176#define X_REWRITE 2 /* restart writing from the check point */
177#define X_ABORT 3 /* abort dump; don't attempt checkpointing */
178
179#define OPGRENT "operator" /* group entry to notify */
180#ifdef __linux__
181#define DIALUP "ttyS" /* prefix for dialups */
182#else
183#define DIALUP "ttyd" /* prefix for dialups */
184#endif
185
ddd2ef55 186struct fstab *fstabsearch __P((const char *key)); /* search fs_file and fs_spec */
1227625a 187#ifdef __linux__
ddd2ef55 188struct fstab *fstabsearchdir __P((const char *key, char *dir)); /* search fs_file and fs_spec */
1227625a
SP
189#endif
190
1227625a
SP
191/*
192 * The contents of the file _PATH_DUMPDATES is maintained both on
193 * a linked list, and then (eventually) arrayified.
194 */
195struct dumpdates {
92a9bf12 196 char dd_name[MAXPATHLEN+3];
51b01afe 197 struct fstab *dd_fstab;
1227625a
SP
198 char dd_level;
199 time_t dd_ddate;
200};
201struct dumptime {
202 struct dumpdates dt_value;
203 struct dumptime *dt_next;
204};
205struct dumptime *dthead; /* head of the list version */
206int nddates; /* number of records (might be zero) */
207int ddates_in; /* we have read the increment file */
208struct dumpdates **ddatev; /* the arrayfied version */
8d4197bb
SP
209void initdumptimes __P((int));
210void getdumptime __P((int));
1227625a
SP
211void putdumptime __P((void));
212#define ITITERATE(i, ddp) \
213 for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i])
214
215void sig __P((int signo));
216
217/*
218 * Compatibility with old systems.
219 */
220#ifdef COMPAT
221#include <sys/file.h>
222#define strchr(a,b) index(a,b)
223#define strrchr(a,b) rindex(a,b)
224extern char *strdup(), *ctime();
225extern int read(), write();
226extern int errno;
227#endif
228
229#ifdef __linux__
8d4197bb 230#define DUMP_CURRENT_REV 1
c930abff
SP
231
232int dump_fs_open(const char *disk, ext2_filsys *fs);
1227625a
SP
233#endif
234
235#ifndef __linux__
236#ifndef _PATH_UTMP
237#define _PATH_UTMP "/etc/utmp"
238#endif
239#ifndef _PATH_FSTAB
240#define _PATH_FSTAB "/etc/fstab"
241#endif
242#endif
243
244#ifdef sunos
245extern char *calloc();
246extern char *malloc();
247extern long atol();
248extern char *strcpy();
249extern char *strncpy();
250extern char *strcat();
251extern time_t time();
252extern void endgrent();
b45f51d6 253extern void exit();
1227625a
SP
254extern off_t lseek();
255extern const char *strerror();
256#endif
20c345aa
SP
257
258 /* 04-Feb-00 ILC */
259#define IEXCLUDE_MAXNUM 256 /* max size of inode exclude list */
260