home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / sbin / dump / dump.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-16  |  6.6 KB  |  194 lines

  1. /*-
  2.  * Copyright (c) 1980 The Regents of the University of California.
  3.  * 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    5.21 (Berkeley) 7/16/92
  34.  */
  35.  
  36. #define MAXINOPB    (MAXBSIZE / sizeof(struct dinode))
  37. #define MAXNINDIR    (MAXBSIZE / sizeof(daddr_t))
  38.  
  39. /*
  40.  * Dump maps used to describe what is to be dumped.
  41.  */
  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 */
  46. /*
  47.  * Map manipulation macros.
  48.  */
  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)))
  55.  
  56. /*
  57.  *    All calculations done in 0.1" units!
  58.  */
  59. char    *disk;        /* name of the disk file */
  60. char    *tape;        /* name of the tape file */
  61. char    *dumpdates;    /* name of the file containing dump date information*/
  62. 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. ino_t    curino;        /* current inumber; used globally */
  70. int    newtape;    /* new tape flag */
  71. int    density;    /* density in 0.1" units */
  72. long    tapesize;    /* estimated tape size, blocks */
  73. long    tsize;        /* tape size in 0.1" units */
  74. long    asize;        /* number of 0.1" units written on current tape */
  75. int    etapes;        /* estimated number of tapes */
  76.  
  77. int    notify;        /* notify operator flag */
  78. int    blockswritten;    /* number of blocks written on current tape */
  79. int    tapeno;        /* current tape number */
  80. time_t    tstart_writing;    /* when started writing the first tape block */
  81. struct    fs *sblock;    /* the file system super block */
  82. char    sblock_buf[MAXBSIZE];
  83. long    dev_bsize;    /* block size of underlying disk device */
  84. int    dev_bshift;    /* log2(dev_bsize) */
  85. int    tp_bshift;    /* log2(TP_BSIZE) */
  86.  
  87. /* operator interface functions */
  88. void    broadcast __P((char *message));
  89. void    lastdump __P((int arg));    /* int should be char */
  90. void    msg __P((const char *fmt, ...));
  91. void    msgtail __P((const char *fmt, ...));
  92. int    query __P((char *question));
  93. void    quit __P((const char *fmt, ...));
  94. void    set_operators __P((void));
  95. void    timeest __P((void));
  96. time_t    unctime __P((char *str));
  97.  
  98. /* mapping rouintes */
  99. struct    dinode;
  100. long    blockest __P((struct dinode *dp));
  101. int    mapfiles __P((ino_t maxino, long *tapesize));
  102. int    mapdirs __P((ino_t maxino, long *tapesize));
  103.  
  104. /* file dumping routines */
  105. void    blksout __P((daddr_t *blkp, int frags, ino_t ino));
  106. void    bread __P((daddr_t blkno, char *buf, int size));    
  107. void    dumpino __P((struct dinode *dp, ino_t ino));
  108. void    dumpmap __P((char *map, int type, ino_t ino));
  109. void    writeheader __P((ino_t ino));
  110.  
  111. /* tape writing routines */
  112. int    alloctape __P((void));
  113. void    close_rewind __P((void));
  114. void    dumpblock __P((daddr_t blkno, int size));
  115. void    flushtape __P((void));
  116. void    startnewtape __P((int top));
  117. void    trewind __P((void));
  118. void    writerec __P((char *dp, int isspcl));
  119.  
  120. void    Exit __P((int status));
  121. void    dumpabort __P((int signo));
  122. void    getfstab __P((void));
  123.  
  124. char    *rawname __P((char *cp));
  125. struct    dinode *getino __P((ino_t inum));
  126.  
  127. void    interrupt __P((int signo));    /* in case operator bangs on console */
  128.  
  129. /*
  130.  *    Exit status codes
  131.  */
  132. #define    X_FINOK        0    /* normal exit */
  133. #define    X_REWRITE    2    /* restart writing from the check point */
  134. #define    X_ABORT        3    /* abort dump; don't attempt checkpointing */
  135.  
  136. #define    OPGRENT    "operator"        /* group entry to notify */
  137. #define DIALUP    "ttyd"            /* prefix for dialups */
  138.  
  139. struct    fstab *fstabsearch __P((char *key));    /* search fs_file and fs_spec */
  140.  
  141. #ifndef NAME_MAX
  142. #define NAME_MAX 255
  143. #endif
  144.  
  145. /*
  146.  *    The contents of the file _PATH_DUMPDATES is maintained both on
  147.  *    a linked list, and then (eventually) arrayified.
  148.  */
  149. struct dumpdates {
  150.     char    dd_name[NAME_MAX+3];
  151.     char    dd_level;
  152.     time_t    dd_ddate;
  153. };
  154. struct dumptime {
  155.     struct    dumpdates dt_value;
  156.     struct    dumptime *dt_next;
  157. };
  158. struct    dumptime *dthead;    /* head of the list version */
  159. int    nddates;        /* number of records (might be zero) */
  160. int    ddates_in;        /* we have read the increment file */
  161. struct    dumpdates **ddatev;    /* the arrayfied version */
  162. void    initdumptimes __P((void));
  163. void    getdumptime __P((void));
  164. void    putdumptime __P((void));
  165. #define    ITITERATE(i, ddp) \
  166.     for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i])
  167.  
  168. void    sig __P((int signo));
  169.  
  170. /*
  171.  * Compatibility with old systems.
  172.  */
  173. #ifndef __STDC__
  174. #include <sys/file.h>
  175. #define _PATH_FSTAB    "/etc/fstab"
  176. extern char *index(), *strdup();
  177. extern char *ctime();
  178. extern int errno;
  179. #endif
  180.  
  181. #ifdef sunos
  182. extern char *calloc();
  183. extern char *malloc();
  184. extern long atol();
  185. extern char *strcpy();
  186. extern char *strncpy();
  187. extern char *strcat();
  188. extern time_t time();
  189. extern void endgrent();
  190. extern void exit();
  191. extern off_t lseek();
  192. extern char *strerror();
  193. #endif
  194.