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