Whamcloud - gitweb
pass2.c (check_dir_block): Do a more paranoid check when trying
authorTheodore Ts'o <tytso@mit.edu>
Sun, 29 Sep 2002 23:30:28 +0000 (19:30 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 29 Sep 2002 23:30:28 +0000 (19:30 -0400)
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.

e2fsck/ChangeLog
e2fsck/pass2.c

index 69c68ec..dccc91f 100644 (file)
@@ -1,5 +1,11 @@
 2002-09-29  Theodore Ts'o  <tytso@mit.edu>
 
+       * 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
index f3f2f9e..e218184 100644 (file)
@@ -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 */