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