]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - sbin/dump/dump.h
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.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  * 4. 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.
16  *
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
27  * SUCH DAMAGE.
28  *
29  *      @(#)dump.h      8.2 (Berkeley) 4/28/95
30  *
31  * $FreeBSD$
32  */
33
34 /*
35  * Dump maps used to describe what is to be dumped.
36  */
37 int     mapsize;        /* size of the state maps */
38 char    *usedinomap;    /* map of allocated inodes */
39 char    *dumpdirmap;    /* map of directories to be dumped */
40 char    *dumpinomap;    /* map of files to be dumped */
41 /*
42  * Map manipulation macros.
43  */
44 #define SETINO(ino, map) \
45         map[(u_int)((ino) - 1) / CHAR_BIT] |= \
46             1 << ((u_int)((ino) - 1) % CHAR_BIT)
47 #define CLRINO(ino, map) \
48         map[(u_int)((ino) - 1) / CHAR_BIT] &= \
49             ~(1 << ((u_int)((ino) - 1) % CHAR_BIT))
50 #define TSTINO(ino, map) \
51         (map[(u_int)((ino) - 1) / CHAR_BIT] & \
52             (1 << ((u_int)((ino) - 1) % CHAR_BIT)))
53
54 /*
55  *      All calculations done in 0.1" units!
56  */
57 char    *disk;          /* name of the disk file */
58 char    *tape;          /* name of the tape file */
59 char    *popenout;      /* popen(3) per-"tape" command */
60 char    *dumpdates;     /* name of the file containing dump date information*/
61 char    *temp;          /* name of the file for doing rewrite of dumpdates */
62 int     lastlevel;      /* dump level of previous dump */
63 int     level;          /* dump level of this dump */
64 int     uflag;          /* update flag */
65 int     diskfd;         /* disk file descriptor */
66 int     tapefd;         /* tape file descriptor */
67 int     pipeout;        /* true => output to standard output */
68 ino_t   curino;         /* current inumber; used globally */
69 int     newtape;        /* new tape flag */
70 int     density;        /* density in 0.1" units */
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 */
77 int     cachesize;      /* size of block cache in bytes */
78 int     rsync_friendly; /* be friendly with rsync */
79
80 int     notify;         /* notify operator flag */
81 int     blockswritten;  /* number of blocks written on current tape */
82 int     tapeno;         /* current tape number */
83 time_t  tstart_writing; /* when started writing the first tape block */
84 time_t  tend_writing;   /* after writing the last tape block */
85 int     passno;         /* current dump pass number */
86 struct  fs *sblock;     /* the file system super block */
87 char    sblock_buf[MAXBSIZE];
88 long    dev_bsize;      /* block size of underlying disk device */
89 int     dev_bshift;     /* log2(dev_bsize) */
90 int     tp_bshift;      /* log2(TP_BSIZE) */
91
92 /* operator interface functions */
93 void    broadcast(const char *message);
94 void    infosch(int);
95 void    lastdump(int arg);      /* int should be char */
96 void    msg(const char *fmt, ...) __printflike(1, 2);
97 void    msgtail(const char *fmt, ...) __printflike(1, 2);
98 int     query(const char *question);
99 void    quit(const char *fmt, ...) __printflike(1, 2);
100 void    timeest(void);
101 time_t  unctime(char *str);
102
103 /* mapping rouintes */
104 union   dinode;
105 int     mapfiles(ino_t maxino, long *tapesize);
106 int     mapdirs(ino_t maxino, long *tapesize);
107
108 /* file dumping routines */
109 void    bread(ufs2_daddr_t blkno, char *buf, int size);
110 ssize_t cread(int fd, void *buf, size_t nbytes, off_t offset);
111 void    dumpino(union dinode *dp, ino_t ino);
112 void    dumpmap(char *map, int type, ino_t ino);
113 void    writeheader(ino_t ino);
114
115 /* tape writing routines */
116 int     alloctape(void);
117 void    close_rewind(void);
118 void    dumpblock(ufs2_daddr_t blkno, int size);
119 void    startnewtape(int top);
120 void    trewind(void);
121 void    writerec(char *dp, int isspcl);
122
123 void    Exit(int status) __dead2;
124 void    dumpabort(int signo);
125 void    dump_getfstab(void);
126
127 char    *rawname(char *cp);
128 union   dinode *getino(ino_t inum, int *mode);
129
130 /* rdump routines */
131 #ifdef RDUMP
132 void    rmtclose(void);
133 int     rmthost(const char *host);
134 int     rmtopen(const char *tape, int mode);
135 int     rmtwrite(const char *buf, int count);
136 #endif /* RDUMP */
137
138 void    interrupt(int signo);   /* in case operator bangs on console */
139
140 /*
141  *      Exit status codes
142  */
143 #define X_FINOK         0       /* normal exit */
144 #define X_STARTUP       1       /* startup error */
145 #define X_REWRITE       2       /* restart writing from the check point */
146 #define X_ABORT         3       /* abort dump; don't attempt checkpointing */
147
148 #define OPGRENT "operator"              /* group entry to notify */
149
150 struct  fstab *fstabsearch(const char *key); /* search fs_file and fs_spec */
151
152 #ifndef NAME_MAX
153 #define NAME_MAX 255
154 #endif
155
156 /*
157  *      The contents of the file _PATH_DUMPDATES is maintained both on
158  *      a linked list, and then (eventually) arrayified.
159  */
160 struct dumpdates {
161         char    dd_name[NAME_MAX+3];
162         int     dd_level;
163         time_t  dd_ddate;
164 };
165 int     nddates;                /* number of records (might be zero) */
166 struct  dumpdates **ddatev;     /* the arrayfied version */
167 void    initdumptimes(void);
168 void    getdumptime(void);
169 void    putdumptime(void);
170 #define ITITERATE(i, ddp) \
171         if (ddatev != NULL) \
172                 for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i])
173
174 #define DUMPFMTLEN      53                      /* max device pathname length */
175 #define DUMPOUTFMT      "%-*s %d %s"            /* for printf */
176                                                 /* name, level, ctime(date) */
177 #define DUMPINFMT       "%s %d %[^\n]\n"        /* inverse for scanf */
178
179 void    sig(int signo);
180
181 #ifndef _PATH_FSTAB
182 #define _PATH_FSTAB     "/etc/fstab"
183 #endif