Whamcloud - gitweb
e2fsck: Fix handling of non-zero i_blocks_high field
[tools/e2fsprogs.git] / e2fsck / e2fsck.c
index 2ba72c8..26f7b5e 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * e2fsck.c - a consistency checker for the new extended file system.
- * 
+ *
  * Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o.
  *
  * %Begin-Header%
@@ -15,7 +15,7 @@
 #include "problem.h"
 
 /*
- * This function allocates an e2fsck context 
+ * This function allocates an e2fsck context
  */
 errcode_t e2fsck_allocate_context(e2fsck_t *ret)
 {
@@ -26,12 +26,14 @@ errcode_t e2fsck_allocate_context(e2fsck_t *ret)
        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;
-       
+       context->blocks_per_page = 1;
+       context->htree_slack_percentage = 255;
+
        time_env = getenv("E2FSCK_TIME");
        if (time_env)
                context->now = strtoul(time_env, NULL, 0);
@@ -48,6 +50,8 @@ errcode_t e2fsck_allocate_context(e2fsck_t *ret)
  */
 errcode_t e2fsck_reset_context(e2fsck_t ctx)
 {
+       int     i;
+
        ctx->flags = 0;
        ctx->lost_and_found = 0;
        ctx->bad_lost_and_found = 0;
@@ -149,11 +153,15 @@ errcode_t e2fsck_reset_context(e2fsck_t ctx)
        ctx->fs_dind_count = 0;
        ctx->fs_tind_count = 0;
        ctx->fs_fragmented = 0;
+       ctx->fs_fragmented_dir = 0;
        ctx->large_files = 0;
 
+       for (i=0; i < MAX_EXTENT_DEPTH_COUNT; i++)
+               ctx->extent_depth_count[i] = 0;
+
        /* Reset the superblock to the user's requested value */
        ctx->superblock = ctx->use_superblock;
-       
+
        return 0;
 }
 
@@ -161,14 +169,20 @@ void e2fsck_free_context(e2fsck_t ctx)
 {
        if (!ctx)
                return;
-       
+
        e2fsck_reset_context(ctx);
        if (ctx->blkid)
                blkid_put_cache(ctx->blkid);
 
        if (ctx->profile)
                profile_release(ctx->profile);
-                       
+
+       if (ctx->filesystem_name)
+               ext2fs_free_mem(&ctx->filesystem_name);
+
+       if (ctx->device_name)
+               ext2fs_free_mem(&ctx->device_name);
+
        ext2fs_free_mem(&ctx);
 }
 
@@ -196,7 +210,7 @@ int e2fsck_run(e2fsck_t ctx)
        }
        ctx->flags |= E2F_FLAG_SETJMP_OK;
 #endif
-               
+
        for (i=0; (e2fsck_pass = e2fsck_passes[i]); i++) {
                if (ctx->flags & E2F_FLAG_RUN_RETURN)
                        break;
@@ -205,7 +219,7 @@ int e2fsck_run(e2fsck_t ctx)
                        (void) (ctx->progress)(ctx, 0, 0, 0);
        }
        ctx->flags &= ~E2F_FLAG_SETJMP_OK;
-       
+
        if (ctx->flags & E2F_FLAG_RUN_RETURN)
                return (ctx->flags & E2F_FLAG_RUN_RETURN);
        return 0;