incorporate fs.h -r1.10, and param.h -r1.8 reorganization
authorKirk McKusick <mckusic@ucbvax.Berkeley.EDU>
Thu, 7 Jan 1982 15:35:10 +0000 (07:35 -0800)
committerKirk McKusick <mckusic@ucbvax.Berkeley.EDU>
Thu, 7 Jan 1982 15:35:10 +0000 (07:35 -0800)
SCCS-vsn: sbin/newfs/mkfs.c 1.12
SCCS-vsn: sbin/fsck/main.c 1.16
SCCS-vsn: old/dcheck/dcheck.c 1.5
SCCS-vsn: sbin/icheck/icheck.c 1.12
SCCS-vsn: sbin/ncheck/ncheck.c 1.5
SCCS-vsn: sbin/dumpfs/dumpfs.c 1.7
SCCS-vsn: sbin/restore/main.c 1.10

usr/src/old/dcheck/dcheck.c
usr/src/sbin/dumpfs/dumpfs.c
usr/src/sbin/fsck/main.c
usr/src/sbin/icheck/icheck.c
usr/src/sbin/ncheck/ncheck.c
usr/src/sbin/newfs/mkfs.c
usr/src/sbin/restore/main.c

index a236cb1..999d0f2 100644 (file)
@@ -1,11 +1,11 @@
-static char *sccsid = "@(#)dcheck.c    1.4 (Berkeley) %G%";
+static char *sccsid = "@(#)dcheck.c    1.5 (Berkeley) %G%";
 /*
  * dcheck - check directory consistency
  */
 #define        NB      10
 #define        NDIR(fs)        ((fs)->fs_bsize/sizeof(struct direct))
 #define        MAXNDIR         (MAXBSIZE/sizeof(struct direct))
 /*
  * dcheck - check directory consistency
  */
 #define        NB      10
 #define        NDIR(fs)        ((fs)->fs_bsize/sizeof(struct direct))
 #define        MAXNDIR         (MAXBSIZE/sizeof(struct direct))
-#define        MAXNINDIR       (MAXBSIZE/sizeof(daddr_t))
+#define        MAXNINDIR       (MAXBSIZE / sizeof (daddr_t))
 
 #include <stdio.h>
 #include "../h/param.h"
 
 #include <stdio.h>
 #include "../h/param.h"
@@ -80,7 +80,7 @@ char *file;
        headpr = 0;
        printf("%s:\n", file);
        sync();
        headpr = 0;
        printf("%s:\n", file);
        sync();
