add firewall check for bad entry in state map
[unix-history] / usr / src / sbin / fsck / setup.c
index e8e81d1..88ddbdb 100644 (file)
@@ -1,6 +1,12 @@
+/*
+ * 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
 #ifndef lint
-static char version[] = "@(#)setup.c   3.2 (Berkeley) %G%";
-#endif
+static char sccsid[] = "@(#)setup.c    5.2 (Berkeley) %G%";
+#endif not lint
 
 #include <sys/param.h>
 #include <sys/inode.h>
 
 #include <sys/param.h>
 #include <sys/inode.h>
@@ -53,11 +59,7 @@ setup(dev)
        }
        if (preen == 0)
                printf("\n");
        }
        if (preen == 0)
                printf("\n");
-       fixcg = 0; inosumbad = 0; offsumbad = 0; frsumbad = 0; sbsumbad = 0;
        dfile.mod = 0;
        dfile.mod = 0;
-       n_files = n_blks = n_ffree = n_bfree = 0;
-       muldup = enddup = &duplist[0];
-       badlnp = &badlncnt[0];
        lfdir = 0;
        initbarea(&sblk);
        initbarea(&fileblk);
        lfdir = 0;
        initbarea(&sblk);
        initbarea(&fileblk);
@@ -67,7 +69,7 @@ setup(dev)
        /*
         * Read in the super block and its summary info.
         */
        /*
         * Read in the super block and its summary info.
         */
-       if (bread(&dfile, (char *)&sblock, super, (long)SBSIZE) == 0)
+       if (bread(&dfile, (char *)&sblock, super, (long)SBSIZE) != 0)
                return (0);
        sblk.b_bno = super;
        sblk.b_size = SBSIZE;
                return (0);
        sblk.b_bno = super;
        sblk.b_size = SBSIZE;
@@ -92,8 +94,8 @@ setup(dev)
         */
        if (bflag)
                goto sbok;
         */
        if (bflag)
                goto sbok;
-       if (getblk(&asblk, cgsblock(&sblock, sblock.fs_ncg - 1),
-           sblock.fs_sbsize) == 0)
+       getblk(&asblk, cgsblock(&sblock, sblock.fs_ncg - 1), sblock.fs_sbsize);
+       if (asblk.b_errs != NULL)
                return (0);
        altsblock.fs_link = sblock.fs_link;
        altsblock.fs_rlink = sblock.fs_rlink;
                return (0);
        altsblock.fs_link = sblock.fs_link;
        altsblock.fs_rlink = sblock.fs_rlink;
@@ -106,6 +108,7 @@ setup(dev)
        altsblock.fs_flags = sblock.fs_flags;
        altsblock.fs_maxcontig = sblock.fs_maxcontig;
        altsblock.fs_minfree = sblock.fs_minfree;
        altsblock.fs_flags = sblock.fs_flags;
        altsblock.fs_maxcontig = sblock.fs_maxcontig;
        altsblock.fs_minfree = sblock.fs_minfree;
+       altsblock.fs_optim = sblock.fs_optim;
        altsblock.fs_rotdelay = sblock.fs_rotdelay;
        altsblock.fs_maxbpg = sblock.fs_maxbpg;
        bcopy((char *)sblock.fs_csp, (char *)altsblock.fs_csp,
        altsblock.fs_rotdelay = sblock.fs_rotdelay;
        altsblock.fs_maxbpg = sblock.fs_maxbpg;
        bcopy((char *)sblock.fs_csp, (char *)altsblock.fs_csp,
@@ -117,7 +120,6 @@ setup(dev)
 sbok:
        fmax = sblock.fs_size;
        imax = sblock.fs_ncg * sblock.fs_ipg;
 sbok:
        fmax = sblock.fs_size;
        imax = sblock.fs_ncg * sblock.fs_ipg;
-       n_bad = cgsblock(&sblock, 0); /* boot block plus dedicated sblock */
        /*
         * read in the summary info.
         */
        /*
         * read in the summary info.
         */
@@ -127,7 +129,7 @@ sbok:
                sblock.fs_csp[j] = (struct csum *)calloc(1, (unsigned)size);
                if (bread(&dfile, (char *)sblock.fs_csp[j],
                    fsbtodb(&sblock, sblock.fs_csaddr + j * sblock.fs_frag),
                sblock.fs_csp[j] = (struct csum *)calloc(1, (unsigned)size);
                if (bread(&dfile, (char *)sblock.fs_csp[j],
                    fsbtodb(&sblock, sblock.fs_csaddr + j * sblock.fs_frag),
-                   size) == 0)
+                   size) != 0)
                        return (0);
        }
        /*
                        return (0);
        }
        /*
@@ -139,11 +141,6 @@ sbok:
                printf("cannot alloc %d bytes for blockmap\n", bmapsz);
                goto badsb;
        }
                printf("cannot alloc %d bytes for blockmap\n", bmapsz);
                goto badsb;
        }
-       freemap = calloc((unsigned)bmapsz, sizeof (char));
-       if (freemap == NULL) {
-               printf("cannot alloc %d bytes for freemap\n", bmapsz);
-               goto badsb;
-       }
        statemap = calloc((unsigned)(imax + 1), sizeof(char));
        if (statemap == NULL) {
                printf("cannot alloc %d bytes for statemap\n", imax + 1);
        statemap = calloc((unsigned)(imax + 1), sizeof(char));
        if (statemap == NULL) {
                printf("cannot alloc %d bytes for statemap\n", imax + 1);