From: Theodore Ts'o Date: Sun, 29 Sep 2002 23:30:28 +0000 (-0400) Subject: pass2.c (check_dir_block): Do a more paranoid check when trying X-Git-Tag: E2FSPROGS-1.30-WIP-0930~6 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=e8254bfd3b49cb325a1ff6b21ca86570a1008744;p=tools%2Fe2fsprogs.git pass2.c (check_dir_block): Do a more paranoid check when trying to determine whether or not a directory entry is a completely empty leaf block or leaf node. Otherwise e2fsck might get confused into thinking that a valid dxdir was corrupted. --- diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog index 69c68ec..dccc91f 100644 --- a/e2fsck/ChangeLog +++ b/e2fsck/ChangeLog @@ -1,5 +1,11 @@ 2002-09-29 Theodore Ts'o + * pass2.c (check_dir_block): Do a more paranoid check when trying + to determine whether or not a directory entry is a + completely empty leaf block or leaf node. Otherwise + e2fsck might get confused into thinking that a valid dxdir + was corrupted. + * rehash.c (e2fsck_rehash_dir): Apply patch from Christopher Li which avoids creating an empty directory entry at the end of the directory block. This screws up earlier versions diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c index f3f2f9e..e218184 100644 --- a/e2fsck/pass2.c +++ b/e2fsck/pass2.c @@ -645,6 +645,7 @@ static int check_dir_block(ext2_filsys fs, e2fsck_t ctx; int problem; struct ext2_dx_root_info *root; + struct ext2_dx_countlimit *limit; cd = (struct check_dir_struct *) priv_data; buf = cd->buf; @@ -710,6 +711,7 @@ static int check_dir_block(ext2_filsys fs, dx_db->max_hash = 0; dirent = (struct ext2_dir_entry *) buf; + limit = (struct ext2_dx_countlimit *) (buf+8); if (db->blockcnt == 0) { root = (struct ext2_dx_root_info *) (buf + 24); dx_db->type = DX_DIRBLOCK_ROOT; @@ -724,7 +726,10 @@ static int check_dir_block(ext2_filsys fs, } dx_dir->hashversion = root->hash_version; } else if ((dirent->inode == 0) && - (dirent->rec_len == fs->blocksize)) + (dirent->rec_len == fs->blocksize) && + (dirent->name_len == 0) && + (limit->limit == ((fs->blocksize-8) / + sizeof(struct ext2_dx_entry)))) dx_db->type = DX_DIRBLOCK_NODE; } #endif /* ENABLE_HTREE */