-       bread(SBLOCK, (char *)&sblock, MAXBSIZE);
+       bread(SBLOCK, (char *)&sblock, SBSIZE);
        if (sblock.fs_magic != FS_MAGIC) {
                printf("%s: not a file system\n", file);
                nerror++;
        if (sblock.fs_magic != FS_MAGIC) {
                printf("%s: not a file system\n", file);
                nerror++;
index 266bcf7..2470ae5 100644 (file)
@@ -1,4 +1,4 @@
-static char *sccsid = "@(#)dumpfs.c    1.6 (Berkeley) %G%";
+static char *sccsid = "@(#)dumpfs.c    1.7 (Berkeley) %G%";
 
 #include "../h/param.h"
 #include "../h/fs.h"
 
 #include "../h/param.h"
 #include "../h/fs.h"
@@ -29,7 +29,7 @@ main(argc, argv)
        if (open(argv[1], 0) != 0)
                perror(argv[1]), exit(1);
        lseek(0, SBLOCK * DEV_BSIZE, 0);
        if (open(argv[1], 0) != 0)
                perror(argv[1]), exit(1);
        lseek(0, SBLOCK * DEV_BSIZE, 0);
-       if (read(0, &afs, MAXBSIZE) != MAXBSIZE)
+       if (read(0, &afs, SBSIZE) != SBSIZE)
                perror(argv[1]), exit(1);
        printf("magic\t%x\n", afs.fs_magic);
        printf("sblkno\t%d\n", afs.fs_sblkno);
                perror(argv[1]), exit(1);
        printf("magic\t%x\n", afs.fs_magic);
        printf("sblkno\t%d\n", afs.fs_sblkno);
@@ -47,13 +47,14 @@ main(argc, argv)
        printf("cgsize\t%d\n", afs.fs_cgsize);
        printf("ntrak\t%d\nnsect\t%d\nspc\t%d\nncyl\t%d\n",
            afs.fs_ntrak, afs.fs_nsect, afs.fs_spc, afs.fs_ncyl);
        printf("cgsize\t%d\n", afs.fs_cgsize);
        printf("ntrak\t%d\nnsect\t%d\nspc\t%d\nncyl\t%d\n",
            afs.fs_ntrak, afs.fs_nsect, afs.fs_spc, afs.fs_ncyl);
-       printf("cpg\t%d\nfpg\t%d\nipg\t%d\n",
-           afs.fs_cpg, afs.fs_fpg, afs.fs_ipg);
+       printf("cpg\t%d\nbpg\t%d\nfpg\t%d\nipg\t%d\n",
+           afs.fs_cpg, afs.fs_fpg / afs.fs_frag, afs.fs_fpg, afs.fs_ipg);
        printf("ndir\t%d\nnffree\t%d\nnbfree\t%d\nnifree\t%d\n",
            afs.fs_cstotal.cs_ndir, afs.fs_cstotal.cs_nffree,
            afs.fs_cstotal.cs_nbfree, afs.fs_cstotal.cs_nifree);
        printf("ndir\t%d\nnffree\t%d\nnbfree\t%d\nnifree\t%d\n",
            afs.fs_cstotal.cs_ndir, afs.fs_cstotal.cs_nffree,
            afs.fs_cstotal.cs_nbfree, afs.fs_cstotal.cs_nifree);
-       printf("cgrotor\t%d\nblocks available in each rotational position",
-           afs.fs_cgrotor);
+       printf("cgrotor\t%d\nfmod\t%d\nronly\t%d\n",
+           afs.fs_cgrotor, afs.fs_fmod, afs.fs_ronly);
+       printf("blocks available in each rotational position");
        for (i = 0; i < NRPOS; i++) {
                if (afs.fs_postbl[i] > -1)
                        printf("\nposition %d:\t", i);
        for (i = 0; i < NRPOS; i++) {
                if (afs.fs_postbl[i] > -1)
                        printf("\nposition %d:\t", i);
@@ -80,8 +81,12 @@ main(argc, argv)
                    cs->cs_nbfree, cs->cs_ndir, cs->cs_nifree, cs->cs_nffree);
        }
        printf("\n");
                    cs->cs_nbfree, cs->cs_ndir, cs->cs_nifree, cs->cs_nffree);
        }
        printf("\n");
-       printf("fmod\t%d\n", afs.fs_fmod);
-       printf("ronly\t%d\n", afs.fs_ronly);
+       if (afs.fs_ncyl % afs.fs_cpg) {
+               printf("cylinders in last group %d\n",
+                   i = afs.fs_ncyl % afs.fs_cpg);
+               printf("blocks in last group %d\n",
+                   i * afs.fs_spc / NSPB(&afs));
+       }
        printf("\n");
        for (i = 0; i < afs.fs_ncg; i++)
                dumpcg(i);
        printf("\n");
        for (i = 0; i < afs.fs_ncg; i++)
                dumpcg(i);
index a2b893c..7430768 100644 (file)
@@ -1,4 +1,4 @@
-static char *sccsid = "@(#)main.c      1.15 (Berkeley) %G%";
+static char *sccsid = "@(#)main.c      1.16 (Berkeley) %G%";
 
 #include <stdio.h>
 #include <ctype.h>
 
 #include <stdio.h>
 #include <ctype.h>
