rpms/e2fsprogs/F-12 e2fsprogs-1.41.9-broken_system_clock.patch, NONE, 1.1 e2fsprogs-1.41.9-skip-time-checks-for-crazyclock.patch, NONE, 1.1 e2fsprogs.spec, 1.155, 1.156

Eric Sandeen sandeen at fedoraproject.org
Mon Jul 5 20:31:31 UTC 2010


Author: sandeen

Update of /cvs/pkgs/rpms/e2fsprogs/F-12
In directory cvs01.phx2.fedoraproject.org:/tmp/cvs-serv7748

Modified Files:
	e2fsprogs.spec 
Added Files:
	e2fsprogs-1.41.9-broken_system_clock.patch 
	e2fsprogs-1.41.9-skip-time-checks-for-crazyclock.patch 
Log Message:
* Mon Jul 05 2010 Eric Sandeen <sandeen at redhat.com> 1.41.9-8
- e2fsck: Skip time-based checks if the time looks insane (#577126)


e2fsprogs-1.41.9-broken_system_clock.patch:
 e2fsck.conf.5.in |   13 +++++++++++++
 problem.c        |   11 ++++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)

--- NEW FILE e2fsprogs-1.41.9-broken_system_clock.patch ---
From: Theodore Ts'o <tytso at mit.edu>
Date: Mon, 4 Jan 2010 18:59:04 +0000 (-0500)
Subject: e2fsck: Add new e2fsck.conf option: broken_system_clock
X-Git-Tag: v1.41.10~5
X-Git-Url: http://git.kernel.org/?p=fs%2Fext2%2Fe2fsprogs.git;a=commitdiff_plain;h=c70674387ee0c038bca16098f7869181beeabe0a

e2fsck: Add new e2fsck.conf option: broken_system_clock

The broken_system_clock allows the time to be in the future when in
preen mode.  It's useful for people who have, as the name implies,
broken system clocks.

Signed-off-by: "Theodore Ts'o" <tytso at mit.edu>
---

diff --git a/e2fsck/e2fsck.conf.5.in b/e2fsck/e2fsck.conf.5.in
index a5021bd..64aafd7 100644
--- a/e2fsck/e2fsck.conf.5.in
+++ b/e2fsck/e2fsck.conf.5.in
@@ -109,6 +109,19 @@ This can be disabled by setting
 to the
 boolean value of false.  This setting defaults to true.
 .TP
+.I broken_system_clock
+The
+.BR e2fsck (8)
+program has some hueristics that assume that the system clock is
+correct.  In addition, many system programs make similar assumptions.
+For example, the UUID library depends on time not going backwards in
+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.
+.TP
 .I clear_test_fs_flag
 This boolean relation controls whether or not 
 .BR e2fsck (8)
diff --git a/e2fsck/problem.c b/e2fsck/problem.c
index a713f1b..9043281 100644
--- a/e2fsck/problem.c
+++ b/e2fsck/problem.c
@@ -1741,7 +1741,7 @@ int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx)
 	struct e2fsck_problem *ptr;
 	struct latch_descr *ldesc = 0;
 	const char *message;
-	int		def_yn, answer, ans;
+	int		def_yn, answer, ans, broken_system_clock;
 	int		print_answer = 0;
 	int		suppress = 0;
 
@@ -1753,6 +1753,15 @@ int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx)
 	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,


e2fsprogs-1.41.9-skip-time-checks-for-crazyclock.patch:
 e2fsck.c         |    7 +++++--
 e2fsck.conf.5.in |    7 ++++---
 e2fsck.h         |    3 +++
 problem.c        |   11 +----------
 super.c          |   12 ++++++++++--
 unix.c           |   15 +++++++++++----
 6 files changed, 34 insertions(+), 21 deletions(-)

--- NEW FILE e2fsprogs-1.41.9-skip-time-checks-for-crazyclock.patch ---
From: Theodore Ts'o <tytso at mit.edu>
Date: Thu, 13 May 2010 21:36:36 +0000 (-0400)
Subject: e2fsck: Skip time-based checks if the time looks insane or broken_system_clock
X-Git-Tag: v1.41.12~14
X-Git-Url: http://git.kernel.org/?p=fs%2Fext2%2Fe2fsprogs.git;a=commitdiff_plain;h=177839e2454dcc298244481da9c72a19b41836be

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 at mit.edu>
---

