lint (calloc declaration is provided elsewhere)
[unix-history] / usr / src / sbin / dump / dump.h
index bef6e47..83cc74f 100644 (file)
@@ -1,55 +1,50 @@
-/*
- * "@(#)dump.h 1.8 (Berkeley) %G%"
+/*-
+ * Copyright (c) 1980 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * %sccs.include.redist.c%
+ *
+ *     @(#)dump.h      5.22 (Berkeley) %G%
  */
  */
-#define        NI              16
+
 #define MAXINOPB       (MAXBSIZE / sizeof(struct dinode))
 #define MAXNINDIR      (MAXBSIZE / sizeof(daddr_t))
 
 #define MAXINOPB       (MAXBSIZE / sizeof(struct dinode))
 #define MAXNINDIR      (MAXBSIZE / sizeof(daddr_t))
 
-#include <stdio.h>
-#include <ctype.h>
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <sys/fs.h>
-#include <sys/inode.h>
-#include <dumprestor.h>
-#include <dir.h>
-#include <utmp.h>
-#include <time.h>
-#include <signal.h>
-int (*signal())();
-#include <fstab.h>
-
-#define        MWORD(m,i)      (m[(unsigned)(i-1)/NBBY])
-#define        MBIT(i)         (1<<((unsigned)(i-1)%NBBY))
-#define        BIS(i,w)        (MWORD(w,i) |=  MBIT(i))
-#define        BIC(i,w)        (MWORD(w,i) &= ~MBIT(i))
-#define        BIT(i,w)        (MWORD(w,i) & MBIT(i))
-
-int    msiz;
-char   *clrmap;
-char   *dirmap;
-char   *nodmap;
+/*
+ * Dump maps used to describe what is to be dumped.
+ */
+int    mapsize;        /* size of the state maps */
+char   *usedinomap;    /* map of allocated inodes */
+char   *dumpdirmap;    /* map of directories to be dumped */
+char   *dumpinomap;    /* map of files to be dumped */
+/*
+ * Map manipulation macros.
+ */
+#define        SETINO(ino, map) \
+       map[(u_int)((ino) - 1) / NBBY] |=  1 << ((u_int)((ino) - 1) % NBBY)
+#define        CLRINO(ino, map) \
+       map[(u_int)((ino) - 1) / NBBY] &=  ~(1 << ((u_int)((ino) - 1) % NBBY))
+#define        TSTINO(ino, map) \
+       (map[(u_int)((ino) - 1) / NBBY] &  (1 << ((u_int)((ino) - 1) % NBBY)))
 
 /*
  *     All calculations done in 0.1" units!
  */
 
 /*
  *     All calculations done in 0.1" units!
  */
-
 char   *disk;          /* name of the disk file */
 char   *tape;          /* name of the tape file */
 char   *disk;          /* name of the disk file */
 char   *tape;          /* name of the tape file */
-char   *increm;        /* name of the file containing incremental information*/
-char   incno;          /* increment number */
+char   *dumpdates;     /* name of the file containing dump date information*/
+char   *temp;          /* name of the file for doing rewrite of dumpdates */
+char   lastlevel;      /* dump level of previous dump */
+char   level;          /* dump level of this dump */
 int    uflag;          /* update flag */
 int    uflag;          /* update flag */
-int    fi;             /* disk file descriptor */
-int    to;             /* tape file descriptor */
+int    diskfd;         /* disk file descriptor */
+int    tapefd;         /* tape file descriptor */
 int    pipeout;        /* true => output to standard output */
 int    pipeout;        /* true => output to standard output */
-ino_t  ino;            /* current inumber; used globally */
-int    nsubdir;
+ino_t  curino;         /* current inumber; used globally */
 int    newtape;        /* new tape flag */
 int    newtape;        /* new tape flag */
-int    nadded;         /* number of added sub directories */
-int    dadded;         /* directory added flag */
 int    density;        /* density in 0.1" units */
 int    density;        /* density in 0.1" units */
