Whamcloud - gitweb
Fixes necessary for e2fsprogs to work using the diet libc.
[tools/e2fsprogs.git] / e2fsck / e2fsck.c
index c80036e..1ec8ffa 100644 (file)
@@ -11,8 +11,6 @@
 
 #include <errno.h>
 
-#include "et/com_err.h"
-
 #include "e2fsck.h"
 #include "problem.h"
 
@@ -52,6 +50,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;
@@ -60,15 +62,32 @@ 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);
+       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;
@@ -77,6 +96,10 @@ 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;
+       }
 
        /*
         * Clear the array of invalid meta-data flags
@@ -110,6 +133,7 @@ errcode_t e2fsck_reset_context(e2fsck_t ctx)
        ctx->fs_dind_count = 0;
        ctx->fs_tind_count = 0;
        ctx->fs_fragmented = 0;
+       ctx->large_files = 0;
 
        /* Reset the superblock to the user's requested value */
        ctx->superblock = ctx->use_superblock;
@@ -137,6 +161,8 @@ pass_t e2fsck_passes[] = {
        e2fsck_pass1, e2fsck_pass2, e2fsck_pass3, e2fsck_pass4,
        e2fsck_pass5, 0 };
 
+#define E2F_FLAG_RUN_RETURN    (E2F_FLAG_SIGNAL_MASK|E2F_FLAG_RESTART)
+
 int e2fsck_run(e2fsck_t ctx)
 {
        int     i;
@@ -144,19 +170,21 @@ int e2fsck_run(e2fsck_t ctx)
 
 #ifdef HAVE_SETJMP_H
        if (setjmp(ctx->abort_loc))
-               return (ctx->flags & E2F_FLAG_SIGNAL_MASK);
+               return (ctx->flags & E2F_FLAG_RUN_RETURN);
        ctx->flags |= E2F_FLAG_SETJMP_OK;
 #endif
                
        for (i=0; (e2fsck_pass = e2fsck_passes[i]); i++) {
-               if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
+               if (ctx->flags & E2F_FLAG_RUN_RETURN)
                        break;
                e2fsck_pass(ctx);
+               if (ctx->progress)
+                       (void) (ctx->progress)(ctx, 0, 0, 0);
        }
        ctx->flags &= ~E2F_FLAG_SETJMP_OK;
        
-       if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
-               return (ctx->flags & E2F_FLAG_SIGNAL_MASK);
+       if (ctx->flags & E2F_FLAG_RUN_RETURN)
+               return (ctx->flags & E2F_FLAG_RUN_RETURN);
        return 0;
 }