]>
git.wh0rd.org - dump.git/blob - dump/dump.h
8424c719c0e727ac42adc33ec9b926f6b9f43ff8
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
10 * Copyright (c) 1980, 1993
11 * The Regents of the University of California. All rights reserved.
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
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.
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
41 * @(#)dump.h 8.2 (Berkeley) 4/28/95
44 #define MAXINOPB (MAXBSIZE / sizeof(struct dinode))
45 #define MAXNINDIR (MAXBSIZE / sizeof(daddr_t))
48 * Dump maps used to describe what is to be dumped.
50 int mapsize
; /* size of the state maps */
51 char *usedinomap
; /* map of allocated inodes */
52 char *dumpdirmap
; /* map of directories to be dumped */
53 char *dumpinomap
; /* map of files to be dumped */
55 * Map manipulation macros.
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)))
65 * All calculations done in 0.1" units!
67 char *disk
; /* name of the disk file */
68 char *tape
; /* name of the tape file */
69 char *dumpdates
; /* name of the file containing dump date information*/
70 char *temp
; /* name of the file for doing rewrite of dumpdates */
71 char lastlevel
; /* dump level of previous dump */
72 char level
; /* dump level of this dump */
73 int uflag
; /* update flag */
74 int diskfd
; /* disk file descriptor */
75 int tapefd
; /* tape file descriptor */
76 int pipeout
; /* true => output to standard output */
77 ino_t curino
; /* current inumber; used globally */
78 int newtape
; /* new tape flag */
79 int density
; /* density in 0.1" units */
80 long tapesize
; /* estimated tape size, blocks */
81 long tsize
; /* tape size in 0.1" units */
82 long asize
; /* number of 0.1" units written on current tape */
83 int etapes
; /* estimated number of tapes */
84 int nonodump
; /* if set, do not honor UF_NODUMP user flags */
85 int unlimited
; /* if set, write to end of medium */
87 int notify
; /* notify operator flag */
88 int blockswritten
; /* number of blocks written on current tape */
89 int tapeno
; /* current tape number */
90 time_t tstart_writing
; /* when started writing the first tape block */
91 time_t tend_writing
; /* after writing the last tape block */
95 struct fs
*sblock
; /* the file system super block */
96 char sblock_buf
[MAXBSIZE
];
98 long xferrate
; /* averaged transfer rate of all volumes */
99 long dev_bsize
; /* block size of underlying disk device */
100 int dev_bshift
; /* log2(dev_bsize) */
101 int tp_bshift
; /* log2(TP_BSIZE) */
104 #include <sys/cdefs.h>
107 /* operator interface functions */
108 void broadcast
__P((const char *message
));
109 time_t do_stats
__P((void));
110 void lastdump
__P((char arg
));
111 void msg
__P((const char *fmt
, ...));
112 void msgtail
__P((const char *fmt
, ...));
113 int query
__P((const char *question
));
114 void quit
__P((const char *fmt
, ...));
115 void set_operators
__P((void));
117 void statussig
__P((int signo
));
119 void timeest
__P((void));
120 time_t unctime
__P((const char *str
));
122 /* mapping rouintes */
124 long blockest
__P((struct dinode
*dp
));
125 int mapfiles
__P((ino_t maxino
, long *tapesize
));
127 int mapfilesfromdir
__P((ino_t maxino
, long *tapesize
, char *directory
));
129 int mapdirs
__P((ino_t maxino
, long *tapesize
));
131 /* file dumping routines */
132 void blksout
__P((daddr_t
*blkp
, int frags
, ino_t ino
));
133 void bread
__P((daddr_t blkno
, char *buf
, int size
));
134 void dumpino
__P((struct dinode
*dp
, ino_t ino
));
136 void dumpdirino
__P((struct dinode
*dp
, ino_t ino
));
138 void dumpmap
__P((char *map
, int type
, ino_t ino
));
139 void writeheader
__P((ino_t ino
));
141 /* tape writing routines */
142 int alloctape
__P((void));
143 void close_rewind
__P((void));
144 void dumpblock
__P((daddr_t blkno
, int size
));
145 void startnewtape
__P((int top
));
146 void trewind
__P((void));
147 void writerec
__P((const void *dp
, int isspcl
));
149 void Exit
__P((int status
));
150 void dumpabort
__P((int signo
));
151 void getfstab
__P((void));
153 char *rawname
__P((char *cp
));
154 struct dinode
*getino
__P((ino_t inum
));
158 int rmthost
__P((const char *host
));
159 int rmtopen
__P((const char *tape
, int mode
));
160 void rmtclose
__P((void));
161 int rmtread
__P((char *buf
, size_t count
));
162 int rmtwrite
__P((const char *buf
, size_t count
));
163 int rmtseek
__P((int offset
, int pos
));
164 struct mtget
* rmtstatus
__P((void));
165 int rmtioctl
__P((int cmd
, int count
));
168 void interrupt
__P((int signo
)); /* in case operator bangs on console */
173 #define X_FINOK 0 /* normal exit */
174 #define X_STARTUP 1 /* startup error */
175 #define X_REWRITE 2 /* restart writing from the check point */
176 #define X_ABORT 3 /* abort dump; don't attempt checkpointing */
178 #define OPGRENT "operator" /* group entry to notify */
180 #define DIALUP "ttyS" /* prefix for dialups */
182 #define DIALUP "ttyd" /* prefix for dialups */
185 struct fstab
*fstabsearch
__P((const char *key
)); /* search fs_file and fs_spec */
187 struct fstab
*fstabsearchdir
__P((const char *key
, char *dir
)); /* search fs_file and fs_spec */
195 * The contents of the file _PATH_DUMPDATES is maintained both on
196 * a linked list, and then (eventually) arrayified.
199 char dd_name
[NAME_MAX
+3];
204 struct dumpdates dt_value
;
205 struct dumptime
*dt_next
;
207 struct dumptime
*dthead
; /* head of the list version */
208 int nddates
; /* number of records (might be zero) */
209 int ddates_in
; /* we have read the increment file */
210 struct dumpdates
**ddatev
; /* the arrayfied version */
211 void initdumptimes
__P((void));
212 void getdumptime
__P((void));
213 void putdumptime
__P((void));
214 #define ITITERATE(i, ddp) \
215 for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i])
217 void sig
__P((int signo
));
220 * Compatibility with old systems.
223 #include <sys/file.h>
224 #define strchr(a,b) index(a,b)
225 #define strrchr(a,b) rindex(a,b)
226 extern char *strdup(), *ctime();
227 extern int read(), write();
232 #define DUMP_CURRENT_REV 0
237 #define _PATH_UTMP "/etc/utmp"
240 #define _PATH_FSTAB "/etc/fstab"
245 extern char *calloc();
246 extern char *malloc();
248 extern char *strcpy();
249 extern char *strncpy();
250 extern char *strcat();
251 extern time_t time();
252 extern void endgrent();
254 extern off_t
lseek();
255 extern const char *strerror();