Whamcloud - gitweb
ChangeLog, problem.c, problem.h, super.c:
authorTheodore Ts'o <tytso@mit.edu>
Fri, 18 Jun 1999 01:09:29 +0000 (01:09 +0000)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 18 Jun 1999 01:09:29 +0000 (01:09 +0000)
  problem.c, problem.h (PR_0_INODE_COUNT_WRONG): Add new problem code.
  super.c (check_super_block): Add check to make sure the total number
   of inodes is sane, since this can be calculated from the number of
   groups times the number of inodes per group.  Offer to correct it if
   it is incorrect.

e2fsck/ChangeLog
e2fsck/problem.c
e2fsck/problem.h
e2fsck/super.c

index c4c103d..3752671 100644 (file)
@@ -1,3 +1,13 @@
+1999-05-22    <tytso@rsts-11.mit.edu>
+
+       * problem.c, problem.h (PR_0_INODE_COUNT_WRONG): Add new problem
+               code. 
+       
+       * super.c (check_super_block): Add check to make sure the total
+               number of inodes is sane, since this can be calculated
+               from the number of groups times the number of inodes per
+               group.   Offer to correct it if it is incorrect.
+
 1999-03-19    <tytso@rsts-11.mit.edu>
 
        * pass5.c (check_block_end): Fix fencepost condition where when
index 6811826..e7a0dc6 100644 (file)
@@ -164,6 +164,11 @@ static const struct e2fsck_problem problem_table[] = {
        { PR_0_GETSIZE_ERROR,     
          "Error determining size of the physical device: %m\n",
          PROMPT_NONE, PR_FATAL },
+
+       /* Inode count in superblock is incorrect */
+       { PR_0_INODE_COUNT_WRONG,
+         "@i count in @S is %i, should be %j\n",
+         PROMPT_FIX, 0 },
                  
        /* Pass 1 errors */
        
index 240bd7a..1e21440 100644 (file)
@@ -88,6 +88,9 @@ struct problem_context {
 /* Error determing physical device size of filesystem */
 #define PR_0_GETSIZE_ERROR     0x00000C
 
+/* Inode count in the superblock incorrect */
+#define PR_0_INODE_COUNT_WRONG 0x00000D
+
 /*
  * Pass 1 errors
  */
index ce33c3a..66a8eb5 100644 (file)
@@ -138,6 +138,16 @@ void check_super_block(e2fsck_t ctx)
                return;
        }
 
+       should_be = s->s_inodes_per_group * fs->group_desc_count;
+       if (s->s_inodes_count != should_be) {
+               pctx.ino = s->s_inodes_count;
+               pctx.ino2 = should_be;
+               if (fix_problem(ctx, PR_0_INODE_COUNT_WRONG, &pctx)) {
+                       s->s_inodes_count = should_be;
+                       ext2fs_mark_super_dirty(fs);
+               }
+       }
+
        /*
         * Verify the group descriptors....
         */