BSD 4_3_Tahoe release
[unix-history] / usr / src / old / dump.4.1 / dumpoptr.c
index 526b90e..aa102d1 100644 (file)
@@ -1,4 +1,13 @@
-static char *sccsid = "@(#)dumpoptr.c  1.2 (Berkeley) %G%";
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)dumpoptr.c 5.1 (Berkeley) 6/5/85";
+#endif not lint
+
 #include "dump.h"
 
 /*
 #include "dump.h"
 
 /*
@@ -147,7 +156,7 @@ broadcast(message)
        }
 
        if (!notify || gp == 0)
        }
 
        if (!notify || gp == 0)
-               return;
+               exit(0);
        clock = time(0);
        localclock = localtime(&clock);
 
        clock = time(0);
        localclock = localtime(&clock);
 
@@ -276,73 +285,105 @@ msgtail(fmt, a1, a2, a3, a4, a5)
  *     we don't actually do it
  */
 
  *     we don't actually do it
  */
 
+struct fstab *
+allocfsent(fs)
+       register struct fstab *fs;
+{
+       register struct fstab *new;
+       register char *cp;
+       char *malloc();
+
+       new = (struct fstab *)malloc(sizeof (*fs));
+       cp = malloc(strlen(fs->fs_file) + 1);
+       strcpy(cp, fs->fs_file);
+       new->fs_file = cp;
+       cp = malloc(strlen(fs->fs_type) + 1);
+       strcpy(cp, fs->fs_type);
+       new->fs_type = cp;
+       cp = malloc(strlen(fs->fs_spec) + 1);
+       strcpy(cp, fs->fs_spec);
+       new->fs_spec = cp;
+       new->fs_passno = fs->fs_passno;
+       new->fs_freq = fs->fs_freq;
+       return (new);
+}
+
+struct pfstab {
+       struct  pfstab *pf_next;
+       struct  fstab *pf_fstab;
+};
+
+static struct pfstab *table = NULL;
+
 getfstab()
 {
 getfstab()
 {
-       register        struct  fstab   *dt;
-                       struct  fstab   *fsp;
+       register struct fstab *fs;
+       register struct pfstab *pf;
 
 
-       nfstab = 0;
        if (setfsent() == 0) {
                msg("Can't open %s for dump table information.\n", FSTAB);
        if (setfsent() == 0) {
                msg("Can't open %s for dump table information.\n", FSTAB);
-       } else {
-               for (nfstab = 0, dt = fstab; nfstab < MAXFSTAB;){
-                       if ( (fsp = getfsent()) == 0)
-                               break;
-                       if (   (strcmp(fsp->fs_type, FSTAB_RW) == 0)
-                           || (strcmp(fsp->fs_type, FSTAB_RO) == 0) ){
-                               *dt = *fsp;
-                               nfstab++; 
-                               dt++;
-                       }
-               }
-               endfsent();
+               return;
+       }
+       while (fs = getfsent()) {
+               if (strcmp(fs->fs_type, FSTAB_RW) &&
+                   strcmp(fs->fs_type, FSTAB_RO) &&
+                   strcmp(fs->fs_type, FSTAB_RQ))
+                       continue;
+               fs = allocfsent(fs);
+               pf = (struct pfstab *)malloc(sizeof (*pf));
+               pf->pf_fstab = fs;
+               pf->pf_next = table;
+               table = pf;
        }
        }
+       endfsent();
 }
 
 /*
 }
 
 /*
- *     Search in the fstab for a file name.
- *     This file name can be either the special or the path file name.
+ * Search in the fstab for a file name.
+ * This file name can be either the special or the path file name.
  *
  *
- *     The entries in the fstab are the BLOCK special names, not the
- *     character special names.
- *     The caller of fstabsearch assures that the character device
- *     is dumped (that is much faster)
+ * The entries in the fstab are the BLOCK special names, not the
+ * character special names.
+ * The caller of fstabsearch assures that the character device
+ * is dumped (that is much faster)
  *
  *
- *     The file name can omit the leading '/'.
+ * The file name can omit the leading '/'.
  */
  */
-struct fstab   *fstabsearch(key)
-       char    *key;
+struct fstab *
+fstabsearch(key)
+       char *key;
 {
 {
-       register        struct  fstab *dt;
-                       int     i;
-                       int     keylength;
-                       char    *rawname();
-
-       keylength = min(strlen(key), sizeof (dt->fs_file));
-       for (i = 0, dt = fstab; i < nfstab; i++, dt++){
-               if (strncmp(dt->fs_file, key, keylength) == 0)
-                       return(dt);
-               if (strncmp(dt->fs_spec, key, keylength) == 0)
-                       return(dt);
-               if (strncmp(rawname(dt->fs_spec), key, keylength) == 0)
-                       return(dt);
-
+       register struct pfstab *pf;
+       register struct fstab *fs;
+       char *rawname();
+
+       if (table == NULL)
+               return ((struct fstab *)0);
+       for (pf = table; pf; pf = pf->pf_next) {
+               fs = pf->pf_fstab;
+               if (strcmp(fs->fs_file, key) == 0)
+                       return (fs);
+               if (strcmp(fs->fs_spec, key) == 0)
+                       return (fs);
+               if (strcmp(rawname(fs->fs_spec), key) == 0)
+                       return (fs);
                if (key[0] != '/'){
                if (key[0] != '/'){
-                       if (   (dt->fs_spec[0] == '/')
-                           && (strncmp(dt->fs_spec+1, key, keylength) == 0))
-                               return(dt);
-                       if (   (dt->fs_file[0] == '/')
-                           && (strncmp(dt->fs_file+1, key, keylength) == 0))
-                               return(dt);
+                       if (*fs->fs_spec == '/' &&
+                           strcmp(fs->fs_spec + 1, key) == 0)
+                               return (fs);
+                       if (*fs->fs_file == '/' &&
+                           strcmp(fs->fs_file + 1, key) == 0)
+                               return (fs);
                }
        }
                }
        }
-       return(0);
+       return (0);
 }
 
 /*
  *     Tell the operator what to do
  */
 }
 
 /*
  *     Tell the operator what to do
  */
-lastdump()
+lastdump(arg)
+       char    arg;            /* w ==> just what to do; W ==> most recent dumps */
 {
                        char    *lastname;
                        char    *date;
 {
                        char    *lastname;
                        char    *date;
@@ -359,7 +400,10 @@ lastdump()
        inititimes();           /* /etc/dumpdates input */
        qsort(idatev, nidates, sizeof(struct idates *), idatesort);
 
        inititimes();           /* /etc/dumpdates input */
        qsort(idatev, nidates, sizeof(struct idates *), idatesort);
 
-       fprintf(stdout, "Last dump(s) done (Dump '*' file systems):\n");
+       if (arg == 'w')
+               fprintf(stdout, "Dump these file systems:\n");
+       else
+               fprintf(stdout, "Last dump(s) done (Dump '>' file systems):\n");
        lastname = "??";
        ITITERATE(i, itwalk){
                if (strncmp(lastname, itwalk->id_name, sizeof(itwalk->id_name)) == 0)
        lastname = "??";
        ITITERATE(i, itwalk){
                if (strncmp(lastname, itwalk->id_name, sizeof(itwalk->id_name)) == 0)
@@ -371,8 +415,9 @@ lastdump()
                dumpme = (  (dt != 0)
                         && (dt->fs_freq != 0)
                         && (itwalk->id_ddate < tnow - (dt->fs_freq*DAY)));
                dumpme = (  (dt != 0)
                         && (dt->fs_freq != 0)
                         && (itwalk->id_ddate < tnow - (dt->fs_freq*DAY)));
-               fprintf(stdout,"%c %8s\t(%6s) Last dump: Level %c, Date %s\n",
-                       dumpme ? '*' : ' ',
+               if ( (arg != 'w') || dumpme)
+                 fprintf(stdout,"%c %8s\t(%6s) Last dump: Level %c, Date %s\n",
+                       dumpme && (arg != 'w') ? '>' : ' ',
                        itwalk->id_name,
                        dt ? dt->fs_file : 0,
                        itwalk->id_incno,
                        itwalk->id_name,
                        dt ? dt->fs_file : 0,
                        itwalk->id_incno,