/*
* e2fsck.c - a consistency checker for the new extended file system.
- *
+ *
* Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o.
*
* %Begin-Header%
#include "problem.h"
/*
- * This function allocates an e2fsck context
+ * This function allocates an e2fsck context
*/
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);
*/
errcode_t e2fsck_reset_context(e2fsck_t ctx)
{
+ int i;
+
ctx->flags = 0;
ctx->lost_and_found = 0;
ctx->bad_lost_and_found = 0;
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;
}
{
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);
}
}
ctx->flags |= E2F_FLAG_SETJMP_OK;
#endif
-
+
for (i=0; (e2fsck_pass = e2fsck_passes[i]); i++) {
if (ctx->flags & E2F_FLAG_RUN_RETURN)
break;
(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;