Initial import from FreeBSD RELENG_4:
[games.git] / sbin / dump / dump.h
1 /*-
2  * Copyright (c) 1980, 1993
3  *      The Regents of the University of California.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
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. All advertising materials mentioning features or use of this software
14  *    must display the following acknowledgement:
15  *      This product includes software developed by the University of
16  *      California, Berkeley and its contributors.
17  * 4. Neither the name of the University nor the names of its contributors
18  *    may be used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  *
33  *      @(#)dump.h      8.2 (Berkeley) 4/28/95
34  *
35  * $FreeBSD: src/sbin/dump/dump.h,v 1.7.6.4 2003/01/25 18:54:59 dillon Exp $
36  */
37
38 #define MAXINOPB        (MAXBSIZE / sizeof(struct dinode))
39 #define MAXNINDIR       (MAXBSIZE / sizeof(daddr_t))
40
41 /*
42  * Dump maps used to describe what is to be dumped.
43  */
44 int     mapsize;        /* size of the state maps */
45 char    *usedinomap;    /* map of allocated inodes */
46 char    *dumpdirmap;    /* map of directories to be dumped */
47 char    *dumpinomap;    /* map of files to be dumped */
48 /*
49  * Map manipulation macros.
50  */
51 #define SETINO(ino, map) \
52         map[(u_int)((ino) - 1) / NBBY] |=  1 << ((u_int)((ino) - 1) % NBBY)
53 #define CLRINO(ino, map) \
54         map[(u_int)((ino) - 1) / NBBY] &=  ~(1 << ((u_int)((ino) - 1) % NBBY))
55 #define TSTINO(ino, map) \
56         (map[(u_int)((ino) - 1) / NBBY] &  (1 << ((u_int)((ino) - 1) % NBBY)))
57
58 /*
59  *      All calculations done in 0.1" units!
60  */
61 char    *disk;          /* name of the disk file */
62 char    *tape;          /* name of the tape file */
63 char    *dumpdates;     /* name of the file containing dump date information*/
64 char    *temp;          /* name of the file for doing rewrite of dumpdates */
65 char    lastlevel;      /* dump level of previous dump */
66 char    level;          /* dump level of this dump */
67 int     uflag;          /* update flag */
68 int     diskfd;         /* disk file descriptor */
69 int     tapefd;         /* tape file descriptor */
70 int     pipeout;        /* true => output to standard output */
71 ino_t   curino;         /* current inumber; used globally */
72 int     newtape;        /* new tape flag */
73 int     density;        /* density in 0.1" units */
74 long    tapesize;       /* estimated tape size, blocks */
75 long    tsize;          /* tape size in 0.1" units */
76 long    asize;          /* number of 0.1" units written on current tape */
77 int     etapes;         /* estimated number of tapes */
78 int     nonodump;       /* if set, do not honor UF_NODUMP user flags */
79 int     unlimited;      /* if set, write to end of medium */
80 int     cachesize;      /* size of block cache */
81
82 int     notify;         /* notify operator flag */
83 int     blockswritten;  /* number of blocks written on current tape */
84 int     tapeno;         /* current tape number */
85 time_t  tstart_writing; /* when started writing the first tape block */
86 time_t  tend_writing;   /* after writing the last tape block */
87 int     passno;         /* current dump pass number */
88 struct  fs *sblock;     /* the file system super block */
89 char    sblock_buf[MAXBSIZE];
90 long    dev_bsize;      /* block size of underlying disk device */
91 int     dev_bshift;     /* log2(dev_bsize) */
92 int     tp_bshift;      /* log2(TP_BSIZE) */
93
94 #ifndef __P
95 #include <sys/cdefs.h>
96 #endif
97
98 /* operator interface functions */
99 void    broadcast __P((char *message));
100 void    infosch __P((int));
101 void    lastdump __P((int arg));        /* int should be char */
102 void    msg __P((const char *fmt, ...)) __printflike(1, 2);
103 void    msgtail __P((const char *fmt, ...)) __printflike(1, 2);
104 int     query __P((char *question));
105 void    quit __P((const char *fmt, ...)) __printflike(1, 2);
106 void    timeest __P((void));
107 time_t  unctime __P((char *str));
108
109 /* mapping rouintes */
110 struct  dinode;
111 long    blockest __P((struct dinode *dp));
112 int     mapfiles __P((ino_t maxino, long *tapesize));
113 int     mapdirs __P((ino_t maxino, long *tapesize));
114
115 /* file dumping routines */
116 void    blksout __P((daddr_t *blkp, int frags, ino_t ino));
117 void    bread __P((daddr_t blkno, char *buf, int size));
118 void    dumpino __P((struct dinode *dp, ino_t ino));
119 void    dumpmap __P((char *map, int type, ino_t ino));
120 void    writeheader __P((ino_t ino));
121
122 /* tape writing routines */
123 int     alloctape __P((void));
124 void    close_rewind __P((void));
125 void    dumpblock __P((daddr_t blkno, int size));
126 void    startnewtape __P((int top));
127 void    trewind __P((void));
128 void    writerec __P((char *dp, int isspcl));
129
130 void    Exit __P((int status)) __dead2;
131 void    dumpabort __P((int signo));
132 void    getfstab __P((void));
133
134 char    *rawname __P((char *cp));
135 struct  dinode *getino __P((ino_t inum));
136
137 /* rdump routines */
138 #ifdef RDUMP
139 void    rmtclose __P((void));
140 int     rmthost __P((char *host));
141 int     rmtopen __P((char *tape, int mode));
142 int     rmtwrite __P((char *buf, int count));
143 #endif /* RDUMP */
144
145 void    interrupt __P((int signo));     /* in case operator bangs on console */
146
147 /*
148  *      Exit status codes
149  */
150 #define X_FINOK         0       /* normal exit */
151 #define X_STARTUP       1       /* startup error */
152 #define X_REWRITE       2       /* restart writing from the check point */
153 #define X_ABORT         3       /* abort dump; don't attempt checkpointing */
154
155 #define OPGRENT "operator"              /* group entry to notify */
156
157 struct  fstab *fstabsearch __P((char *key));    /* search fs_file and fs_spec */
158
159 #ifndef NAME_MAX
160 #define NAME_MAX 255
161 #endif
162
163 /*
164  *      The contents of the file _PATH_DUMPDATES is maintained both on
165  *      a linked list, and then (eventually) arrayified.
166  */
167 struct dumpdates {
168         char    dd_name[NAME_MAX+3];
169         char    dd_level;
170         time_t  dd_ddate;
171 };
172 int     nddates;                /* number of records (might be zero) */
173 int     ddates_in;              /* we have read the increment file */
174 struct  dumpdates **ddatev;     /* the arrayfied version */
175 void    initdumptimes __P((void));
176 void    getdumptime __P((void));
177 void    putdumptime __P((void));
178 #define ITITERATE(i, ddp) \
179         for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i])
180
181 void    sig __P((int signo));
182
183 /*
184  * Compatibility with old systems.
185  */
186 #ifdef COMPAT
187 #include <sys/file.h>
188 #define strchr(a,b)     index(a,b)
189 #define strrchr(a,b)    rindex(a,b)
190 extern char *strdup(), *ctime();
191 extern int read(), write();
192 extern int errno;
193 #endif
194
195 #ifndef _PATH_UTMP
196 #define _PATH_UTMP      "/etc/utmp"
197 #endif
198 #ifndef _PATH_FSTAB
199 #define _PATH_FSTAB     "/etc/fstab"
200 #endif
201
202 #ifdef sunos
203 extern char *calloc();
204 extern char *malloc();
205 extern long atol();
206 extern char *strcpy();
207 extern char *strncpy();
208 extern char *strcat();
209 extern time_t time();
210 extern void endgrent();
211 extern void exit();
212 extern off_t lseek();
213 extern const char *strerror();
214 #endif