From e02bc28aaf0acd21195914dc1f116651ade2b7b5 Mon Sep 17 00:00:00 2001 From: spew Date: Mon, 27 Mar 2017 17:57:10 -0500 Subject: [PATCH] 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 --- sys/src/cmd/hjfs/check.c | 6 ++++-- sys/src/cmd/hjfs/cons.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sys/src/cmd/hjfs/check.c b/sys/src/cmd/hjfs/check.c index edb11b75e..4e540e70c 100644 --- a/sys/src/cmd/hjfs/check.c +++ b/sys/src/cmd/hjfs/check.c @@ -16,14 +16,16 @@ checkdir(FLoc *l, Buf *b) 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"); } } diff --git a/sys/src/cmd/hjfs/cons.c b/sys/src/cmd/hjfs/cons.c index e2bff60ba..b8b9278f1 100644 --- a/sys/src/cmd/hjfs/cons.c +++ b/sys/src/cmd/hjfs/cons.c @@ -127,7 +127,7 @@ cmdcheck(int, char**) continue; } for(j = 0; j < REFPERBLK; j++, blk++) - if(b->refs[j] == 0) + if(b->refs[j] > 0) checkblk(blk); putbuf(b); }