Subject: Re: FFS reliability problems
To: None <tech-kern@netbsd.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-kern
Date: 06/10/2002 19:25:38
> Der Mouse already has such a patch.

> Please note the context of the word "trivial", i.e. "in comparison to
> the code already there."

Here is the core of the patch.  All other changes are argument parsing
and such to deal with the zflag variable:

/*	$NetBSD: pass4.c,v 1.14 1997/09/20 06:16:32 lukem Exp $	*/
--- OLD/sbin/fsck_ffs/pass4.c	Thu Jan  1 00:00:00 1970
+++ NEW/sbin/fsck_ffs/pass4.c	Thu Jan  1 00:00:00 1970
@@ -84,7 +84,11 @@
 						zlnp = zlnhead;
 						zlnhead = zlnhead->next;
 						free((char *)zlnp);
-						clri(&idesc, "UNREF", 1);
+						if ( !zflag ||
+						     ((dp=ginode(inumber))->di_size == 0) ||
+						     !linkup(inumber,(ino_t)0) ||
+						     ((dp->di_nlink=iswap16(1)),inodirty(),0) )
+							clri(&idesc, "UNREF", 1);
 						break;
 					}
 			}

The control structure is admittedly a bit ugly and probably should be
cleaned up.

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse@rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B