Fix fsck_ffs Pass 1b error exit "bad inode number 256 to nextinode".

Pass 1b of fsck_ffs runs only when Pass 1 has found duplicate blocks.
Pass 1 only knows that a block is duplicate when it finds the second
instance of its use. The role of Pass 1b is to find the first use
of all the duplicate blocks. It makes a pass over the cylinder groups
looking for these blocks. When moving to the next cylinder group,
Pass 1b failed to properly calculate the starting inode number for
the cylinder group resulting in the above error message when it
tried to read the first inode in the cylinder group.

Reported by:  Px
Tested by:    Px
PR:           255979
MFC after:    3 days
Sponsored by: Netflix
This commit is contained in:
Kirk McKusick 2021-05-19 14:38:21 -07:00
parent 71a071be1c
commit fe815b88b5

View File

@ -60,7 +60,6 @@ pass1b(void)
memset(&idesc, 0, sizeof(struct inodesc)); memset(&idesc, 0, sizeof(struct inodesc));
idesc.id_func = pass1bcheck; idesc.id_func = pass1bcheck;
duphead = duplist; duphead = duplist;
inumber = 0;
for (c = 0; c < sblock.fs_ncg; c++) { for (c = 0; c < sblock.fs_ncg; c++) {
if (got_siginfo) { if (got_siginfo) {
printf("%s: phase 1b: cyl group %d of %d (%d%%)\n", printf("%s: phase 1b: cyl group %d of %d (%d%%)\n",
@ -77,6 +76,7 @@ pass1b(void)
if (inosused == 0) if (inosused == 0)
continue; continue;
setinodebuf(c, inosused); setinodebuf(c, inosused);
inumber = c * sblock.fs_ipg;
for (i = 0; i < inosused; i++, inumber++) { for (i = 0; i < inosused; i++, inumber++) {
if (inumber < UFS_ROOTINO) { if (inumber < UFS_ROOTINO) {
(void)getnextinode(inumber, 0); (void)getnextinode(inumber, 0);