git: 3286a8dc8382 - releng/13.0 - fsck_ffs: fix bad inode number errors

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Tue, 11 Jan 2022 18:14:57 UTC
The branch releng/13.0 has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=3286a8dc83829bf183284290dd59f82ba389a066

commit 3286a8dc83829bf183284290dd59f82ba389a066
Author:     Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2021-03-24 23:50:24 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2022-01-10 14:51:48 +0000

    fsck_ffs: fix bad inode number errors
    
    Fix fsck_ffs Pass 1b error exit "bad inode number 2 to nextinode".
    
    (cherry picked from commit bc444e2ec6e6cc9d96d35ab7ce3c02c0da952fad)
    (cherry picked from commit fab7c18ce3229d53b732fdfdbb6e9a1a1c72739a)
    
    Fix fsck_ffs Pass 1b error exit "bad inode number 256 to nextinode".
    
    (cherry picked from commit fe815b88b553667c40353c46b58f9779efa3570e)
    
    PR:           255979
    Sponsored by: Netflix
    
    (cherry picked from commit e198c1dc8f6faaa85bd20990d15e3bcb9d081873)
    
    Approved by:    so
    Errata:         FreeBSD-EN-22:01.fsck_ffs
---
 sbin/fsck_ffs/pass1b.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sbin/fsck_ffs/pass1b.c b/sbin/fsck_ffs/pass1b.c
index 8c09ef36acad..17a3b6495dc4 100644
--- a/sbin/fsck_ffs/pass1b.c
+++ b/sbin/fsck_ffs/pass1b.c
@@ -60,7 +60,6 @@ pass1b(void)
 	memset(&idesc, 0, sizeof(struct inodesc));
 	idesc.id_func = pass1bcheck;
 	duphead = duplist;
-	inumber = 0;
 	for (c = 0; c < sblock.fs_ncg; c++) {
 		if (got_siginfo) {
 			printf("%s: phase 1b: cyl group %d of %d (%d%%)\n",
@@ -77,9 +76,12 @@ pass1b(void)
 		if (inosused == 0)
 			continue;
 		setinodebuf(c, inosused);
+		inumber = c * sblock.fs_ipg;
 		for (i = 0; i < inosused; i++, inumber++) {
-			if (inumber < UFS_ROOTINO)
+			if (inumber < UFS_ROOTINO) {
+				(void)getnextinode(inumber, 0);
 				continue;
+			}
 			dp = getnextinode(inumber, 0);
 			idesc.id_number = inumber;
 			idesc.id_type = inoinfo(inumber)->ino_idtype;