merge into new kernel
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Fri, 9 Apr 1982 02:41:11 +0000 (18:41 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Fri, 9 Apr 1982 02:41:11 +0000 (18:41 -0800)
SCCS-vsn: sbin/fsck/main.c 2.1

usr/src/sbin/fsck/main.c

index d42986e..9d84d3a 100644 (file)
@@ -1,13 +1,19 @@
-static char *sccsid = "@(#)main.c      1.31 (Berkeley) %G%";
+static char *sccsid = "@(#)main.c      2.1 (Berkeley) %G%";
 
 #include <stdio.h>
 #include <ctype.h>
 
 #include <stdio.h>
 #include <ctype.h>
+#ifndef SIMFS
+#include <sys/param.h>
+#include <sys/fs.h>
+#include <sys/inode.h>
+#include <ndir.h>
+#else
 #include "../h/param.h"
 #include "../h/fs.h"
 #include "../h/inode.h"
 #include "../h/param.h"
 #include "../h/fs.h"
 #include "../h/inode.h"
-#include "../h/stat.h"
-#include "../h/ostat.h"
-#include <ndir.h>
+#include "../h/ndir.h"
+#endif
+#include <sys/stat.h>
 #include <fstab.h>
 
 typedef        int     (*SIG_TYP)();
 #include <fstab.h>
 
 typedef        int     (*SIG_TYP)();
@@ -269,7 +275,7 @@ main(argc, argv)
 blockcheck(name)
        char *name;
 {
 blockcheck(name)
        char *name;
 {
-       struct ostat stslash, stblock, stchar;
+       struct stat stslash, stblock, stchar;
        char *raw;
        int looped = 0;
 
        char *raw;
        int looped = 0;
 
@@ -318,7 +324,7 @@ unrawname(cp)
        char *cp;
 {
        char *dp = rindex(cp, '/');
        char *cp;
 {
        char *dp = rindex(cp, '/');
-       struct ostat stb;
+       struct stat stb;
 
        if (dp == 0)
                return (cp);
 
        if (dp == 0)
                return (cp);
@@ -1195,7 +1201,7 @@ setup(dev)
        char *dev;
 {
        dev_t rootdev;
        char *dev;
 {
        dev_t rootdev;
-       struct ostat statb;
+       struct stat statb;
        int super = bflag ? bflag : SBLOCK;
 
        bflag = 0;
        int super = bflag ? bflag : SBLOCK;
 
        bflag = 0;
@@ -1866,3 +1872,110 @@ isblock(fs, cp, h)
                return (0);
        }
 }
                return (0);
        }
 }
+
+/*     tables.c        4.1     82/03/25        */
+
+/* merged into kernel: tables.c 2.1 3/25/82 */
+
+/* last monet version: partab.c        4.2     81/03/08        */
+
+/*
+ * bit patterns for identifying fragments in the block map
+ * used as ((map & around) == inside)
+ */
+int around[9] = {
+       0x3, 0x7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, 0x1ff, 0x3ff
+};
+int inside[9] = {
+       0x0, 0x2, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe
+};
+
+/*
+ * given a block map bit pattern, the frag tables tell whether a
+ * particular size fragment is available. 
+ *
+ * used as:
+ * if ((1 << (size - 1)) & fragtbl[fs->fs_frag][map] {
+ *     at least one fragment of the indicated size is available
+ * }
+ *
+ * These tables are used by the scanc instruction on the VAX to
+ * quickly find an appropriate fragment.
+ */
+
+unsigned char fragtbl124[256] = {
+       0x00, 0x16, 0x16, 0x2a, 0x16, 0x16, 0x26, 0x4e,
+       0x16, 0x16, 0x16, 0x3e, 0x2a, 0x3e, 0x4e, 0x8a,
+       0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
+       0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
+       0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
+       0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
+       0x2a, 0x3e, 0x3e, 0x2a, 0x3e, 0x3e, 0x2e, 0x6e,
+       0x3e, 0x3e, 0x3e, 0x3e, 0x2a, 0x3e, 0x6e, 0xaa,
+       0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
+       0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
+       0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
+       0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
+       0x26, 0x36, 0x36, 0x2e, 0x36, 0x36, 0x26, 0x6e,
+       0x36, 0x36, 0x36, 0x3e, 0x2e, 0x3e, 0x6e, 0xae,
+       0x4e, 0x5e, 0x5e, 0x6e, 0x5e, 0x5e, 0x6e, 0x4e,
+       0x5e, 0x5e, 0x5e, 0x7e, 0x6e, 0x7e, 0x4e, 0xce,
+       0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
+       0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
+       0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
+       0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
+       0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e,
+       0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e,
+       0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x7e,
+       0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x7e, 0xbe,
+       0x2a, 0x3e, 0x3e, 0x2a, 0x3e, 0x3e, 0x2e, 0x6e,
+       0x3e, 0x3e, 0x3e, 0x3e, 0x2a, 0x3e, 0x6e, 0xaa,
+       0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x7e,
+       0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x7e, 0xbe,
+       0x4e, 0x5e, 0x5e, 0x6e, 0x5e, 0x5e, 0x6e, 0x4e,
+       0x5e, 0x5e, 0x5e, 0x7e, 0x6e, 0x7e, 0x4e, 0xce,
+       0x8a, 0x9e, 0x9e, 0xaa, 0x9e, 0x9e, 0xae, 0xce,
+       0x9e, 0x9e, 0x9e, 0xbe, 0xaa, 0xbe, 0xce, 0x8a,
+};
+
+unsigned char fragtbl8[256] = {
+       0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x04,
+       0x01, 0x01, 0x01, 0x03, 0x02, 0x03, 0x04, 0x08,
+       0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
+       0x02, 0x03, 0x03, 0x02, 0x04, 0x05, 0x08, 0x10,
+       0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
+       0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
+       0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
+       0x04, 0x05, 0x05, 0x06, 0x08, 0x09, 0x10, 0x20,
+       0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
+       0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
+       0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
+       0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11,
+       0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
+       0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a,
+       0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04,
+       0x08, 0x09, 0x09, 0x0a, 0x10, 0x11, 0x20, 0x40,
+       0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
+       0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
+       0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
+       0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11,
+       0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05,
+       0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09,
+       0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07,
+       0x05, 0x05, 0x05, 0x07, 0x09, 0x09, 0x11, 0x21,
+       0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06,
+       0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a,
+       0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07,
+       0x02, 0x03, 0x03, 0x02, 0x06, 0x07, 0x0a, 0x12,
+       0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04,
+       0x05, 0x05, 0x05, 0x07, 0x06, 0x07, 0x04, 0x0c,
+       0x08, 0x09, 0x09, 0x0a, 0x09, 0x09, 0x0a, 0x0c,
+       0x10, 0x11, 0x11, 0x12, 0x20, 0x21, 0x40, 0x80,
+};
+
+/*
+ * the actual fragtbl array
+ */
+unsigned char *fragtbl[MAXFRAG + 1] = {
+       0, fragtbl124, fragtbl124, 0, fragtbl124, 0, 0, 0, fragtbl8,
+};