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) {
order for it to be able to make its guarantees about issuing universally
unique ID's. Systems with broken system clocks, are well, broken.
However, broken system clocks, particularly in embedded systems, do
-exist. If true, e2fsck will not abort a preen check if it detects a
-last mounted or last write time in the superblock in the future. This
-setting defaults to false.
+exist. E2fsck will attempt to use hueristics to determine if the time
+can no tbe trusted; and to skip time-based checks if this is true. If
+this boolean is set to true, then e2fsck will always assume that the
+system clock can not be trusted.
.TP
.I clear_test_fs_flag
This boolean relation controls whether or not
#define E2F_FLAG_RESIZE_INODE 0x0400 /* Request to recreate resize inode */
#define E2F_FLAG_GOT_DEVSIZE 0x0800 /* Device size has been fetched */
#define E2F_FLAG_EXITING 0x1000 /* E2fsck exiting due to errors */
+#define E2F_FLAG_TIME_INSANE 0x2000 /* Time is insane */
+
+#define E2F_RESET_FLAGS (E2F_FLAG_TIME_INSANE)
/*
* Defines for indicating the e2fsck pass number
struct e2fsck_problem *ptr;
struct latch_descr *ldesc = 0;
const char *message;
- int def_yn, answer, ans, broken_system_clock;
+ int def_yn, answer, ans;
int print_answer = 0;
int suppress = 0;
if (!(ptr->flags & PR_CONFIG)) {
char key[9], *new_desc;
- if ((code == PR_0_FUTURE_SB_LAST_MOUNT) ||
- (code == PR_0_FUTURE_SB_LAST_WRITE)) {
- profile_get_boolean(ctx->profile, "options",
- "broken_system_clock", 0, 0,
- &broken_system_clock);
- if (broken_system_clock)
- ptr->flags |= PR_PREEN_OK;
- }
-
sprintf(key, "0x%06x", code);
profile_get_string(ctx->profile, "problems", key,
int ipg_max;
int inode_size;
int accept_time_fudge;
+ int broken_system_clock;
dgrp_t i;
blk_t should_be;
struct problem_context pctx;
0, accept_time_fudge, &accept_time_fudge);
ctx->time_fudge = accept_time_fudge ? 86400 : 0;
+ profile_get_boolean(ctx->profile, "options", "broken_system_clock",
+ 0, 0, &broken_system_clock);
+
/*
* Check to see if the superblock last mount time or last
* write time is in the future.
*/
- if (fs->super->s_mtime > (__u32) ctx->now) {
+ if (!broken_system_clock &&
+ !(ctx->flags & E2F_FLAG_TIME_INSANE) &&
+ fs->super->s_mtime > (__u32) ctx->now) {
pctx.num = fs->super->s_mtime;
problem = PR_0_FUTURE_SB_LAST_MOUNT;
if (fs->super->s_mtime <= (__u32) ctx->now + ctx->time_fudge)
ext2fs_mark_super_dirty(fs);
}
}
- if (fs->super->s_wtime > (__u32) ctx->now) {
+ if (!broken_system_clock &&
+ !(ctx->flags & E2F_FLAG_TIME_INSANE) &&
+ fs->super->s_wtime > (__u32) ctx->now) {
pctx.num = fs->super->s_wtime;
problem = PR_0_FUTURE_SB_LAST_WRITE;
if (fs->super->s_wtime <= (__u32) ctx->now + ctx->time_fudge)
long next_check;
int batt = is_on_batt();
int defer_check_on_battery;
+ int broken_system_clock;
time_t lastcheck;
+ profile_get_boolean(ctx->profile, "options", "broken_system_clock",
+ 0, 0, &broken_system_clock);
+ if (ctx->flags & E2F_FLAG_TIME_INSANE)
+ broken_system_clock = 1;
profile_get_boolean(ctx->profile, "options",
"defer_check_on_battery", 0, 1,
&defer_check_on_battery);
if (batt && (fs->super->s_mnt_count <
(unsigned) fs->super->s_max_mnt_count*2))
reason = 0;
- } else if (fs->super->s_checkinterval && (ctx->now < lastcheck)) {
+ } else if (!broken_system_clock && fs->super->s_checkinterval &&
+ (ctx->now < lastcheck)) {
reason = _(" has filesystem last checked time in the future");
if (batt)
reason = 0;
- } else if (fs->super->s_checkinterval &&
+ } else if (!broken_system_clock && fs->super->s_checkinterval &&
((ctx->now - lastcheck) >=
((time_t) fs->super->s_checkinterval))) {
reason = _(" has gone %u days without being checked");
if (next_check <= 0)
next_check = 1;
}
- if (fs->super->s_checkinterval &&
+ if (!broken_system_clock && fs->super->s_checkinterval &&
((ctx->now - fs->super->s_lastcheck) >= fs->super->s_checkinterval))
next_check = 1;
if (next_check <= 5) {
} else
sb->s_state &= ~EXT2_VALID_FS;
sb->s_mnt_count = 0;
- sb->s_lastcheck = ctx->now;
+ if (!(ctx->flags & E2F_FLAG_TIME_INSANE))
+ sb->s_lastcheck = ctx->now;
ext2fs_mark_super_dirty(fs);
}
}