+long   tapesize;       /* estimated tape size, blocks */
 long   tsize;          /* tape size in 0.1" units */
 long   tsize;          /* tape size in 0.1" units */
-long   esize;          /* estimated tape size, blocks */
 long   asize;          /* number of 0.1" units written on current tape */
 int    etapes;         /* estimated number of tapes */
 
 long   asize;          /* number of 0.1" units written on current tape */
 int    etapes;         /* estimated number of tapes */
 
@@ -57,85 +52,123 @@ int        notify;         /* notify operator flag */
 int    blockswritten;  /* number of blocks written on current tape */
 int    tapeno;         /* current tape number */
 time_t tstart_writing; /* when started writing the first tape block */
 int    blockswritten;  /* number of blocks written on current tape */
 int    tapeno;         /* current tape number */
 time_t tstart_writing; /* when started writing the first tape block */
-char   *processname;
-struct fs *sblock;     /* the file system super block */
-char   buf[MAXBSIZE];
-
-char   *ctime();
-char   *prdate();
-long   atol();
-int    mark();
-int    add();
-int    dump();
-int    tapsrec();
-int    dmpspc();
-int    dsrch();
-int    nullf();
-char   *getsuffix();
-char   *rawname();
-struct dinode *getino();
-
-int    interrupt();            /* in case operator bangs on console */
-
-#define        HOUR    (60L*60L)
-#define        DAY     (24L*HOUR)
-#define        YEAR    (365L*DAY)
+struct fs *sblock;     /* the file system super block */
+char   sblock_buf[MAXBSIZE];
+long   dev_bsize;      /* block size of underlying disk device */
+int    dev_bshift;     /* log2(dev_bsize) */
+int    tp_bshift;      /* log2(TP_BSIZE) */
+
+/* operator interface functions */
+void   broadcast __P((char *message));
+void   lastdump __P((int arg));        /* int should be char */
+void   msg __P((const char *fmt, ...));
+void   msgtail __P((const char *fmt, ...));
+int    query __P((char *question));
+void   quit __P((const char *fmt, ...));
+void   set_operators __P((void));
+void   timeest __P((void));
+time_t unctime __P((char *str));
+
+/* mapping rouintes */
+struct dinode;
+long   blockest __P((struct dinode *dp));
+int    mapfiles __P((ino_t maxino, long *tapesize));
+int    mapdirs __P((ino_t maxino, long *tapesize));
+
+/* file dumping routines */
+void   blksout __P((daddr_t *blkp, int frags, ino_t ino));
+void   bread __P((daddr_t blkno, char *buf, int size));        
+void   dumpino __P((struct dinode *dp, ino_t ino));
+void   dumpmap __P((char *map, int type, ino_t ino));
+void   writeheader __P((ino_t ino));
+
+/* tape writing routines */
+int    alloctape __P((void));
+void   close_rewind __P((void));
+void   dumpblock __P((daddr_t blkno, int size));
+void   startnewtape __P((int top));
+void   trewind __P((void));
+void   writerec __P((char *dp, int isspcl));
+
+void   Exit __P((int status));
+void   dumpabort __P((int signo));
+void   getfstab __P((void));
+
+char   *rawname __P((char *cp));
+struct dinode *getino __P((ino_t inum));
+
+/* rdump routines */
+#ifdef RDUMP
+void   rmtclose __P((void));
+int    rmthost __P((char *host));
+int    rmtopen __P((char *tape, int mode));
+int    rmtwrite __P((char *buf, int count));
+#endif /* RDUMP */
+
+void   interrupt __P((int signo));     /* in case operator bangs on console */
 
 /*
  *     Exit status codes
  */
 
 /*
  *     Exit status codes
  */
-#define        X_FINOK         1       /* normal exit */
+#define        X_FINOK         0       /* normal exit */
 #define        X_REWRITE       2       /* restart writing from the check point */
 #define        X_REWRITE       2       /* restart writing from the check point */