@@ -14,8 +14,8 @@ typedef       int     (*SIG_TYP)();
 
 #define        NDIRECT(fs)     ((fs)->fs_bsize / sizeof(struct direct))
 #define        MAXNDIRECT      (MAXBSIZE / sizeof(struct direct))
 
 #define        NDIRECT(fs)     ((fs)->fs_bsize / sizeof(struct direct))
 #define        MAXNDIRECT      (MAXBSIZE / sizeof(struct direct))
-#define        MAXINOPB        (MAXBSIZE / sizeof(struct dinode))
-#define        MAXNINDIR       (MAXBSIZE / sizeof(daddr_t))
+#define        MAXNINDIR       (MAXBSIZE / sizeof (daddr_t))
+#define        MAXINOPB        (MAXBSIZE / sizeof (struct dinode))
 #define        SPERB           (MAXBSIZE / sizeof(short))
 
 #define        MAXDUP  10              /* limit on dup blks (per inode) */
 #define        SPERB           (MAXBSIZE / sizeof(short))
 
 #define        MAXDUP  10              /* limit on dup blks (per inode) */
@@ -1193,10 +1193,10 @@ setup(dev)
        initbarea(&fileblk);
        initbarea(&inoblk);
        initbarea(&cgblk);
        initbarea(&fileblk);
        initbarea(&inoblk);
        initbarea(&cgblk);
-       if (bread(&dfile, &sblock, super, MAXBSIZE) == 0)
+       if (bread(&dfile, &sblock, super, SBSIZE) == 0)
                return (0);
        sblk.b_bno = super;
                return (0);
        sblk.b_bno = super;
-       sblk.b_size = MAXBSIZE;
+       sblk.b_size = SBSIZE;
        if (sblock.fs_magic != FS_MAGIC)
                { badsb("MAGIC NUMBER WRONG"); return (0); }
        if (sblock.fs_ncg < 1)
        if (sblock.fs_magic != FS_MAGIC)
                { badsb("MAGIC NUMBER WRONG"); return (0); }
        if (sblock.fs_ncg < 1)
@@ -1230,7 +1230,8 @@ setup(dev)
        if (sblock.fs_spc != sblock.fs_nsect * sblock.fs_ntrak)
                { badsb("SPC DOES NOT JIVE w/NTRAK*NSECT"); return (0); }
        if (sblock.fs_cgsize !=
        if (sblock.fs_spc != sblock.fs_nsect * sblock.fs_ntrak)
                { badsb("SPC DOES NOT JIVE w/NTRAK*NSECT"); return (0); }
        if (sblock.fs_cgsize !=
-           sizeof(struct cg) + howmany(sblock.fs_fpg, NBBY))
+           roundup(sizeof(struct cg) + howmany(sblock.fs_fpg, NBBY),
+           sblock.fs_fsize))
                { badsb("CGSIZE INCORRECT"); return (0); }
        if (sblock.fs_cssize != sblock.fs_ncg * sizeof(struct csum))
                { badsb("CSSIZE INCORRECT"); return (0); }
                { badsb("CGSIZE INCORRECT"); return (0); }
        if (sblock.fs_cssize != sblock.fs_ncg * sizeof(struct csum))
                { badsb("CSSIZE INCORRECT"); return (0); }
index cef78cd..5ba5e33 100644 (file)
@@ -1,11 +1,11 @@
-static char *sccsid = "@(#)icheck.c    1.11 (Berkeley) %G%";
+static char *sccsid = "@(#)icheck.c    1.12 (Berkeley) %G%";
 
 /*
  * icheck
  */
 #define        NB      500
 #define        MAXFN   500
 
 /*
  * icheck
  */
 #define        NB      500
 #define        MAXFN   500
-#define MAXNINDIR (MAXBSIZE / sizeof (daddr_t))
+#define        MAXNINDIR       (MAXBSIZE / sizeof (daddr_t))
 
 #ifndef STANDALONE
 #include <stdio.h>
 
 #ifndef STANDALONE
 #include <stdio.h>
@@ -524,7 +524,7 @@ makecg()
        }
        sblock.fs_ronly = 0;
        sblock.fs_fmod = 0;
        }
        sblock.fs_ronly = 0;
        sblock.fs_fmod = 0;
