Whamcloud - gitweb
Fixed missing not_fixed branch in e2fsck so that if the frag size field in
[tools/e2fsprogs.git] / e2fsck / e2fsck.c
index 77e0e2e..2a84c51 100644 (file)
@@ -22,14 +22,14 @@ errcode_t e2fsck_allocate_context(e2fsck_t *ret)
        e2fsck_t        context;
        errcode_t       retval;
 
-       retval = ext2fs_get_mem(sizeof(struct e2fsck_struct),
-                               (void **) &context);
+       retval = ext2fs_get_mem(sizeof(struct e2fsck_struct), &context);
        if (retval)
                return retval;
        
        memset(context, 0, sizeof(struct e2fsck_struct));
 
        context->process_inode_size = 256;
+       context->ext_attr_ver = 2;
 
        *ret = context;
        return 0;
@@ -42,6 +42,8 @@ errcode_t e2fsck_allocate_context(e2fsck_t *ret)
 errcode_t e2fsck_reset_context(e2fsck_t ctx)
 {
        ctx->flags = 0;
+       ctx->lost_and_found = 0;
+       ctx->bad_lost_and_found = 0;
        if (ctx->inode_used_map) {
                ext2fs_free_inode_bitmap(ctx->inode_used_map);
                ctx->inode_used_map = 0;
@@ -50,6 +52,10 @@ errcode_t e2fsck_reset_context(e2fsck_t ctx)
                ext2fs_free_inode_bitmap(ctx->inode_dir_map);
                ctx->inode_dir_map = 0;
        }
+       if (ctx->inode_reg_map) {
+               ext2fs_free_inode_bitmap(ctx->inode_reg_map);
+               ctx->inode_reg_map = 0;
+       }
        if (ctx->block_found_map) {
                ext2fs_free_block_bitmap(ctx->block_found_map);
                ctx->block_found_map = 0;
@@ -58,15 +64,35 @@ errcode_t e2fsck_reset_context(e2fsck_t ctx)
                ext2fs_free_icount(ctx->inode_link_info);
                ctx->inode_link_info = 0;
        }
-       if (ctx->fs->dblist) {
+       if (ctx->journal_io) {
+               if (ctx->fs && ctx->fs->io != ctx->journal_io)
+                       io_channel_close(ctx->journal_io);
+               ctx->journal_io = 0;
+       }
+       if (ctx->fs && ctx->fs->dblist) {
                ext2fs_free_dblist(ctx->fs->dblist);
                ctx->fs->dblist = 0;
        }
        e2fsck_free_dir_info(ctx);
+#ifdef ENABLE_HTREE
+       e2fsck_free_dx_dir_info(ctx);
+#endif
+       if (ctx->refcount) {
+               ea_refcount_free(ctx->refcount);
+               ctx->refcount = 0;
+       }
+       if (ctx->refcount_extra) {
+               ea_refcount_free(ctx->refcount_extra);
+               ctx->refcount_extra = 0;
+       }
        if (ctx->block_dup_map) {
                ext2fs_free_block_bitmap(ctx->block_dup_map);
                ctx->block_dup_map = 0;
        }
+       if (ctx->block_ea_map) {
+               ext2fs_free_block_bitmap(ctx->block_ea_map);
+               ctx->block_ea_map = 0;
+       }
        if (ctx->inode_bb_map) {
                ext2fs_free_inode_bitmap(ctx->inode_bb_map);
                ctx->inode_bb_map = 0;
@@ -75,20 +101,28 @@ errcode_t e2fsck_reset_context(e2fsck_t ctx)
                ext2fs_free_inode_bitmap(ctx->inode_bad_map);
                ctx->inode_bad_map = 0;
        }
+       if (ctx->inode_imagic_map) {
+               ext2fs_free_inode_bitmap(ctx->inode_imagic_map);
+               ctx->inode_imagic_map = 0;
+       }
+       if (ctx->dirs_to_hash) {
+               ext2fs_u32_list_free(ctx->dirs_to_hash);
+               ctx->dirs_to_hash = 0;
+       }
 
        /*
         * Clear the array of invalid meta-data flags
         */
        if (ctx->invalid_inode_bitmap_flag) {
-               ext2fs_free_mem((void **) &ctx->invalid_inode_bitmap_flag);
+               ext2fs_free_mem(&ctx->invalid_inode_bitmap_flag);
                ctx->invalid_inode_bitmap_flag = 0;
        }
        if (ctx->invalid_block_bitmap_flag) {
-               ext2fs_free_mem((void **) &ctx->invalid_block_bitmap_flag);
+               ext2fs_free_mem(&ctx->invalid_block_bitmap_flag);
                ctx->invalid_block_bitmap_flag = 0;
        }
        if (ctx->invalid_inode_table_flag) {
-               ext2fs_free_mem((void **) &ctx->invalid_inode_table_flag);
+               ext2fs_free_mem(&ctx->invalid_inode_table_flag);
                ctx->invalid_inode_table_flag = 0;
        }
 
@@ -122,8 +156,10 @@ void e2fsck_free_context(e2fsck_t ctx)
                return;
        
        e2fsck_reset_context(ctx);
-       
-       ext2fs_free_mem((void **) &ctx);
+       if (ctx->blkid)
+               blkid_put_cache(ctx->blkid);
+                       
+       ext2fs_free_mem(&ctx);
 }
 
 /*
@@ -144,8 +180,10 @@ int e2fsck_run(e2fsck_t ctx)
        pass_t  e2fsck_pass;
 
 #ifdef HAVE_SETJMP_H
-       if (setjmp(ctx->abort_loc))
+       if (setjmp(ctx->abort_loc)) {
+               ctx->flags &= ~E2F_FLAG_SETJMP_OK;
                return (ctx->flags & E2F_FLAG_RUN_RETURN);
+       }
        ctx->flags |= E2F_FLAG_SETJMP_OK;
 #endif
                
@@ -162,9 +200,3 @@ int e2fsck_run(e2fsck_t ctx)
                return (ctx->flags & E2F_FLAG_RUN_RETURN);
        return 0;
 }
-
-
-       
-
-       
-