Whamcloud - gitweb
ChangeLog, super.c:
authorTheodore Ts'o <tytso@mit.edu>
Wed, 20 Oct 1999 18:29:18 +0000 (18:29 +0000)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 20 Oct 1999 18:29:18 +0000 (18:29 +0000)
  super.c (check_super_block): Check to see whether the inodes_per_group
   value in the superblock is insanely too high.

e2fsck/ChangeLog
e2fsck/super.c

index 52a93ad..28960be 100644 (file)
                inode block count and size files so that the block count
                field is updated correctly when we create an indirect block.
 
+1999-08-05    <tytso@valinux.com>
+
+       * super.c (check_super_block): Check to see whether the
+               inodes_per_group value in the superblock is insanely too
+               high.
+
 1999-08-02    <tytso@valinux.com>
 
        * pass1b.c (clone_file_block): Don't clear the dup_map flag if
index 66a8eb5..962dd81 100644 (file)
@@ -57,9 +57,14 @@ void check_super_block(e2fsck_t ctx)
        blk_t   first_block, last_block;
        struct ext2fs_sb *s = (struct ext2fs_sb *) fs->super;
        blk_t   blocks_per_group = fs->super->s_blocks_per_group;
+       int     inodes_per_block;
        dgrp_t  i;
        blk_t   should_be;
        struct problem_context  pctx;
+       
+       inodes_per_block = (EXT2_INODE_SIZE(fs->super) + 
+                           EXT2_BLOCK_SIZE(fs->super) - 1) /
+                                   EXT2_BLOCK_SIZE(fs->super);
 
        ctx->invalid_inode_bitmap_flag = (int *) e2fsck_allocate_memory(ctx,
                 sizeof(int) * fs->group_desc_count, "invalid_inode_bitmap");
@@ -89,7 +94,8 @@ void check_super_block(e2fsck_t ctx)
        check_super_value(ctx, "blocks_per_group", s->s_blocks_per_group,
                          MIN_CHECK | MAX_CHECK, 1, 8 * EXT2_BLOCK_SIZE(s));
        check_super_value(ctx, "inodes_per_group", s->s_inodes_per_group,
-                         MIN_CHECK, 1, 0);
+                         MIN_CHECK | MAX_CHECK, 1,
+                         inodes_per_block * blocks_per_group);
        check_super_value(ctx, "r_blocks_count", s->s_r_blocks_count,
                          MAX_CHECK, 0, s->s_blocks_count);