The following patch will be in the next release of e2fsprogs.  If
you'd like to apply it and rebuild it, it will provide the proof you
need that either your laptop RTC clock is bad or there's something
strange going on with the system time on your laptop.

                                         - Ted

commit fe26a55ac923f4cce17c27ef51de84d2e3b6eebb
Author: Theodore Ts'o <ty...@mit.edu>
Date:   Sat Aug 8 10:14:48 2009 -0400

    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" <ty...@mit.edu>

diff --git a/e2fsck/message.c b/e2fsck/message.c
index 3f85916..77f9756 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 d6b345c..fc325e9 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 ef29aa5..2202967 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)) {



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to