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
;
81 extern int ntrec
; /* blocking factor on tape */
83 extern const char *host
;
84 extern long blocksperfile
; /* number of blocks per output file */
85 extern int notify
; /* notify operator flag */
86 extern int blockswritten
; /* number of blocks written on current tape */
87 extern long dev_bsize
; /* block size of underlying disk device */
89 time_t tstart_writing
; /* when started writing the first tape block */
90 time_t tend_writing
; /* after writing the last tape block */
91 int passno
; /* current dump pass number */
92 struct fs
*sblock
; /* the file system super block */
93 char sblock_buf
[MAXBSIZE
];
94 int dev_bshift
; /* log2(dev_bsize) */
95 int tp_bshift
; /* log2(TP_BSIZE) */
97 /* operator interface functions */
98 void broadcast(const char *);
100 void lastdump(int); /* int should be char */
101 void msg(const char *, ...) __printflike(1, 2);
102 void msgtail(const char *, ...) __printflike(1, 2);
103 int query(const char *);
104 void quit(const char *, ...) __printflike(1, 2);
106 time_t unctime(const char *);
108 /* mapping rouintes */
110 long blockest(struct ufs1_dinode
*);
111 int mapfiles(ufs1_ino_t maxino
, long *);
112 int mapdirs(ufs1_ino_t maxino
, long *);
114 /* file dumping routines */
115 void blksout(daddr_t
*, int, ufs1_ino_t
);
116 void bread(daddr_t
, char *, int);
117 ssize_t
cread(int, void *, size_t, off_t
);
118 void dumpino(struct ufs1_dinode
*, ufs1_ino_t
);
119 void dumpmap(const char *, int, ufs1_ino_t
);
120 void writeheader(ufs1_ino_t
);
122 /* tape writing routines */
124 void close_rewind(void);
125 void dumpblock(daddr_t
, int);
126 void startnewtape(int);
128 void writerec(const void *, int);
130 void Exit(int) __dead2
;
132 void dump_getfstab(void);
134 char *rawname(char *);
135 struct ufs1_dinode
*getino(ufs1_ino_t
);
138 #if defined(RDUMP) || defined(RRESTORE)
140 int rmthost(const char *);
141 int rmtopen(const char *, int);
142 int rmtwrite(const void *, int);
143 #endif /* RDUMP || RRESTORE */
145 /* rrestore routines */
147 int rmtread(char *, int);
148 int rmtseek(int, int);
149 int rmtioctl(int, int);
150 #endif /* RRESTORE */
152 void interrupt(int); /* in case operator bangs on console */
157 #define X_FINOK 0 /* normal exit */
158 #define X_STARTUP 1 /* startup error */
159 #define X_REWRITE 2 /* restart writing from the check point */
160 #define X_ABORT 3 /* abort dump; don't attempt checkpointing */
162 #define OPGRENT "operator" /* group entry to notify */
164 struct fstab
*fstabsearch(const char *); /* search fs_file and fs_spec */
171 * The contents of the file _PATH_DUMPDATES is maintained both on
172 * a linked list, and then (eventually) arrayified.
175 char dd_name
[NAME_MAX
+3];
179 extern int nddates
; /* number of records (might be zero) */
180 extern struct dumpdates
**ddatev
; /* the arrayfied version */
181 void initdumptimes(void);
182 void getdumptime(void);
183 void putdumptime(void);
184 #define ITITERATE(i, ddp) \
185 if (ddatev != NULL) \
186 for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i])
191 #define _PATH_UTMP "/etc/utmp"
194 #define _PATH_FSTAB "/etc/fstab"