]>
git.wh0rd.org - dump.git/blob - dump/dump.h
e525f3dfcc0fc648ecfe263a75bfd2634dc07461
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.51 2011/06/10 13:07:29 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. Neither the name of the University nor the names of its contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41 #include <protocols/dumprestore.h>
42 #include <compatlfs.h>
43 #include "transformation.h"
45 #define MAXINOPB (MAXBSIZE / sizeof(struct dinode))
46 #define MAXNINDIR (MAXBSIZE / sizeof(blk_t))
47 #define NUM_STR_SIZE 32 /* a generic number buffer size */
50 * Dump maps used to describe what is to be dumped.
52 extern int mapsize
; /* size of the state maps */
53 extern char *usedinomap
; /* map of allocated inodes */
54 extern char *dumpdirmap
; /* map of directories to be dumped */
55 extern char *dumpinomap
; /* map of files to be dumped */
56 extern char *metainomap
; /* which of the inodes in dumpinomap
57 will get only their metadata dumped */
59 * Map manipulation macros.
61 #define SETINO(ino, map) \
62 map[(u_int)((ino) - 1) / NBBY] |= 1 << ((u_int)((ino) - 1) % NBBY)
63 #define CLRINO(ino, map) \
64 map[(u_int)((ino) - 1) / NBBY] &= ~(1 << ((u_int)((ino) - 1) % NBBY))
65 #define TSTINO(ino, map) \
66 (map[(u_int)((ino) - 1) / NBBY] & (1 << ((u_int)((ino) - 1) % NBBY)))
69 * All calculations done in 0.1" units!
71 extern char *host
; /* name of the remote host */
72 extern const char *disk
; /* name of the disk file */
73 extern char tape
[MAXPATHLEN
];/* name of the tape file */
74 extern char *tapeprefix
; /* prefix of the tape file */
75 extern char *dumpdates
; /* name of the file containing dump date information*/
76 extern char lastlevel
[NUM_STR_SIZE
];/* dump level of previous dump */
77 extern char level
[NUM_STR_SIZE
];/* dump level of this dump */
78 extern int Afile
; /* archive file descriptor */
79 extern int AfileActive
; /* Afile flag */
80 extern int zipflag
; /* which compression method */
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 vflag
; /* verbose flag */
86 extern int breademax
; /* maximum number of bread errors before we quit */
87 extern char *eot_script
; /* end of volume script fiag */
88 extern int diskfd
; /* disk file descriptor */
89 extern int tapefd
; /* tape file descriptor */
90 extern int pipeout
; /* true => output to standard output */
91 extern int fifoout
; /* true => output to fifo */
92 extern dump_ino_t curino
; /* current inumber; used globally */
93 extern int newtape
; /* new tape flag */
94 extern int density
; /* density in 0.1" units */
95 extern long long tapesize
; /* estimated tape size, blocks */
96 extern long tsize
; /* tape size in 0.1" units */
97 extern long asize
; /* number of 0.1" units written on current tape */
98 extern int etapes
; /* estimated number of tapes */
99 extern int nonodump
; /* if set, do not honor UF_NODUMP user flags */
100 extern int unlimited
; /* if set, write to end of medium */
101 extern int compressed
; /* if set, dump is to be compressed */
102 extern long long bytes_written
;/* total bytes written to tape */
103 extern long uncomprblks
; /* uncompressed blocks written to tape */
104 extern int notify
; /* notify operator flag */
105 extern int blockswritten
; /* number of blocks written on current tape */
106 extern int tapeno
; /* current tape number */
107 extern time_t tstart_writing
; /* when started writing the first tape block */
108 extern time_t tend_writing
; /* after writing the last tape block */
110 extern ext2_filsys fs
;
112 extern struct fs
*sblock
; /* the file system super block */
113 extern char sblock_buf
[MAXBSIZE
];
115 extern long xferrate
; /* averaged transfer rate of all volumes */
116 extern long dev_bsize
; /* block size of underlying disk device */
117 extern int dev_bshift
; /* log2(dev_bsize) */
118 extern int tp_bshift
; /* log2(TP_BSIZE) */
119 extern dump_ino_t volinfo
[]; /* which inode on which volume archive info */
120 extern Transformation
*transformation
;
123 #define QFA_MAGIC "495115637697"
124 #define QFA_VERSION "1.0"
125 extern int gTapeposfd
;
126 extern char *gTapeposfile
;
127 extern char gTps
[255];
128 extern int32_t gThisDumpDate
;
132 #include <sys/cdefs.h>
135 /* operator interface functions */
136 void broadcast
__P((const char *message
));
137 time_t do_stats
__P((void));
138 void lastdump
__P((char arg
));
139 void msg
__P((const char *fmt
, ...));
140 void msgtail
__P((const char *fmt
, ...));
141 int query
__P((const char *question
));
142 void quit
__P((const char *fmt
, ...));
143 void set_operators
__P((void));
145 void statussig
__P((int signo
));
147 void timeest
__P((void));
148 time_t unctime
__P((const char *str
));
150 /* mapping rouintes */
152 long blockest
__P((struct dinode
const *dp
));
153 int mapfiles
__P((dump_ino_t maxino
, long long *tapesize
));
155 int mapfilesfromdir
__P((dump_ino_t maxino
, long long *tapesize
, char *directory
));
156 int maponefile
__P((dump_ino_t maxino
, long long *tapesize
, char *directory
));
158 int mapdirs
__P((dump_ino_t maxino
, long long *tapesize
));
160 /* file dumping routines */
161 void blksout
__P((blk_t
*blkp
, int frags
, dump_ino_t ino
));
162 void bread
__P((ext2_loff_t blkno
, char *buf
, int size
));
163 void dumpino
__P((struct dinode
*dp
, dump_ino_t ino
, int metaonly
));
165 void dumpdirino
__P((struct dinode
*dp
, dump_ino_t ino
));
167 void dumpmap
__P((char *map
, int type
, dump_ino_t ino
));
168 void writeheader
__P((dump_ino_t ino
));
169 void mkchecksum
__P((union u_spcl
*tmpspcl
));
171 /* tape writing routines */
172 int alloctape
__P((void));
173 void close_rewind
__P((void));
174 void dumpblock
__P((blk_t blkno
, int size
));
175 void startnewtape
__P((int top
));
176 time_t trewind
__P((void));
177 void writerec
__P((const void *dp
, int isspcl
));
178 char *mktimeest
__P((time_t tnow
));
180 void Exit
__P((int status
));
181 void dumpabort
__P((int signo
));
182 void getfstab
__P((void));
184 const char *rawname
__P((const char *cp
));
185 struct dinode
*getino
__P((dump_ino_t inum
));
189 int rmthost
__P((const char *host
));
190 int rmtopen
__P((const char *tape
, const int mode
));
191 void rmtclose
__P((void));
192 int rmtread
__P((char *buf
, size_t count
));
193 int rmtwrite
__P((const char *buf
, size_t count
));
194 OFF_T rmtseek
__P((OFF_T offset
, int pos
));
195 struct mtget
* rmtstatus
__P((void));
196 int rmtioctl
__P((int cmd
, int count
));
199 void interrupt
__P((int signo
)); /* in case operator bangs on console */
200 int exclude_ino
__P((dump_ino_t ino
));
201 void do_exclude_ino
__P((dump_ino_t ino
, const char *));
206 #define X_FINOK 0 /* normal exit */
207 #define X_STARTUP 1 /* startup error */
208 #define X_REWRITE 2 /* restart writing from the check point */
209 #define X_ABORT 3 /* abort dump; don't attempt checkpointing */
211 #define OPGRENT "operator" /* group entry to notify */
213 #define DIALUP "ttyS" /* prefix for dialups */
215 #define DIALUP "ttyd" /* prefix for dialups */
220 struct mntent
*fstabsearch
__P((const char *key
)); /* search fs_file and fs_spec */
222 struct mntent
*fstabsearchdir
__P((const char *key
, char *dir
)); /* search fs_file and fs_spec */
226 * The contents of the file _PATH_DUMPDATES is maintained both on
227 * a linked list, and then (eventually) arrayified.
230 char dd_name
[MAXPATHLEN
+3];
231 struct mntent
*dd_fstab
;
236 struct dumpdates dt_value
;
237 struct dumptime
*dt_next
;
239 extern struct dumptime
*dthead
; /* head of the list version */
240 extern int nddates
; /* number of records (might be zero) */
241 extern int ddates_in
; /* we have read the increment file */
242 extern struct dumpdates
**ddatev
; /* the arrayfied version */
243 void initdumptimes
__P((int));
244 void getdumptime
__P((int));
245 void putdumptime
__P((void));
246 #define ITITERATE(i, ddp) \
247 for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i])
249 void sig
__P((int signo
));
252 * Compatibility with old systems.
255 #include <sys/file.h>
256 #define strchr(a,b) index(a,b)
257 #define strrchr(a,b) rindex(a,b)
258 extern char *strdup(), *ctime();
259 extern int read(), write();
264 #define DUMP_CURRENT_REV 1
266 int dump_fs_open(const char *disk
, ext2_filsys
*fs
);
271 #define _PATH_UTMP "/etc/utmp"
274 #define _PATH_FSTAB "/etc/fstab"
279 extern char *calloc();
280 extern char *malloc();
282 extern char *strcpy();
283 extern char *strncpy();
284 extern char *strcat();
285 extern time_t time();
286 extern void endgrent();
288 extern off_t
lseek();
289 extern const char *strerror();