Hello all.

I while back I put an ext2 rev1 filesystem on my disk (not sure why
any more, but oh well). Whenever fsck ran, it stopped during pass2 with
the error message "wrong type to dirscan 0".

Long story short, it seems that a call to memset was writing zeros over
the curino structure because the rev1 inode structure takes up 256 bytes
on disk but only 156 in memory. I assume that the patch below (which
worked fine on my machine), would also work for anyone with a rev0 ext2
fs since there is only one ext2fs_dinode structure for all of
fsck_ext2fs.

Does that make sense? I could give more info, but I don't want to be
pedantic, and I assume most people looking at this know more than I do.

Chris



Index: pass2.c
===================================================================
RCS file: /cvs/src/sbin/fsck_ext2fs/pass2.c,v
retrieving revision 1.15
diff -u -p -r1.15 pass2.c
--- pass2.c     28 Apr 2016 12:17:15 -0000      1.15
+++ pass2.c     17 Dec 2019 17:49:51 -0000
@@ -145,7 +145,7 @@ pass2(void)
                                inodirty();
                        }
                }
-               memset(&dino, 0, EXT2_DINODE_SIZE(&sblock));
+               memset(&dino, 0, sizeof(struct ext2fs_dinode));
                dino.e2di_mode = htole16(IFDIR);
                inossize(&dino, inp->i_isize);
                memcpy(&dino.e2di_blocks[0], &inp->i_blks[0], 
(size_t)inp->i_numblks);






Reply via email to