summaryrefslogtreecommitdiff
path: root/e2fsck/unix.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2010-05-13 17:36:36 -0400
committerTheodore Ts'o <tytso@mit.edu>2010-05-13 17:36:36 -0400
commit177839e2454dcc298244481da9c72a19b41836be (patch)
tree0e998a24865b468bbe4c893494b8db06c2e3ee18 /e2fsck/unix.c
parent65d71894c9f254ea1a5eb836e454dd263b13a867 (diff)
downloade2fsprogs-177839e2454dcc298244481da9c72a19b41836be.tar.gz
e2fsck: Skip time-based checks if the time looks insane or broken_system_clock
There are broken embedded devices that have system clocks that always reset to January 1, 1970 whenever they boot (even if no power is lost). There are also systems that have super cheap clock crystals that can be very inaccurate. So if the option broken_system_clock is given, disable all time based checks. E2fsck will also try to detect incorrect system clock times, and automatically mark the system clock as insane. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'e2fsck/unix.c')
-rw-r--r--e2fsck/unix.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index fd62ce5d..383c651f 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -291,8 +291,13 @@ static void check_if_skip(e2fsck_t ctx)
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);
@@ -320,11 +325,12 @@ static void check_if_skip(e2fsck_t ctx)
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");
@@ -350,7 +356,7 @@ static void check_if_skip(e2fsck_t ctx)
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) {
@@ -1433,7 +1439,8 @@ no_journal:
} 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);
}
}