386BSD 0.1 development
[unix-history] / usr / src / sbin / fsck / pass5.c
index 933ed33..8c4d2aa 100644 (file)
@@ -1,16 +1,44 @@
 /*
 /*
- * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+ * Copyright (c) 1980, 1986 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)pass5.c    5.9 (Berkeley) %G%";
-#endif not lint
+static char sccsid[] = "@(#)pass5.c    5.13 (Berkeley) 7/20/90";
+#endif /* not lint */
 
 #include <sys/param.h>
 #include <ufs/dinode.h>
 #include <ufs/fs.h>
 
 #include <sys/param.h>
 #include <ufs/dinode.h>
 #include <ufs/fs.h>
+#include <string.h>
 #include "fsck.h"
 
 pass5()
 #include "fsck.h"
 
 pass5()
@@ -29,7 +57,7 @@ pass5()
        register struct cg *newcg = (struct cg *)buf;
        struct ocg *ocg = (struct ocg *)buf;
 
        register struct cg *newcg = (struct cg *)buf;
        struct ocg *ocg = (struct ocg *)buf;
 
-       bzero((char *)newcg, (int)fs->fs_cgsize);
+       bzero((char *)newcg, (size_t)fs->fs_cgsize);
        newcg->cg_niblk = fs->fs_ipg;
        switch ((int)fs->fs_postblformat) {
 
        newcg->cg_niblk = fs->fs_ipg;
        switch ((int)fs->fs_postblformat) {
 
@@ -70,7 +98,8 @@ pass5()
                idesc[i].id_type = ADDR;
        bzero((char *)&cstotal, sizeof(struct csum));
        (void)time(&now);
                idesc[i].id_type = ADDR;
        bzero((char *)&cstotal, sizeof(struct csum));
        (void)time(&now);
-       for (i = fs->fs_size; i < fragroundup(fs, fs->fs_size); i++)
+       j = blknum(fs, fs->fs_size + fs->fs_frag - 1);
+       for (i = fs->fs_size; i < j; i++)
                setbmap(i);
        for (c = 0; c < fs->fs_ncg; c++) {
                getblk(&cgblk, cgtod(fs, c), fs->fs_cgsize);
                setbmap(i);
        for (c = 0; c < fs->fs_ncg; c++) {
                getblk(&cgblk, cgtod(fs, c), fs->fs_cgsize);
@@ -107,7 +136,8 @@ pass5()
                else
                        newcg->cg_irotor = 0;
                bzero((char *)&newcg->cg_frsum[0], sizeof newcg->cg_frsum);
                else
                        newcg->cg_irotor = 0;
                bzero((char *)&newcg->cg_frsum[0], sizeof newcg->cg_frsum);
-               bzero((char *)&cg_blktot(newcg)[0], sumsize + mapsize);
+               bzero((char *)&cg_blktot(newcg)[0],
+                     (size_t)(sumsize + mapsize));
                if (fs->fs_postblformat == FS_42POSTBLFMT)
                        ocg->cg_magic = CG_MAGIC;
                j = fs->fs_ipg * c;
                if (fs->fs_postblformat == FS_42POSTBLFMT)
                        ocg->cg_magic = CG_MAGIC;
                j = fs->fs_ipg * c;
@@ -173,23 +203,24 @@ pass5()
                        sbdirty();
                }
                if (cvtflag) {
                        sbdirty();
                }
                if (cvtflag) {
-                       bcopy((char *)newcg, (char *)cg, (int)fs->fs_cgsize);
+                       bcopy((char *)newcg, (char *)cg, (size_t)fs->fs_cgsize);
                        cgdirty();
                        continue;
                }
                if (bcmp(cg_inosused(newcg),
                         cg_inosused(cg), mapsize) != 0 &&
                    dofix(&idesc[1], "BLK(S) MISSING IN BIT MAPS")) {
                        cgdirty();
                        continue;
                }
                if (bcmp(cg_inosused(newcg),
                         cg_inosused(cg), mapsize) != 0 &&
                    dofix(&idesc[1], "BLK(S) MISSING IN BIT MAPS")) {
-                       bcopy(cg_inosused(newcg), cg_inosused(cg), mapsize);
+                       bcopy(cg_inosused(newcg), cg_inosused(cg),
+                             (size_t)mapsize);
                        cgdirty();
                }
                if ((bcmp((char *)newcg, (char *)cg, basesize) != 0 ||
                     bcmp((char *)&cg_blktot(newcg)[0],
                          (char *)&cg_blktot(cg)[0], sumsize) != 0) &&
                    dofix(&idesc[2], "SUMMARY INFORMATION BAD")) {
                        cgdirty();
                }
                if ((bcmp((char *)newcg, (char *)cg, basesize) != 0 ||
                     bcmp((char *)&cg_blktot(newcg)[0],
                          (char *)&cg_blktot(cg)[0], sumsize) != 0) &&
                    dofix(&idesc[2], "SUMMARY INFORMATION BAD")) {
-                       bcopy((char *)newcg, (char *)cg, basesize);
+                       bcopy((char *)newcg, (char *)cg, (size_t)basesize);
                        bcopy((char *)&cg_blktot(newcg)[0],
                        bcopy((char *)&cg_blktot(newcg)[0],
-                             (char *)&cg_blktot(cg)[0], sumsize);
+                             (char *)&cg_blktot(cg)[0], (size_t)sumsize);
                        cgdirty();
                }
        }
                        cgdirty();
                }
        }