-       bwrite(SBLOCK, (char *)&sblock, MAXBSIZE);
+       bwrite(SBLOCK, (char *)&sblock, SBSIZE);
 }
 
 /*
 }
 
 /*
@@ -567,7 +567,7 @@ getsb(fs, file)
 {
        int i;
 
 {
        int i;
 
-       if (bread(SBLOCK, fs, MAXBSIZE)) {
+       if (bread(SBLOCK, fs, SBSIZE)) {
                printf("bad super block");
                perror(file);
                nerror |= 04;
                printf("bad super block");
                perror(file);
                nerror |= 04;
index 1a78f5e..aa1f19d 100644 (file)
@@ -1,4 +1,4 @@
-static char *sccsid = "@(#)ncheck.c    1.4 (Berkeley) %G%";
+static char *sccsid = "@(#)ncheck.c    1.5 (Berkeley) %G%";
 /*
  * ncheck -- obtain file names from reading filesystem
  */
 /*
  * ncheck -- obtain file names from reading filesystem
  */
@@ -7,7 +7,7 @@ static  char *sccsid = "@(#)ncheck.c    1.4 (Berkeley) %G%";
 #define        HSIZE           2503
 #define        NDIR(fs)        ((fs)->fs_bsize/sizeof(struct direct))
 #define        MAXNDIR         (MAXBSIZE/sizeof(struct direct))
 #define        HSIZE           2503
 #define        NDIR(fs)        ((fs)->fs_bsize/sizeof(struct direct))
 #define        MAXNDIR         (MAXBSIZE/sizeof(struct direct))
-#define        MAXNINDIR       (MAXBSIZE/sizeof(daddr_t))
+#define        MAXNINDIR       (MAXBSIZE / sizeof (daddr_t))
 
 #include <stdio.h>
 #include "../h/param.h"
 
 #include <stdio.h>
 #include "../h/param.h"
@@ -94,7 +94,7 @@ check(file)
        nhent = 0;
        printf("%s:\n", file);
        sync();
        nhent = 0;
        printf("%s:\n", file);
        sync();
