diff --git a/sys/fs/ext2fs/ext2_lookup.c b/sys/fs/ext2fs/ext2_lookup.c --- a/sys/fs/ext2fs/ext2_lookup.c +++ b/sys/fs/ext2fs/ext2_lookup.c @@ -539,8 +539,8 @@ if (entryoffsetinblock + EXT2_DIR_REC_LEN(ep->e2d_namlen) > dp->i_size) { ext2_dirbad(dp, i_offset, "i_size too small"); - dp->i_size = entryoffsetinblock + EXT2_DIR_REC_LEN(ep->e2d_namlen); - dp->i_flag |= IN_CHANGE | IN_UPDATE; + brelse(bp); + return (EIO); } brelse(bp); @@ -802,13 +802,9 @@ struct mount *mp; mp = ITOV(ip)->v_mount; - if ((mp->mnt_flag & MNT_RDONLY) == 0) - panic("ext2_dirbad: %s: bad dir ino %ju at offset %ld: %s\n", - mp->mnt_stat.f_mntonname, (uintmax_t)ip->i_number, - (long)offset, how); - else - SDT_PROBE4(ext2fs, , trace, ext2_dirbad_error, - mp->mnt_stat.f_mntonname, ip->i_number, offset, how); + + SDT_PROBE4(ext2fs, , trace, ext2_dirbad_error, + mp->mnt_stat.f_mntonname, ip->i_number, offset, how); } /* diff --git a/sys/fs/ext2fs/ext2_vnops.c b/sys/fs/ext2fs/ext2_vnops.c --- a/sys/fs/ext2fs/ext2_vnops.c +++ b/sys/fs/ext2fs/ext2_vnops.c @@ -1088,6 +1088,15 @@ if (namlen != 2 || dirbuf->dotdot_name[0] != '.' || dirbuf->dotdot_name[1] != '.') { + /* + * The filesystem is in corrupted state, + * need to run fsck to fix mangled dir + * entry. From other side this error + * need to be ignored because it is + * too difficult to revert directories + * to state before rename from this + * point. + */ ext2_dirbad(xp, (doff_t)12, "rename: mangled dir"); } else {