Home | History | Annotate | Line # | Download | only in fsck_lfs
pass5.c revision 1.3
      1  1.3  perseant /*	$NetBSD: pass5.c,v 1.3 2000/05/16 04:55:59 perseant Exp $	*/
      2  1.1  perseant 
      3  1.1  perseant #include <sys/param.h>
      4  1.1  perseant #include <sys/time.h>
      5  1.1  perseant #include <ufs/ufs/dinode.h>
      6  1.3  perseant #include <ufs/ufs/dir.h>
      7  1.3  perseant #include <sys/mount.h>
      8  1.3  perseant #include <ufs/lfs/lfs.h>
      9  1.3  perseant 
     10  1.1  perseant #include <string.h>
     11  1.1  perseant #include "fsck.h"
     12  1.1  perseant #include "extern.h"
     13  1.3  perseant #include "fsutil.h"
     14  1.3  perseant 
     15  1.3  perseant extern SEGUSE *seg_table;
     16  1.1  perseant 
     17  1.1  perseant void
     18  1.1  perseant pass5()
     19  1.1  perseant {
     20  1.3  perseant 	SEGUSE *su;
     21  1.3  perseant 	struct bufarea *bp;
     22  1.3  perseant 	int i;
     23  1.3  perseant 
     24  1.3  perseant 	/*
     25  1.3  perseant 	 * Check segment holdings against actual holdings.  Check for
     26  1.3  perseant 	 * "clean" segments that contain live data.
     27  1.3  perseant 	 */
     28  1.3  perseant 	for(i=0; i < sblock.lfs_nseg; i++) {
     29  1.3  perseant 		su = lfs_gseguse(i, &bp);
     30  1.3  perseant 		if (!(su->su_flags & SEGUSE_DIRTY) &&
     31  1.3  perseant 		    seg_table[i].su_nbytes>0)
     32  1.3  perseant 		{
     33  1.3  perseant 			pwarn("%d bytes contained in 'clean' segment %d\n",
     34  1.3  perseant 			      seg_table[i].su_nbytes, i);
     35  1.3  perseant 			if(preen || reply("fix")) {
     36  1.3  perseant 				su->su_flags |= SEGUSE_DIRTY;
     37  1.3  perseant 				dirty(bp);
     38  1.3  perseant 			}
     39  1.3  perseant 		}
     40  1.3  perseant 		if ((su->su_flags & SEGUSE_DIRTY) &&
     41  1.3  perseant 		    su->su_nbytes != seg_table[i].su_nbytes)
     42  1.3  perseant 		{
     43  1.3  perseant 			pwarn("segment %d claims %d bytes but has %d\n",
     44  1.3  perseant 			      i, su->su_nbytes, seg_table[i].su_nbytes);
     45  1.3  perseant 			if(preen || reply("fix")) {
     46  1.3  perseant 				su->su_nbytes = seg_table[i].su_nbytes;
     47  1.3  perseant 				dirty(bp);
     48  1.1  perseant 			}
     49  1.1  perseant 		}
     50  1.3  perseant 		bp->b_flags &= ~B_INUSE;
     51  1.1  perseant 	}
     52  1.1  perseant }
     53