new fstab format
authorSam Leffler <sam@ucbvax.Berkeley.EDU>
Mon, 13 Jun 1983 07:15:18 +0000 (23:15 -0800)
committerSam Leffler <sam@ucbvax.Berkeley.EDU>
Mon, 13 Jun 1983 07:15:18 +0000 (23:15 -0800)
SCCS-vsn: sbin/dump/dump.h 1.9
SCCS-vsn: sbin/dump/optr.c 1.7

usr/src/sbin/dump/dump.h
usr/src/sbin/dump/optr.c

index bef6e47..c2d5928 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * "@(#)dump.h 1.8 (Berkeley) %G%"
+ * "@(#)dump.h 1.9 (Berkeley) %G%"
  */
 #define        NI              16
 #define MAXINOPB       (MAXBSIZE / sizeof(struct dinode))
  */
 #define        NI              16
 #define MAXINOPB       (MAXBSIZE / sizeof(struct dinode))
@@ -16,7 +16,6 @@
 #include <utmp.h>
 #include <time.h>
 #include <signal.h>
 #include <utmp.h>
 #include <time.h>
 #include <signal.h>
-int (*signal())();
 #include <fstab.h>
 
 #define        MWORD(m,i)      (m[(unsigned)(i-1)/NBBY])
 #include <fstab.h>
 
 #define        MWORD(m,i)      (m[(unsigned)(i-1)/NBBY])
@@ -101,10 +100,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 7c75584..930c6c9 100644 (file)
@@ -1,4 +1,4 @@
-static char *sccsid = "@(#)optr.c      1.6 (Berkeley) %G%";
+static char *sccsid = "@(#)optr.c      1.7 (Berkeley) %G%";
 
 #include "dump.h"
 
 
 #include "dump.h"
 
@@ -279,67 +279,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);
 }
 
 /*
 }
 
 /*