/*
* e2fsck.c - a consistency checker for the new extended file system.
- *
+ *
* Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o.
*
* %Begin-Header%
* %End-Header%
*/
+#include "config.h"
#include <errno.h>
#include "e2fsck.h"
#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);
- else
+ else {
context->now = time(0);
+ if (context->now < 1262322000) /* January 1 2010 */
+ context->flags |= E2F_FLAG_TIME_INSANE;
+ }
*ret = context;
return 0;
{
int i;
- ctx->flags = 0;
+ ctx->flags &= E2F_RESET_FLAGS;
ctx->lost_and_found = 0;
ctx->bad_lost_and_found = 0;
if (ctx->inode_used_map) {
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++)
/* 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->filesystem_name)
ext2fs_free_mem(&ctx->filesystem_name);
-
+
if (ctx->device_name)
ext2fs_free_mem(&ctx->device_name);
-
+
+ if (ctx->log_fn)
+ free(ctx->log_fn);
+
ext2fs_free_mem(&ctx);
}
*/
typedef void (*pass_t)(e2fsck_t ctx);
-pass_t e2fsck_passes[] = {
+static pass_t e2fsck_passes[] = {
e2fsck_pass1, e2fsck_pass2, e2fsck_pass3, e2fsck_pass4,
e2fsck_pass5, 0 };
}
ctx->flags |= E2F_FLAG_SETJMP_OK;
#endif
-
+
for (i=0; (e2fsck_pass = e2fsck_passes[i]); i++) {
if (ctx->flags & E2F_FLAG_RUN_RETURN)
break;
+ if (e2fsck_mmp_update(ctx->fs))
+ fatal_error(ctx, 0);
e2fsck_pass(ctx);
if (ctx->progress)
(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;