new fstab and utmp
authorSam Leffler <sam@ucbvax.Berkeley.EDU>
Mon, 13 Jun 1983 07:24:37 +0000 (23:24 -0800)
committerSam Leffler <sam@ucbvax.Berkeley.EDU>
Mon, 13 Jun 1983 07:24:37 +0000 (23:24 -0800)
SCCS-vsn: old/dump.4.1/dump.h 1.3
SCCS-vsn: old/dump.4.1/dumpoptr.c 1.5

usr/src/old/dump.4.1/dump.h
usr/src/old/dump.4.1/dumpoptr.c

index 0cba6f1..57990e3 100644 (file)
@@ -1,11 +1,14 @@
 /*
 /*
- * "@(#)dump.h 1.2 (Berkeley) %G%"
+ * "@(#)dump.h 1.3 (Berkeley) %G%"
  */
 #define        NI      16
 #define        DIRPB   (BSIZE/sizeof(struct direct))
 
 #include <stdio.h>
 #include <ctype.h>
  */
 #define        NI      16
 #define        DIRPB   (BSIZE/sizeof(struct direct))
 
 #include <stdio.h>
 #include <ctype.h>
+#include <fstab.h>
+#include <signal.h>
+#include <utmp.h>
 #include "include.4.1/sys/param.h"
 #include "include.4.1/sys/stat.h"
 #include "include.4.1/sys/filsys.h"
 #include "include.4.1/sys/param.h"
 #include "include.4.1/sys/stat.h"
 #include "include.4.1/sys/filsys.h"
 #include "include.4.1/sys/inode.h"
 #include "include.4.1/sys/fblk.h"
 #include "include.4.1/sys/dir.h"
 #include "include.4.1/sys/inode.h"
 #include "include.4.1/sys/fblk.h"
 #include "include.4.1/sys/dir.h"
-#include "include.4.1/utmp.h"
 #include "include.4.1/time.h"
 #include "include.4.1/time.h"
-#include "include.4.1/signal.h"
 #include "include.4.1/dumprestor.h"
 #include "include.4.1/dumprestor.h"
-#include "include.4.1/fstab.h"
 
 #define        MWORD(m,i)      (m[(unsigned)(i-1)/MLEN])
 #define        MBIT(i)         (1<<((unsigned)(i-1)%MLEN))
 
 #define        MWORD(m,i)      (m[(unsigned)(i-1)/MLEN])
 #define        MBIT(i)         (1<<((unsigned)(i-1)%MLEN))
@@ -97,10 +97,7 @@ int  interrupt();            /* in case operator bangs on console */
 #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 */
 struct fstab   *fstabsearch(); /* search in fs_file and fs_spec */
-int    nfstab;
 
 /*
  *     The contents of the file NINCREM is maintained both on
 
 /*
  *     The contents of the file NINCREM is maintained both on
index ef8e950..b23231c 100644 (file)
@@ -1,4 +1,4 @@
-static char *sccsid = "@(#)dumpoptr.c  1.4 (Berkeley) %G%";
+static char *sccsid = "@(#)dumpoptr.c  1.5 (Berkeley) %G%";
 #include "dump.h"
 
 /*
 #include "dump.h"
 
 /*
@@ -276,67 +276,100 @@ 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;
+       register int i, keylength;
+       char *rawname();
+
+       if (table == NULL)
+               return ((struct fstab *)0);
+       keylength = min(strlen(key), sizeof (table->pf_fstab->fs_file));
+       for (pf = table; pf; pf = pf->pf_next) {
+               fs = pf->pf_fstab;
+               if (strncmp(fs->fs_file, key, keylength) == 0)
+                       return (fs);
+               if (strncmp(fs->fs_spec, key, keylength) == 0)
+                       return (fs);
+               if (strncmp(rawname(fs->fs_spec), key, keylength) == 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 == '/' &&
+                           strncmp(fs->fs_spec + 1, key, keylength) == 0)
+                               return (fs);
+                       if (*fs->fs_file == '/' &&
+                           strncmp(fs->fs_file + 1, key, keylength) == 0)
+                               return (fs);
                }
        }
                }
        }
-       return(0);
+       return (0);
 }
 
 /*
 }
 
 /*