diff options
author | Theodore Ts'o <tytso@mit.edu> | 2004-12-16 20:13:45 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2004-12-16 20:13:45 -0500 |
commit | e75cfc5da83c749be43f87c0ccf5ec1f1dd26e2c (patch) | |
tree | dcc5719e79f4665ca05a98942ae670e5476d211b /e2fsck/super.c | |
parent | 1b4cd9c7464d5bd0f5b416c7303bcc827e312473 (diff) | |
download | e2fsprogs-e75cfc5da83c749be43f87c0ccf5ec1f1dd26e2c.tar.gz |
Fix e2fsck so that it will clean up filesystesm that have the
resize_inode capability disabled, but which still have the
s_reserved_gdt_blocks field set in the superblock, or which
still have blocks in the inode #7 (the resize inode).
Diffstat (limited to 'e2fsck/super.c')
-rw-r--r-- | e2fsck/super.c | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/e2fsck/super.c b/e2fsck/super.c index 9a1ab4c0..11ab7c9a 100644 --- a/e2fsck/super.c +++ b/e2fsck/super.c @@ -325,6 +325,7 @@ void check_super_block(e2fsck_t ctx) dgrp_t i; blk_t should_be; struct problem_context pctx; + struct ext2_inode inode; __u32 free_blocks = 0, free_inodes = 0; inodes_per_block = EXT2_INODES_PER_BLOCK(fs->super); @@ -541,6 +542,39 @@ void check_super_block(e2fsck_t ctx) ext2fs_mark_super_dirty(fs); } + /* + * If the resize inode feature isn't set, then + * s_reserved_gdt_blocks must be zero, and the resize inode + * must be cleared. + */ + if (!(fs->super->s_feature_compat & + EXT2_FEATURE_COMPAT_RESIZE_INODE)) { + if (fs->super->s_reserved_gdt_blocks) { + pctx.num = fs->super->s_reserved_gdt_blocks; + if (fix_problem(ctx, PR_0_NONZERO_RESERVED_GDT_BLOCKS, + &pctx)) { + fs->super->s_reserved_gdt_blocks = 0; + ext2fs_mark_super_dirty(fs); + } + } + e2fsck_read_inode(ctx, EXT2_RESIZE_INO, &inode, + "check_resize"); + for (i=0; i < EXT2_N_BLOCKS; i++) { + if (inode.i_block[i]) + break; + } + pctx.ino = EXT2_RESIZE_INO; + if ((i < EXT2_N_BLOCKS) && + fix_problem(ctx, PR_0_CLEAR_RESIZE_INODE, &pctx)) { + for (i=0; i < EXT2_N_BLOCKS; i++) { + inode.i_block[i] = 0; + } + inode.i_blocks = 0; + e2fsck_write_inode(ctx, EXT2_RESIZE_INO, &inode, + "clear_resize"); + } + } + /* * Clean up any orphan inodes, if present. */ @@ -555,5 +589,3 @@ void check_super_block(e2fsck_t ctx) e2fsck_move_ext3_journal(ctx); return; } - - |