shithub: riscv

Download patch

ref: e02bc28aaf0acd21195914dc1f116651ade2b7b5
parent: 4671df38fe8b526e7f72c494e093563e1d744d74
author: spew <devnull@localhost>
date: Mon Mar 27 13:57:10 EDT 2017

hjfs: check: check a block if its ref count is _not_ zero. Also check all the ref counts of blocks of a directory and clean up messages

--- a/sys/src/cmd/hjfs/check.c
+++ b/sys/src/cmd/hjfs/check.c
@@ -16,14 +16,16 @@
 	d = getdent(l, b);
 	for(i = 0; i < d->size; i++){
 		if(getblk(fsmain, l, b, i, &r, GBREAD) <= 0) {
-			dprint("hjfs: directory %s in block %ulld at index %d has a bad block reference at %ulld\n", d->name, l->blk, l->deind, i);
+			dprint("hjfs: directory in block %ulld at index %d has a bad block %ulld at directory index %ulld\n", l->blk, l->deind, r, i);
 			continue;
 		}
 		c = getbuf(fsmain->d, r, TDENTRY, 0);
 		if(c == nil) {
-			dprint("hjfs: directory %s in block %ulld at index %d has a block %ulld that is not a directory entry\n", d->name, l->blk, l->deind, i);
+			dprint("hjfs: directory in block %ulld at index %d has a block %ulld at directory index %ulld that is not a directory entry\n", l->blk, l->deind, r, i);
 			continue;
 		}
+		if(chref(fsmain, r, 0) == 0)
+			dprint("hjfs: directory in block %ulld at index %d has a block %ulld at index %ulld whose reference count is 0");
 	}
 }
 
--- a/sys/src/cmd/hjfs/cons.c
+++ b/sys/src/cmd/hjfs/cons.c
@@ -127,7 +127,7 @@
 			continue;
 		}
 		for(j = 0; j < REFPERBLK; j++, blk++)
-			if(b->refs[j] == 0)
+			if(b->refs[j] > 0)
 				checkblk(blk);
 		putbuf(b);
 	}