diff --git a/e2fsck/e2fsck.c b/e2fsck/e2fsck.c
index 26f7b5e..f1da97a 100644
--- a/e2fsck/e2fsck.c
+++ b/e2fsck/e2fsck.c
@@ -37,8 +37,11 @@ errcode_t e2fsck_allocate_context(e2fsck_t *ret)
 	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;
@@ -52,7 +55,7 @@ errcode_t e2fsck_reset_context(e2fsck_t ctx)
 {
 	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) {
diff --git a/e2fsck/e2fsck.conf.5.in b/e2fsck/e2fsck.conf.5.in
index 64aafd7..7cb0633 100644
--- a/e2fsck/e2fsck.conf.5.in
+++ b/e2fsck/e2fsck.conf.5.in
@@ -118,9 +118,10 @@ For example, the UUID library depends on time not going backwards in
 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 
diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h
index e763b89..7926658 100644
--- a/e2fsck/e2fsck.h
+++ b/e2fsck/e2fsck.h
@@ -176,6 +176,9 @@ struct resource_track {
 #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
diff --git a/e2fsck/problem.c b/e2fsck/problem.c
index 5825f5b..8032fda 100644
--- a/e2fsck/problem.c
+++ b/e2fsck/problem.c
@@ -1746,7 +1746,7 @@ int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx)
 	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;
 
@@ -1758,15 +1758,6 @@ int fix_problem(e2fsck_t ctx, problem_t code, struct problem_context *pctx)
 	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,
diff --git a/e2fsck/super.c b/e2fsck/super.c
index 951f6db..accc2f1 100644
--- a/e2fsck/super.c
+++ b/e2fsck/super.c
@@ -464,6 +464,7 @@ void check_super_block(e2fsck_t ctx)
 	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;
@@ -821,11 +822,16 @@ void check_super_block(e2fsck_t ctx)
 			    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)
@@ -835,7 +841,9 @@ void check_super_block(e2fsck_t ctx)
 			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)
diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index fd62ce5..383c651 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);
 		}
 	}



Index: e2fsprogs.spec
===================================================================
RCS file: /cvs/pkgs/rpms/e2fsprogs/F-12/e2fsprogs.spec,v
retrieving revision 1.155
retrieving revision 1.156
diff -u -p -r1.155 -r1.156
--- e2fsprogs.spec	7 Feb 2010 22:17:06 -0000	1.155
+++ e2fsprogs.spec	5 Jul 2010 20:31:31 -0000	1.156
@@ -18,6 +18,8 @@ Patch5: e2fsprogs-1.41.9-24hr-fsck-grace
 Patch6: e2fsprogs-1.41.9-s_jnl_blocks-swap.patch
 Patch7: e2fsprogs-1.41.9-resize-array.patch
 Patch8: e2fsprogs-1.41.9-dlopen-fix.patch
+Patch9: e2fsprogs-1.41.9-broken_system_clock.patch
+Patch10: e2fsprogs-1.41.9-skip-time-checks-for-crazyclock.patch
 
 Url: http://e2fsprogs.sourceforge.net/
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@@ -148,6 +150,8 @@ It was originally inspired by the Multic
 %patch6 -p1 -b .swap
 %patch7 -p1 -b .resize2
 %patch8 -p1 -b .dlopen
+%patch9 -p1 -b .brokenclock
+%patch10 -p1 -b .crazyclock
 
 %build
 %configure --enable-elf-shlibs --enable-nls --disable-uuidd --disable-fsck \
@@ -305,6 +309,9 @@ exit 0
 %{_libdir}/pkgconfig/ss.pc
 
 %changelog
+* Mon Jul 05 2010 Eric Sandeen <sandeen at redhat.com> 1.41.9-8
+- e2fsck: Skip time-based checks if the time looks insane (#577126)
+
 * Sun Feb 07 2010 Eric Sandeen <sandeen at redhat.com> 1.41.9-7
 - Upstream version of resize2fs array fix, original was wrong
 



More information about the scm-commits mailing list