]>
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 <pop@cybercable.fr>, 1999-2000
7 * $Id: dump.h,v 1.13 2000/03/02 11:34:51 stelian Exp $
11 * Copyright (c) 1980, 1993
12 * The Regents of the University of California. All rights reserved.
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
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.
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
43 #define MAXINOPB (MAXBSIZE / sizeof(struct dinode))
44 #define MAXNINDIR (MAXBSIZE / sizeof(daddr_t))
47 * Dump maps used to describe what is to be dumped.
49 int mapsize
; /* size of the state maps */
50 char *usedinomap
; /* map of allocated inodes */
51 char *dumpdirmap
; /* map of directories to be dumped */
52 char *dumpinomap
; /* map of files to be dumped */
54 * Map manipulation macros.
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)))
64 * All calculations done in 0.1" units!
66 char *disk
; /* name of the disk file */
67 char tape
[MAXPATHLEN
]; /* name of the tape file */
68 char *tapeprefix
; /* prefix of the tape file */
69 char *dumpdates
; /* name of the file containing dump date information*/
70 char lastlevel
; /* dump level of previous dump */
71 char level
; /* dump level of this dump */
72 int uflag
; /* update flag */
73 int Mflag
; /* multi-volume flag */
74 char *eot_script
; /* end of volume script fiag */
75 int diskfd
; /* disk file descriptor */
76 int tapefd
; /* tape file descriptor */
77 int pipeout
; /* true => output to standard output */
78 ino_t curino
; /* current inumber; used globally */
79 int newtape
; /* new tape flag */
80 int density
; /* density in 0.1" units */
81 long tapesize
; /* estimated tape size, blocks */
82 long tsize
; /* tape size in 0.1" units */
83 long asize
; /* number of 0.1" units written on current tape */
84 int etapes
; /* estimated number of tapes */
85 int nonodump
; /* if set, do not honor UF_NODUMP user flags */
86 int unlimited
; /* if set, write to end of medium */
88 int notify
; /* notify operator flag */
89 int blockswritten
; /* number of blocks written on current tape */
90 int tapeno
; /* current tape number */
91 time_t tstart_writing
; /* when started writing the first tape block */
92 time_t tend_writing
; /* after writing the last tape block */
96 struct fs
*sblock
; /* the file system super block */
97 char sblock_buf
[MAXBSIZE
];
99 long xferrate
; /* averaged transfer rate of all volumes */
100 long dev_bsize
; /* block size of underlying disk device */
101 int dev_bshift
; /* log2(dev_bsize) */
102 int tp_bshift
; /* log2(TP_BSIZE) */
105 #include <sys/cdefs.h>
108 /* operator interface functions */
109 void broadcast
__P((const char *message
));
110 time_t do_stats
__P((void));
111 void lastdump
__P((char arg
));
112 void msg
__P((const char *fmt
, ...));
113 void msgtail
__P((const char *fmt
, ...));
114 int query
__P((const char *question
));
115 void quit
__P((const char *fmt
, ...));
116 void set_operators
__P((void));
118 void statussig
__P((int signo
));
120 void timeest
__P((void));
121 time_t unctime
__P((const char *str
));
123 /* mapping rouintes */
125 long blockest
__P((struct dinode
*dp
));
126 int mapfiles
__P((ino_t maxino
, long *tapesize
));
128 int mapfilesfromdir
__P((ino_t maxino
, long *tapesize
, char *directory
));
130 int mapdirs
__P((ino_t maxino
, long *tapesize
));
132 /* file dumping routines */
133 void blksout
__P((daddr_t
*blkp
, int frags
, ino_t ino
));
134 void bread
__P((daddr_t blkno
, char *buf
, int size
));
135 void dumpino
__P((struct dinode
*dp
, ino_t ino
));
137 void dumpdirino
__P((struct dinode
*dp
, ino_t ino
));
139 void dumpmap
__P((char *map
, int type
, ino_t ino
));
140 void writeheader
__P((ino_t ino
));
142 /* tape writing routines */
143 int alloctape
__P((void));
144 void close_rewind
__P((void));
145 void dumpblock
__P((daddr_t blkno
, int size
));
146 void startnewtape
__P((int top
));
147 time_t trewind
__P((void));
148 void writerec
__P((const void *dp
, int isspcl
));
150 void Exit
__P((int status
));
151 void dumpabort
__P((int signo
));
152 void getfstab
__P((void));
154 char *rawname
__P((char *cp
));
155 struct dinode
*getino
__P((ino_t inum
));
159 int rmthost
__P((const char *host
));
160 int rmtopen
__P((const char *tape
, int mode
));
161 void rmtclose
__P((void));
162 int rmtread
__P((char *buf
, size_t count
));
163 int rmtwrite
__P((const char *buf
, size_t count
));
164 int rmtseek
__P((int offset
, int pos
));
165 struct mtget
* rmtstatus
__P((void));
166 int rmtioctl
__P((int cmd
, int count
));
169 void interrupt
__P((int signo
)); /* in case operator bangs on console */
174 #define X_FINOK 0 /* normal exit */
175 #define X_STARTUP 1 /* startup error */
176 #define X_REWRITE 2 /* restart writing from the check point */
177 #define X_ABORT 3 /* abort dump; don't attempt checkpointing */
179 #define OPGRENT "operator" /* group entry to notify */
181 #define DIALUP "ttyS" /* prefix for dialups */
183 #define DIALUP "ttyd" /* prefix for dialups */
186 struct fstab
*fstabsearch
__P((const char *key
)); /* search fs_file and fs_spec */
188 struct fstab
*fstabsearchdir
__P((const char *key
, char *dir
)); /* search fs_file and fs_spec */
192 * The contents of the file _PATH_DUMPDATES is maintained both on
193 * a linked list, and then (eventually) arrayified.
196 char dd_name
[MAXPATHLEN
+3];
201 struct dumpdates dt_value
;
202 struct dumptime
*dt_next
;
204 struct dumptime
*dthead
; /* head of the list version */
205 int nddates
; /* number of records (might be zero) */
206 int ddates_in
; /* we have read the increment file */
207 struct dumpdates
**ddatev
; /* the arrayfied version */
208 void initdumptimes
__P((int));
209 void getdumptime
__P((int));
210 void putdumptime
__P((void));
211 #define ITITERATE(i, ddp) \
212 for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i])
214 void sig
__P((int signo
));
217 * Compatibility with old systems.
220 #include <sys/file.h>
221 #define strchr(a,b) index(a,b)
222 #define strrchr(a,b) rindex(a,b)
223 extern char *strdup(), *ctime();
224 extern int read(), write();
229 #define DUMP_CURRENT_REV 1
231 int dump_fs_open(const char *disk
, ext2_filsys
*fs
);
236 #define _PATH_UTMP "/etc/utmp"
239 #define _PATH_FSTAB "/etc/fstab"
244 extern char *calloc();
245 extern char *malloc();
247 extern char *strcpy();
248 extern char *strncpy();
249 extern char *strcat();
250 extern time_t time();
251 extern void endgrent();
253 extern off_t
lseek();
254 extern const char *strerror();
258 #define IEXCLUDE_MAXNUM 256 /* max size of inode exclude list */