BSD 4_4 release
[unix-history] / usr / src / sbin / fsck / pass5.c
index 3bb7495..9feb700 100644 (file)
@@ -1,29 +1,44 @@
 /*
 /*
- * Copyright (c) 1980, 1986 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1980, 1986, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  *
- * Redistribution and use in source and binary forms are permitted provided
- * that: (1) source distributions retain this entire copyright notice and
- * comment, and (2) distributions including binaries display the following
- * acknowledgement:  ``This product includes software developed by the
- * University of California, Berkeley and its contributors'' in the
- * documentation or other materials provided with the distribution and in
- * all advertising materials mentioning features or use of this software.
- * 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * 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.13 (Berkeley) 7/20/90";
+static char sccsid[] = "@(#)pass5.c    8.1 (Berkeley) 6/5/93";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
-#include <ufs/dinode.h>
-#include <ufs/fs.h>
+#include <sys/time.h>
+#include <ufs/ufs/dinode.h>
+#include <ufs/ffs/fs.h>
 #include <string.h>
 #include "fsck.h"
 
 #include <string.h>
 #include "fsck.h"
 
@@ -36,7 +51,6 @@ pass5()
        register daddr_t d;
        register long i, j;
        struct csum *cs;
        register daddr_t d;
        register long i, j;
        struct csum *cs;
-       time_t now;
        struct csum cstotal;
        struct inodesc idesc[3];
        char buf[MAXBSIZE];
        struct csum cstotal;
        struct inodesc idesc[3];
        char buf[MAXBSIZE];
@@ -80,10 +94,12 @@ pass5()
                        fs->fs_postblformat);
        }
        bzero((char *)&idesc[0], sizeof idesc);
                        fs->fs_postblformat);
        }
        bzero((char *)&idesc[0], sizeof idesc);
-       for (i = 0; i < 3; i++)
+       for (i = 0; i < 3; i++) {
                idesc[i].id_type = ADDR;
                idesc[i].id_type = ADDR;
+               if (doinglevel2)
+                       idesc[i].id_fix = FIX;
+       }
        bzero((char *)&cstotal, sizeof(struct csum));
        bzero((char *)&cstotal, sizeof(struct csum));
-       (void)time(&now);
        j = blknum(fs, fs->fs_size + fs->fs_frag - 1);
        for (i = fs->fs_size; i < j; i++)
                setbmap(i);
        j = blknum(fs, fs->fs_size + fs->fs_frag - 1);
        for (i = fs->fs_size; i < j; i++)
                setbmap(i);
@@ -95,10 +111,7 @@ pass5()
                dmax = dbase + fs->fs_fpg;
                if (dmax > fs->fs_size)
                        dmax = fs->fs_size;
                dmax = dbase + fs->fs_fpg;
                if (dmax > fs->fs_size)
                        dmax = fs->fs_size;
-               if (now > cg->cg_time)
-                       newcg->cg_time = cg->cg_time;
-               else
-                       newcg->cg_time = now;
+               newcg->cg_time = cg->cg_time;
                newcg->cg_cgx = c;
                if (c == fs->fs_ncg - 1)
                        newcg->cg_ncyl = fs->fs_ncyl % fs->fs_cpg;
                newcg->cg_cgx = c;
                if (c == fs->fs_ncg - 1)
                        newcg->cg_ncyl = fs->fs_ncyl % fs->fs_cpg;
@@ -175,7 +188,7 @@ pass5()
                        } else if (frags > 0) {
                                newcg->cg_cs.cs_nffree += frags;
                                blk = blkmap(fs, cg_blksfree(newcg), i);
                        } else if (frags > 0) {
                                newcg->cg_cs.cs_nffree += frags;
                                blk = blkmap(fs, cg_blksfree(newcg), i);
-                               fragacct(fs, blk, newcg->cg_frsum, 1);
+                               ffs_fragacct(fs, blk, newcg->cg_frsum, 1);
                        }
                }
                cstotal.cs_nffree += newcg->cg_cs.cs_nffree;
                        }
                }
                cstotal.cs_nffree += newcg->cg_cs.cs_nffree;
@@ -188,7 +201,7 @@ pass5()
                        bcopy((char *)&newcg->cg_cs, (char *)cs, sizeof *cs);
                        sbdirty();
                }
                        bcopy((char *)&newcg->cg_cs, (char *)cs, sizeof *cs);
                        sbdirty();
                }
-               if (cvtflag) {
+               if (doinglevel1) {
                        bcopy((char *)newcg, (char *)cg, (size_t)fs->fs_cgsize);
                        cgdirty();
                        continue;
                        bcopy((char *)newcg, (char *)cg, (size_t)fs->fs_cgsize);
                        cgdirty();
                        continue;