2 * Copyright (c) 1980, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * @(#)dump.h 8.2 (Berkeley) 4/28/95
31 * $FreeBSD: src/sbin/dump/dump.h,v 1.7.6.4 2003/01/25 18:54:59 dillon Exp $
34 #include <sys/param.h>
36 #define MAXINOPB (MAXBSIZE / sizeof(struct ufs1_dinode))
37 #define MAXNINDIR (MAXBSIZE / sizeof(daddr_t))
40 * Dump maps used to describe what is to be dumped.
42 int mapsize
; /* size of the state maps */
43 char *usedinomap
; /* map of allocated inodes */
44 char *dumpdirmap
; /* map of directories to be dumped */
45 char *dumpinomap
; /* map of files to be dumped */
47 * Map manipulation macros.
49 #define SETINO(ino, map) \
50 map[(u_int)((ino) - 1) / NBBY] |= 1 << ((u_int)((ino) - 1) % NBBY)
51 #define CLRINO(ino, map) \
52 map[(u_int)((ino) - 1) / NBBY] &= ~(1 << ((u_int)((ino) - 1) % NBBY))
53 #define TSTINO(ino, map) \
54 (map[(u_int)((ino) - 1) / NBBY] & (1 << ((u_int)((ino) - 1) % NBBY)))
57 * All calculations done in 0.1" units!
59 char *disk
; /* name of the disk file */
60 const char *tape
; /* name of the tape file */
61 extern const char *dumpdates
; /* name of the file containing dump date information*/
62 extern const char *temp
; /* name of the file for doing rewrite of dumpdates */
63 char lastlevel
; /* dump level of previous dump */
64 char level
; /* dump level of this dump */
65 int uflag
; /* update flag */
66 int diskfd
; /* disk file descriptor */
67 int tapefd
; /* tape file descriptor */
68 int pipeout
; /* true => output to standard output */
69 ufs1_ino_t curino
; /* current inumber; used globally */
70 int newtape
; /* new tape flag */
71 long tapesize
; /* estimated tape size, blocks */
72 long tsize
; /* tape size in 0.1" units */
73 long asize
; /* number of 0.1" units written on current tape */
74 int etapes
; /* estimated number of tapes */
75 int nonodump
; /* if set, do not honor UF_NODUMP user flags */
76 int unlimited
; /* if set, write to end of medium */
78 extern int cachesize
; /* size of block cache */
79 extern int density
; /* density in 0.1" units */
80 extern int dokerberos
;
82 extern long ntrec
; /* used by sbin/restore */
84 extern int ntrec
; /* blocking factor on tape */
87 extern const char *host
;
88 extern long blocksperfile
; /* number of blocks per output file */
89 extern int notify
; /* notify operator flag */
90 extern int blockswritten
; /* number of blocks written on current tape */
91 extern long dev_bsize
; /* block size of underlying disk device */
93 time_t tstart_writing
; /* when started writing the first tape block */
94 time_t tend_writing
; /* after writing the last tape block */
95 int passno
; /* current dump pass number */
96 struct fs
*sblock
; /* the file system super block */
97 char sblock_buf
[MAXBSIZE
];
98 int dev_bshift
; /* log2(dev_bsize) */
99 int tp_bshift
; /* log2(TP_BSIZE) */
101 /* operator interface functions */
102 void broadcast(const char *);
104 void lastdump(int); /* int should be char */
105 void msg(const char *, ...) __printflike(1, 2);
106 void msgtail(const char *, ...) __printflike(1, 2);
107 int query(const char *);
108 void quit(const char *, ...) __dead2
__printflike(1, 2);
110 time_t unctime(const char *);
112 /* mapping rouintes */
114 long blockest(struct ufs1_dinode
*);
115 int mapfiles(ufs1_ino_t maxino
, long *);
116 int mapdirs(ufs1_ino_t maxino
, long *);
118 /* file dumping routines */
119 void blksout(daddr_t
*, int, ufs1_ino_t
);
120 void bread(daddr_t
, char *, int);
121 ssize_t
cread(int, void *, size_t, off_t
);
122 void dumpino(struct ufs1_dinode
*, ufs1_ino_t
);
123 void dumpmap(const char *, int, ufs1_ino_t
);
124 void writeheader(ufs1_ino_t
);
126 /* tape writing routines */
128 void close_rewind(void);
129 void dumpblock(daddr_t
, int);
130 void startnewtape(int);
132 void writerec(const void *, int);
134 void Exit(int) __dead2
;
135 void dumpabort(int) __dead2
;
136 void dump_getfstab(void);
138 char *rawname(char *);
139 struct ufs1_dinode
*getino(ufs1_ino_t
);
142 #if defined(RDUMP) || defined(RRESTORE)
144 int rmthost(const char *);
145 int rmtopen(const char *, int);
146 int rmtwrite(const void *, int);
147 #endif /* RDUMP || RRESTORE */
149 /* rrestore routines */
151 int rmtread(char *, int);
152 int rmtseek(int, int);
153 int rmtioctl(int, int);
154 #endif /* RRESTORE */
156 void interrupt(int); /* in case operator bangs on console */
161 #define X_FINOK 0 /* normal exit */
162 #define X_STARTUP 1 /* startup error */
163 #define X_REWRITE 2 /* restart writing from the check point */
164 #define X_ABORT 3 /* abort dump; don't attempt checkpointing */
166 #define OPGRENT "operator" /* group entry to notify */
168 struct fstab
*fstabsearch(const char *); /* search fs_file and fs_spec */
175 * The contents of the file _PATH_DUMPDATES is maintained both on
176 * a linked list, and then (eventually) arrayified.
179 char dd_name
[NAME_MAX
+3];
183 extern int nddates
; /* number of records (might be zero) */
184 extern struct dumpdates
**ddatev
; /* the arrayfied version */
185 void initdumptimes(void);
186 void getdumptime(void);
187 void putdumptime(void);
188 #define ITITERATE(i, ddp) \
189 if (ddatev != NULL) \
190 for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i])
195 #define _PATH_UTMP "/etc/utmp"
198 #define _PATH_FSTAB "/etc/fstab"