On Tue, 17 Dec 2019 18:11:17 +0000, Chris Waddey wrote:
> 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.
Yes, that looks correct, though I would just use sizeof(dino) instead.
E.g.
Index: sbin/fsck_ext2fs/pass2.c
===================================================================
RCS file: /cvs/src/sbin/fsck_ext2fs/pass2.c,v
retrieving revision 1.15
diff -u -p -u -r1.15 pass2.c
--- sbin/fsck_ext2fs/pass2.c 28 Apr 2016 12:17:15 -0000 1.15
+++ sbin/fsck_ext2fs/pass2.c 17 Dec 2019 18:26:24 -0000
@@ -145,7 +145,7 @@ pass2(void)
inodirty();
}
}
- memset(&dino, 0, EXT2_DINODE_SIZE(&sblock));
+ memset(&dino, 0, sizeof(dino));
dino.e2di_mode = htole16(IFDIR);
inossize(&dino, inp->i_isize);
memcpy(&dino.e2di_blocks[0], &inp->i_blks[0],
(size_t)inp->i_numblks);