install correct aliases file
[unix-history] / usr / src / old / dcheck / dcheck.c
index b3d109e..8558a45 100644 (file)
@@ -1,25 +1,34 @@
-static char sccsid[] = "@(#)dcheck.c 2.2 %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
+char copyright[] =
+"@(#) Copyright (c) 1980 Regents of the University of California.\n\
+ All rights reserved.\n";
+#endif not lint
+
+#ifndef lint
+static char sccsid[] = "@(#)dcheck.c   5.3 (Berkeley) %G%";
+#endif not lint
+
 /*
  * dcheck - check directory consistency
  */
 #define        NB      10
 #define        MAXNINDIR       (MAXBSIZE / sizeof (daddr_t))
 
 /*
  * dcheck - check directory consistency
  */
 #define        NB      10
 #define        MAXNINDIR       (MAXBSIZE / sizeof (daddr_t))
 
-#ifndef SIMFS
 #include <sys/param.h>
 #include <sys/inode.h>
 #include <sys/fs.h>
 #include <sys/param.h>
 #include <sys/inode.h>
 #include <sys/fs.h>
-#else
-#include "../h/param.h"
-#include "../h/inode.h"
-#include "../h/fs.h"
-#endif
-#include <dir.h>
+#include <sys/dir.h>
 #include <stdio.h>
 
 union {
        struct  fs fs;
 #include <stdio.h>
 
 union {
        struct  fs fs;
-       char pad[MAXBSIZE];
+       char pad[SBSIZE];
 } fsun;
 #define        sblock  fsun.fs
 
 } fsun;
 #define        sblock  fsun.fs
 
@@ -29,7 +38,7 @@ struct dirstuff {
        char dbuf[MAXBSIZE];
 };
 
        char dbuf[MAXBSIZE];
 };
 
-struct dinode  itab[MAXIPG];
+struct dinode  itab[MAXBSIZE / sizeof(struct dinode)];
 struct dinode  *gip;
 ino_t  ilist[NB];
 
 struct dinode  *gip;
 ino_t  ilist[NB];
 
@@ -38,6 +47,7 @@ ino_t ino;
 ino_t  *ecount;
 int    headpr;
 int    nfiles;
 ino_t  *ecount;
 int    headpr;
 int    nfiles;
+long   dev_bsize = 1;
 
 int    nerror;
 daddr_t        bmap();
 
 int    nerror;
 daddr_t        bmap();
@@ -90,18 +100,14 @@ char *file;
        headpr = 0;
        printf("%s:\n", file);
        sync();
        headpr = 0;
        printf("%s:\n", file);
        sync();
-       bread(SBLOCK, (char *)&sblock, SBSIZE);
+       bread(SBOFF, (char *)&sblock, SBSIZE);
        if (sblock.fs_magic != FS_MAGIC) {
                printf("%s: not a file system\n", file);
                nerror++;
                return;
        }
        if (sblock.fs_magic != FS_MAGIC) {
                printf("%s: not a file system\n", file);
                nerror++;
                return;
        }
+       dev_bsize = sblock.fs_fsize / fsbtodb(&sblock, 1);
        nfiles = sblock.fs_ipg * sblock.fs_ncg;
        nfiles = sblock.fs_ipg * sblock.fs_ncg;
-       if (nfiles > 65535) {
-               printf("%s: preposterous number of files\n", file);
-               nerror++;
-               return;
-       }
        ecount = (ino_t *)malloc((nfiles+1) * sizeof (*ecount));
        if (ecount == 0) {
                printf("%s: not enough core for %d files\n", file, nfiles);
        ecount = (ino_t *)malloc((nfiles+1) * sizeof (*ecount));
        if (ecount == 0) {
                printf("%s: not enough core for %d files\n", file, nfiles);
@@ -111,20 +117,28 @@ char *file;
                ecount[i] = 0;
        ino = 0;
        for (c = 0; c < sblock.fs_ncg; c++) {
                ecount[i] = 0;
        ino = 0;
        for (c = 0; c < sblock.fs_ncg; c++) {
-               bread(fsbtodb(&sblock, cgimin(&sblock, c)), (char *)itab,
-                   sblock.fs_ipg * sizeof (struct dinode));
-               for (j = 0; j < sblock.fs_ipg; j++) {
-                       pass1(&itab[j]);
-                       ino++;
+               for (i = 0;
+                    i < sblock.fs_ipg / INOPF(&sblock);
+                    i += sblock.fs_frag) {
+                       bread(fsbtodb(&sblock, cgimin(&sblock, c) + i),
+                           (char *)itab, sblock.fs_bsize);
+                       for (j = 0; j < INOPB(&sblock); j++) {
+                               pass1(&itab[j]);
+                               ino++;
+                       }
                }
        }
        ino = 0;
        for (c = 0; c < sblock.fs_ncg; c++) {
                }
        }
        ino = 0;
        for (c = 0; c < sblock.fs_ncg; c++) {
-               bread(fsbtodb(&sblock, cgimin(&sblock, c)), (char *)itab,
-                   sblock.fs_ipg * sizeof (struct dinode));
-               for (j = 0; j < sblock.fs_ipg; j++) {
-                       pass2(&itab[j]);
-                       ino++;
+               for (i = 0;
+                    i < sblock.fs_ipg / INOPF(&sblock);
+                    i += sblock.fs_frag) {
+                       bread(fsbtodb(&sblock, cgimin(&sblock, c) + i),
+                           (char *)itab, sblock.fs_bsize);
+                       for (j = 0; j < INOPB(&sblock); j++) {
+                               pass2(&itab[j]);
+                               ino++;
+                       }
                }
        }
        free(ecount);
                }
        }
        free(ecount);
@@ -214,7 +228,7 @@ char *buf;
 {
        register i;
 
 {
        register i;
 
-       lseek(fi, bno * DEV_BSIZE, 0);
+       lseek(fi, bno * dev_bsize, 0);
        if (read(fi, buf, cnt) != cnt) {
                printf("read error %d\n", bno);
                for(i=0; i < cnt; i++)
        if (read(fi, buf, cnt) != cnt) {
                printf("read error %d\n", bno);
                for(i=0; i < cnt; i++)