-#define        X_ABORT         3       /* abort all of dump; don't attempt checkpointing*/
-
-#ifdef DEBUG
-#define        OINCREM "./ddate"               /*old format incremental info*/
-#define        NINCREM "./dumpdates"           /*new format incremental info*/
-#else not DEBUG
-#define        OINCREM "/etc/ddate"            /*old format incremental info*/
-#define        NINCREM "/etc/dumpdates"        /*new format incremental info*/
-#endif
+#define        X_ABORT         3       /* abort dump; don't attempt checkpointing */
 
 
-#define        TAPE    "/dev/rmt8"             /* default tape device */
-#define        DISK    "/dev/rrp1g"            /* default disk */
 #define        OPGRENT "operator"              /* group entry to notify */
 #define DIALUP "ttyd"                  /* prefix for dialups */
 
 #define        OPGRENT "operator"              /* group entry to notify */
 #define DIALUP "ttyd"                  /* prefix for dialups */
 
-#define        MAXFSTAB                32
-struct fstab   fstab[MAXFSTAB];
-struct fstab   *fstabsearch(); /* search in fs_file and fs_spec */
-int    nfstab;
+struct fstab *fstabsearch __P((char *key));    /* search fs_file and fs_spec */
+
+#ifndef NAME_MAX
+#define NAME_MAX 255
+#endif
 
 /*
 
 /*
- *     The contents of the file NINCREM is maintained both on
+ *     The contents of the file _PATH_DUMPDATES is maintained both on
  *     a linked list, and then (eventually) arrayified.
  */
  *     a linked list, and then (eventually) arrayified.
  */
-struct idates {
-       char    id_name[MAXNAMLEN+3];
-       char    id_incno;
-       time_t  id_ddate;
+struct dumpdates {
+       char    dd_name[NAME_MAX+3];
+       char    dd_level;
+       time_t  dd_ddate;
 };
 };
-struct itime{
-       struct  idates  it_value;
-       struct  itime   *it_next;
+struct dumptime {
+       struct  dumpdates dt_value;
+       struct  dumptime *dt_next;
 };
 };
-struct itime   *ithead;        /* head of the list version */
-int    nidates;                /* number of records (might be zero) */
-int    idates_in;              /* we have read the increment file */
-struct idates  **idatev;       /* the arrayfied version */
-#define        ITITERATE(i, ip) for (i = 0,ip = idatev[0]; i < nidates; i++, ip = idatev[i])
+struct dumptime *dthead;       /* head of the list version */
+int    nddates;                /* number of records (might be zero) */
+int    ddates_in;              /* we have read the increment file */
+struct dumpdates **ddatev;     /* the arrayfied version */
+void   initdumptimes __P((void));
+void   getdumptime __P((void));
+void   putdumptime __P((void));
+#define        ITITERATE(i, ddp) \
+       for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i])
+
+void   sig __P((int signo));
 
 /*
 
 /*
- *     We catch these interrupts
+ * Compatibility with old systems.
  */
  */
-int    sighup();
-int    sigquit();
-int    sigill();
-int    sigtrap();
-int    sigfpe();
-int    sigkill();
-int    sigbus();
-int    sigsegv();
-int    sigsys();
-int    sigalrm();
-int    sigterm();
+#ifndef __STDC__
+#include <sys/file.h>
+#define _PATH_FSTAB    "/etc/fstab"
+extern char *index(), *strdup();
+extern char *ctime();
+extern int errno;
+#endif
+
+#ifdef sunos
+extern char *calloc();
+extern char *malloc();
+extern long atol();
+extern char *strcpy();
+extern char *strncpy();
+extern char *strcat();
+extern time_t time();
+extern void endgrent();
+extern __dead void exit();
+extern off_t lseek();
+extern char *strerror();
+#endif