]>
git.wh0rd.org - dump.git/blob - dump/dump.h
2 * Ported to Linux's Second Extended File System as part of the
3 * dump and restore backup suit
4 * Remy Card <card@Linux.EU.Org>, 1994-1997
5 * Stelian Pop <stelian@popies.net>, 1999-2000
6 * Stelian Pop <stelian@popies.net> - AlcĂ´ve <www.alcove.com>, 2000-2002
8 * $Id: dump.h,v 1.37 2002/04/04 08:20:23 stelian Exp $
12 * Copyright (c) 1980, 1993
13 * The Regents of the University of California. All rights reserved.
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 * 3. All advertising materials mentioning features or use of this software
24 * must display the following acknowledgement:
25 * This product includes software developed by the University of
26 * California, Berkeley and its contributors.
27 * 4. Neither the name of the University nor the names of its contributors
28 * may be used to endorse or promote products derived from this software
29 * without specific prior written permission.
31 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
32 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
33 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
34 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
35 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
39 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
40 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
45 #include <protocols/dumprestore.h>
47 #define MAXINOPB (MAXBSIZE / sizeof(struct dinode))
48 #define MAXNINDIR (MAXBSIZE / sizeof(daddr_t))
51 * Dump maps used to describe what is to be dumped.
53 extern int mapsize
; /* size of the state maps */
54 extern char *usedinomap
; /* map of allocated inodes */
55 extern char *dumpdirmap
; /* map of directories to be dumped */
56 extern char *dumpinomap
; /* map of files to be dumped */
57 extern char *metainomap
; /* which of the inodes in dumpinomap
58 will get only their metadata dumped */
60 * Map manipulation macros.
62 #define SETINO(ino, map) \
63 map[(u_int)((ino) - 1) / NBBY] |= 1 << ((u_int)((ino) - 1) % NBBY)
64 #define CLRINO(ino, map) \
65 map[(u_int)((ino) - 1) / NBBY] &= ~(1 << ((u_int)((ino) - 1) % NBBY))
66 #define TSTINO(ino, map) \
67 (map[(u_int)((ino) - 1) / NBBY] & (1 << ((u_int)((ino) - 1) % NBBY)))
70 * All calculations done in 0.1" units!
72 extern char *host
; /* name of the remote host */
73 extern const char *disk
; /* name of the disk file */
74 extern char tape
[MAXPATHLEN
];/* name of the tape file */
75 extern char *tapeprefix
; /* prefix of the tape file */
76 extern char *dumpdates
; /* name of the file containing dump date information*/
77 extern char lastlevel
; /* dump level of previous dump */
78 extern char level
; /* dump level of this dump */
79 extern int Afile
; /* archive file descriptor */
80 extern int bzipflag
; /* compression is done using bzlib */
81 extern int uflag
; /* update flag */
82 extern int mflag
; /* dump metadata only if possible flag */
83 extern int Mflag
; /* multi-volume flag */
84 extern int qflag
; /* quit on errors flag */
85 extern int breademax
; /* maximum number of bread errors before we quit */
86 extern char *eot_script
; /* end of volume script fiag */
87 extern int diskfd
; /* disk file descriptor */
88 extern int tapefd
; /* tape file descriptor */
89 extern int pipeout
; /* true => output to standard output */
90 extern int fifoout
; /* true => output to fifo */
91 extern dump_ino_t curino
; /* current inumber; used globally */
92 extern int newtape
; /* new tape flag */
93 extern int density
; /* density in 0.1" units */
94 extern long tapesize
; /* estimated tape size, blocks */
95 extern long tsize
; /* tape size in 0.1" units */
96 extern long asize
; /* number of 0.1" units written on current tape */
97 extern int etapes
; /* estimated number of tapes */
98 extern int nonodump
; /* if set, do not honor UF_NODUMP user flags */
99 extern int unlimited
; /* if set, write to end of medium */
100 extern int compressed
; /* if set, dump is to be compressed */
101 extern long long bytes_written
;/* total bytes written to tape */
102 extern long uncomprblks
; /* uncompressed blocks written to tape */
103 extern int notify
; /* notify operator flag */
104 extern int blockswritten
; /* number of blocks written on current tape */
105 extern int tapeno
; /* current tape number */
106 extern time_t tstart_writing
; /* when started writing the first tape block */
107 extern time_t tend_writing
; /* after writing the last tape block */
109 extern ext2_filsys fs
;
111 extern struct fs
*sblock
; /* the file system super block */
112 extern char sblock_buf
[MAXBSIZE
];
114 extern long xferrate
; /* averaged transfer rate of all volumes */
115 extern long dev_bsize
; /* block size of underlying disk device */
116 extern int dev_bshift
; /* log2(dev_bsize) */
117 extern int tp_bshift
; /* log2(TP_BSIZE) */
118 extern dump_ino_t volinfo
[]; /* which inode on which volume archive info */
121 #define QFA_MAGIC "495115637697"
122 #define QFA_VERSION "1.0"
123 extern int gTapeposfd
;
124 extern char *gTapeposfile
;
125 extern char gTps
[255];
126 extern int32_t gThisDumpDate
;
130 #include <sys/cdefs.h>
133 /* operator interface functions */
134 void broadcast
__P((const char *message
));
135 time_t do_stats
__P((void));
136 void lastdump
__P((char arg
));
137 void msg
__P((const char *fmt
, ...));
138 void msgtail
__P((const char *fmt
, ...));
139 int query
__P((const char *question
));
140 void quit
__P((const char *fmt
, ...));
141 void set_operators
__P((void));
143 void statussig
__P((int signo
));
145 void timeest
__P((void));
146 time_t unctime
__P((const char *str
));
148 /* mapping rouintes */
150 long blockest
__P((struct dinode
const *dp
));
151 int mapfiles
__P((dump_ino_t maxino
, long *tapesize
));
153 int mapfilesfromdir
__P((dump_ino_t maxino
, long *tapesize
, char *directory
));
154 int maponefile
__P((dump_ino_t maxino
, long *tapesize
, char *directory
));
156 int mapdirs
__P((dump_ino_t maxino
, long *tapesize
));
158 /* file dumping routines */
159 void blksout
__P((daddr_t
*blkp
, int frags
, dump_ino_t ino
));
160 void bread
__P((daddr_t blkno
, char *buf
, int size
));
161 void dumpino
__P((struct dinode
*dp
, dump_ino_t ino
, int metaonly
));
163 void dumpdirino
__P((struct dinode
*dp
, dump_ino_t ino
));
165 void dumpmap
__P((char *map
, int type
, dump_ino_t ino
));
166 void writeheader
__P((dump_ino_t ino
));
167 void mkchecksum
__P((union u_spcl
*tmpspcl
));
169 /* tape writing routines */
170 int alloctape
__P((void));
171 void close_rewind
__P((void));
172 void dumpblock
__P((daddr_t blkno
, int size
));
173 void startnewtape
__P((int top
));
174 time_t trewind
__P((void));
175 void writerec
__P((const void *dp
, int isspcl
));
176 char *mktimeest
__P((time_t tnow
));
178 void Exit
__P((int status
));
179 void dumpabort
__P((int signo
));
180 void getfstab
__P((void));
182 const char *rawname
__P((const char *cp
));
183 struct dinode
*getino
__P((dump_ino_t inum
));
187 int rmthost
__P((const char *host
));
188 int rmtopen
__P((const char *tape
, int mode
));
189 void rmtclose
__P((void));
190 int rmtread
__P((char *buf
, size_t count
));
191 int rmtwrite
__P((const char *buf
, size_t count
));
192 int rmtseek
__P((int offset
, int pos
));
193 struct mtget
* rmtstatus
__P((void));
194 int rmtioctl
__P((int cmd
, int count
));
197 void interrupt
__P((int signo
)); /* in case operator bangs on console */
198 int exclude_ino
__P((dump_ino_t ino
));
199 void do_exclude_ino
__P((dump_ino_t ino
, const char *));
204 #define X_FINOK 0 /* normal exit */
205 #define X_STARTUP 1 /* startup error */
206 #define X_REWRITE 2 /* restart writing from the check point */
207 #define X_ABORT 3 /* abort dump; don't attempt checkpointing */
209 #define OPGRENT "operator" /* group entry to notify */
211 #define DIALUP "ttyS" /* prefix for dialups */
213 #define DIALUP "ttyd" /* prefix for dialups */
216 struct fstab
*fstabsearch
__P((const char *key
)); /* search fs_file and fs_spec */
218 struct fstab
*fstabsearchdir
__P((const char *key
, char *dir
)); /* search fs_file and fs_spec */
222 * The contents of the file _PATH_DUMPDATES is maintained both on
223 * a linked list, and then (eventually) arrayified.
226 char dd_name
[MAXPATHLEN
+3];
227 struct fstab
*dd_fstab
;
232 struct dumpdates dt_value
;
233 struct dumptime
*dt_next
;
235 extern struct dumptime
*dthead
; /* head of the list version */
236 extern int nddates
; /* number of records (might be zero) */
237 extern int ddates_in
; /* we have read the increment file */
238 extern struct dumpdates
**ddatev
; /* the arrayfied version */
239 void initdumptimes
__P((int));
240 void getdumptime
__P((int));
241 void putdumptime
__P((void));
242 #define ITITERATE(i, ddp) \
243 for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i])
245 void sig
__P((int signo
));
248 * Compatibility with old systems.
251 #include <sys/file.h>
252 #define strchr(a,b) index(a,b)
253 #define strrchr(a,b) rindex(a,b)
254 extern char *strdup(), *ctime();
255 extern int read(), write();
260 #define DUMP_CURRENT_REV 1
262 int dump_fs_open(const char *disk
, ext2_filsys
*fs
);
267 #define _PATH_UTMP "/etc/utmp"
270 #define _PATH_FSTAB "/etc/fstab"
275 extern char *calloc();
276 extern char *malloc();
278 extern char *strcpy();
279 extern char *strncpy();
280 extern char *strcat();
281 extern time_t time();
282 extern void endgrent();
284 extern off_t
lseek();
285 extern const char *strerror();
289 #define IEXCLUDE_MAXNUM 256 /* max size of inode exclude list */