From 12b335607eed21dcb11828bfd307d95c18b6c8bd Mon Sep 17 00:00:00 2001 From: Eric Kim Date: Sat, 20 Jun 2026 00:37:25 +0900 Subject: [PATCH 1/3] fix: ensure forward progress in __file_lookup when nr_blk = 0 --- inode.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/inode.c b/inode.c index 4c8dc02..4a7cd1e 100644 --- a/inode.c +++ b/inode.c @@ -186,6 +186,14 @@ static int __file_lookup(struct inode *dir, *fi = _fi; return 0; } + 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; + } _fi += dblock->files[_fi].nr_blk; } RELEASE_BUFFER_HEAD(*ret_bi_bh); From 9b04f7bed73d295f22b2f328a4d890317c7aaf5c Mon Sep 17 00:00:00 2001 From: Eric Kim Date: Sat, 20 Jun 2026 00:57:48 +0900 Subject: [PATCH 2/3] fixing coding style conventions --- inode.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/inode.c b/inode.c index 4a7cd1e..94825bd 100644 --- a/inode.c +++ b/inode.c @@ -186,11 +186,12 @@ static int __file_lookup(struct inode *dir, *fi = _fi; return 0; } - if(!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. + 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; } From 444918aa0440f488f01da7b8e990867f00bd667d Mon Sep 17 00:00:00 2001 From: Eric Kim Date: Sat, 20 Jun 2026 00:59:58 +0900 Subject: [PATCH 3/3] cleaning up code --- inode.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/inode.c b/inode.c index 94825bd..ffa8412 100644 --- a/inode.c +++ b/inode.c @@ -186,16 +186,17 @@ static int __file_lookup(struct inode *dir, *fi = _fi; return 0; } - if(!dblock->files[_fi].nr_blk) { + if (!dblock->files[_fi].nr_blk) { /* - this means the _ei and _bi we're looking for is looking at + 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; } - _fi += dblock->files[_fi].nr_blk; } RELEASE_BUFFER_HEAD(*ret_bi_bh); }