-       bread(SBLOCK, (char *)&sblock, MAXBSIZE);
+       bread(SBLOCK, (char *)&sblock, SBSIZE);
        if (sblock.fs_magic != FS_MAGIC) {
                printf("%s: not a file system\n", file);
                nerror++;
        if (sblock.fs_magic != FS_MAGIC) {
                printf("%s: not a file system\n", file);
                nerror++;
index 748f687..4198999 100644 (file)
@@ -1,4 +1,4 @@
-static char *sccsid = "@(#)mkfs.c      1.11 (Berkeley) %G%";
+static char *sccsid = "@(#)mkfs.c      1.12 (Berkeley) %G%";
 
 /*
  * make file system for cylinder-group style file systems
 
 /*
  * make file system for cylinder-group style file systems
@@ -18,6 +18,7 @@ static        char *sccsid = "@(#)mkfs.c      1.11 (Berkeley) %G%";
 
 #define UMASK          0755
 #define MAXNDIR                (MAXBSIZE / sizeof(struct direct))
 
 #define UMASK          0755
 #define MAXNDIR                (MAXBSIZE / sizeof(struct direct))
+#define MAXINOPB       (MAXBSIZE / sizeof(struct dinode))
 #define POWEROF2(num)  (((num) & ((num) - 1)) == 0)
 
 union {
 #define POWEROF2(num)  (((num) & ((num) - 1)) == 0)
 
 union {
@@ -296,10 +297,9 @@ main(argc, argv)
                printf("Warning, no super-block backups with only one cylinder group\n");
        else
                printf("\tsuper-block backups (for fsck -b#) at %d+k*%d (%d .. %d)\n",
                printf("Warning, no super-block backups with only one cylinder group\n");
        else
                printf("\tsuper-block backups (for fsck -b#) at %d+k*%d (%d .. %d)\n",
-                   SBLOCK, fsbtodb(&sblock, sblock.fs_fpg),
-                   SBLOCK + fsbtodb(&sblock, sblock.fs_fpg),
-                   SBLOCK + fsbtodb(&sblock, (sblock.fs_ncg - 1) *
-                       sblock.fs_fpg));
+                   SBLOCK, fsbtodb(&sblock, cgsblock(1, &sblock)) - SBLOCK,
+                   fsbtodb(&sblock, cgsblock(1, &sblock)),
+                   fsbtodb(&sblock, cgsblock(sblock.fs_ncg - 1, &sblock)));
        /*
         * Now construct the initial file system,
         * then write out the super-block.
        /*
         * Now construct the initial file system,
         * then write out the super-block.
@@ -548,10 +548,15 @@ rdfs(bno, size, bf)
 {
        int n;
 
 {
        int n;
 
-       lseek(fsi, bno * DEV_BSIZE, 0);
+       if (lseek(fsi, bno * DEV_BSIZE, 0) < 0) {
+               printf("seek error: %ld\n", bno);
+               perror("rdfs");
+               exit(1);
+       }
        n = read(fsi, bf, size);
        if(n != size) {
                printf("read error: %ld\n", bno);
        n = read(fsi, bf, size);
        if(n != size) {
                printf("read error: %ld\n", bno);
+               perror("rdfs");
                exit(1);
        }
 }
                exit(1);
        }
 }
@@ -566,11 +571,16 @@ wtfs(bno, size, bf)
 {
        int n;
 
 {
        int n;
 
-       printf("wtfs: bno %d, size %d, buf %d\n", bno, size, bf);
        lseek(fso, bno * DEV_BSIZE, 0);
        lseek(fso, bno * DEV_BSIZE, 0);
+       if (lseek(fso, bno * DEV_BSIZE, 0) < 0) {
+               printf("seek error: %ld\n", bno);
+               perror("wtfs");
+               exit(1);
+       }
        n = write(fso, bf, size);
        if(n != size) {
                printf("write error: %D\n", bno);
        n = write(fso, bf, size);
        if(n != size) {
                printf("write error: %D\n", bno);
+               perror("wtfs");
                exit(1);
        }
 }
                exit(1);
        }
 }
index 36f6192..91e6126 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1981 Regents of the University of California */
 
 /* Copyright (c) 1981 Regents of the University of California */
 
-char version[] = "@(#)main.c 1.9 %G%";
+char version[] = "@(#)main.c 1.10 %G%";
 
 /*     Modified to include h option (recursively extract all files within
  *     a subtree) and m option (recreate the heirarchical structure of
 
 /*     Modified to include h option (recursively extract all files within
  *     a subtree) and m option (recreate the heirarchical structure of
@@ -507,7 +507,7 @@ ragain:
                         */
                        if (BIT(ROOTINO, clrimap))
                                BIS(LOSTFOUNDINO + 1, clrimap);
                         */
                        if (BIT(ROOTINO, clrimap))
                                BIS(LOSTFOUNDINO + 1, clrimap);
-                       for (ino = 1; ino <= maxi; ino++)
+                       for (ino = ROOTINO; ino <= maxi; ino++)
                                if (BIT(ino, clrimap) == 0) {
                                        if (!iexist(dev, ino))
                                                continue;
                                if (BIT(ino, clrimap) == 0) {
                                        if (!iexist(dev, ino))
                                                continue;
@@ -698,7 +698,7 @@ dcvt(odp, ndp)
        for (itp = inotab[INOHASH(odp->d_ino)]; itp; itp = itp->t_next) {
                if (itp->t_ino != odp->d_ino)
                        continue;
        for (itp = inotab[INOHASH(odp->d_ino)]; itp; itp = itp->t_next) {
                if (itp->t_ino != odp->d_ino)
                        continue;
-               ndp->d_mode = IFDIR;
+               ndp->d_fmt = IFDIR;
                break;
        }
 }
                break;
        }
 }