diff --git a/inode.c b/inode.c index 4c8dc02..ffa8412 100644 --- a/inode.c +++ b/inode.c @@ -186,7 +186,17 @@ static int __file_lookup(struct inode *dir, *fi = _fi; return 0; } - _fi += dblock->files[_fi].nr_blk; + if (!dblock->files[_fi].nr_blk) { + /* + this means the _ei and _bi we're looking for is looking at + an empty block. we have to advance nontheless, but nr_blk + would just add 0 to fi, causing endless loop. so we skip + this entry by 1, just in case. + */ + _fi += 1; + } else { + _fi += dblock->files[_fi].nr_blk; + } } RELEASE_BUFFER_HEAD(*ret_bi_bh); }