diff options
author | Theodore Ts'o <tytso@mit.edu> | 2009-08-08 10:14:48 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2009-08-08 10:14:48 -0400 |
commit | fe26a55ac923f4cce17c27ef51de84d2e3b6eebb (patch) | |
tree | 4a211e21c187f2fecdb99d7d9c081591683cc6a1 /e2fsck | |
parent | bf3941aac389f1de6ce2008f818b6350d1fdd764 (diff) | |
download | e2fsprogs-fe26a55ac923f4cce17c27ef51de84d2e3b6eebb.tar.gz |
e2fsck: Fix and enhance superblock dates in future problem reports
Fixed a bug where e2fsck would report that last mount time was in the
future when it was really the last write time that was in the future.
Also, since people can't seem to believe that (a) their distribution
has buggy init scripts, or (b) their CMOS/RTC clock or backup battery
is dead, print the incorrect time and the current system time.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'e2fsck')
-rw-r--r-- | e2fsck/message.c | 41 | ||||
-rw-r--r-- | e2fsck/problem.c | 4 | ||||
-rw-r--r-- | e2fsck/super.c | 2 |
3 files changed, 30 insertions, 17 deletions
diff --git a/e2fsck/message.c b/e2fsck/message.c index 3f859160..77f97560 100644 --- a/e2fsck/message.c +++ b/e2fsck/message.c @@ -209,6 +209,24 @@ static void print_pathname(ext2_filsys fs, ext2_ino_t dir, ext2_ino_t ino) } } +static void print_time(time_t t) +{ + const char * time_str; + static int do_gmt = -1; + +#ifdef __dietlibc__ + /* The diet libc doesn't respect the TZ environemnt variable */ + if (do_gmt == -1) { + time_str = getenv("TZ"); + if (!time_str) + time_str = ""; + do_gmt = !strcmp(time_str, "GMT0"); + } +#endif + time_str = asctime((do_gmt > 0) ? gmtime(&t) : localtime(&t)); + printf("%.24s", time_str); +} + /* * This function handles the '@' expansion. We allow recursive * expansion; an @ expression can contain further '@' and '%' @@ -244,9 +262,7 @@ static _INLINE_ void expand_inode_expression(char ch, { struct ext2_inode *inode; struct ext2_inode_large *large_inode; - const char * time_str; time_t t; - static int do_gmt = -1; if (!ctx || !ctx->inode) goto no_inode; @@ -289,18 +305,7 @@ static _INLINE_ void expand_inode_expression(char ch, printf("0%o", inode->i_mode); break; case 'M': -#ifdef __dietlibc__ - /* The diet libc doesn't respect the TZ environemnt variable */ - if (do_gmt == -1) { - time_str = getenv("TZ"); - if (!time_str) - time_str = ""; - do_gmt = !strcmp(time_str, "GMT0"); - } -#endif - t = inode->i_mtime; - time_str = asctime((do_gmt > 0) ? gmtime(&t) : localtime(&t)); - printf("%.24s", time_str); + print_time(inode->i_mtime); break; case 'F': printf("%u", inode->i_faddr); @@ -392,6 +397,8 @@ static _INLINE_ void expand_dirent_expression(ext2_filsys fs, char ch, static _INLINE_ void expand_percent_expression(ext2_filsys fs, char ch, struct problem_context *ctx) { + e2fsck_t e2fsck_ctx = fs ? (e2fsck_t) fs->priv_data : NULL; + if (!ctx) goto no_context; @@ -461,6 +468,12 @@ static _INLINE_ void expand_percent_expression(ext2_filsys fs, char ch, case 's': printf("%s", ctx->str ? ctx->str : "NULL"); break; + case 't': + print_time((time_t) ctx->num); + break; + case 'T': + print_time(e2fsck_ctx ? e2fsck_ctx->now : time(0)); + break; case 'X': #ifdef EXT2_NO_64_TYPE printf("0x%x", ctx->num); diff --git a/e2fsck/problem.c b/e2fsck/problem.c index d6b345cf..fc325e95 100644 --- a/e2fsck/problem.c +++ b/e2fsck/problem.c @@ -334,12 +334,12 @@ static struct e2fsck_problem problem_table[] = { /* Last mount time is in the future */ { PR_0_FUTURE_SB_LAST_MOUNT, - N_("@S last mount time is in the future. "), + N_("@S last mount time (%t,\n\tnow = %T) is in the future.\n"), PROMPT_FIX, PR_NO_OK }, /* Last write time is in the future */ { PR_0_FUTURE_SB_LAST_WRITE, - N_("@S last write time is in the future. "), + N_("@S last write time (%t,\n\tnow = %T) is in the future.\n"), PROMPT_FIX, PR_NO_OK }, { PR_0_EXTERNAL_JOURNAL_HINT, diff --git a/e2fsck/super.c b/e2fsck/super.c index ef29aa52..22029674 100644 --- a/e2fsck/super.c +++ b/e2fsck/super.c @@ -831,7 +831,7 @@ void check_super_block(e2fsck_t ctx) } if (fs->super->s_wtime > (__u32) ctx->now) { pctx.num = fs->super->s_wtime; - problem = PR_0_FUTURE_SB_LAST_MOUNT; + problem = PR_0_FUTURE_SB_LAST_WRITE; if (fs->super->s_wtime <= (__u32) ctx->now + ctx->time_fudge) problem = PR_0_FUTURE_SB_LAST_MOUNT_FUDGED; if (fix_problem(ctx, problem, &pctx)) { |