Whamcloud - gitweb
If the TZ environment variable is set to GMT, use gmtime()
authorTheodore Ts'o <tytso@mit.edu>
Wed, 1 Dec 2004 00:57:20 +0000 (19:57 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 1 Dec 2004 00:57:20 +0000 (19:57 -0500)
instead of localtime() or ctime() to force the use of GMT.
This is because the dietlibc doesn't honor the TZ environment
variable.

debugfs/ChangeLog
debugfs/util.c
e2fsck/ChangeLog
e2fsck/message.c

index dc7dcc7..3b6b25d 100644 (file)
@@ -1,5 +1,10 @@
 2004-11-30  Theodore Ts'o  <tytso@mit.edu>
 
+       * util.c (time_to_string): If the TZ environment variable is set
+               to GMT, use gmtime() instead of localtime() or ctime() to
+               force the use of GMT.  This is because the dietlibc
+               doesn't honor the TZ environment variable.
+
        * Makefile.in: Use Linux-kernel-style makefile output to make it
                easier to see errors/warnings.
 
index 0c1cfed..ea82e32 100644 (file)
@@ -187,8 +187,14 @@ int check_fs_bitmaps(char *name)
 char *time_to_string(__u32 cl)
 {
        time_t  t = (time_t) cl;
+       static int do_gmt = -1;
 
-       return ctime(&t);
+       if (do_gmt == -1) {
+               /* The diet libc doesn't respect the TZ environemnt variable */
+               do_gmt = !strcmp(getenv("TZ"), "GMT");
+       }
+
+       return asctime((do_gmt) ? gmtime(&t) : localtime(&t));
 }
 
 /*
index cf99a87..c2addbb 100644 (file)
@@ -1,5 +1,11 @@
 2004-11-30  Theodore Ts'o  <tytso@mit.edu>
 
+       * message.c (expand_inode_expression): If the TZ environment
+               variable is set to GMT, use gmtime() instead of
+               localtime() or ctime() to force the use of GMT.  This is
+               because the dietlibc doesn't honor the TZ environment
+               variable.
+       
        * e2fsck.h: Add io_options to e2fsck_struct
 
        * unix.c: If there is a question mark in the device name, separate
index 6c19f57..a3250e1 100644 (file)
@@ -231,12 +231,13 @@ static _INLINE_ void expand_at_expression(e2fsck_t ctx, char ch,
 /*
  * This function expands '%IX' expressions
  */
-static _INLINE_ void expand_inode_expression(char ch,
-                                              struct problem_context *ctx)
+static _INLINE_ void expand_inode_expression(char ch, 
+                                            struct problem_context *ctx)
 {
        struct ext2_inode       *inode;
        char *                  time_str;
        time_t                  t;
+       int                     do_gmt = -1;
 
        if (!ctx || !ctx->inode)
                goto no_inode;
@@ -270,8 +271,12 @@ static _INLINE_ void expand_inode_expression(char ch,
                printf("0%o", inode->i_mode);
                break;
        case 'M':
+               /* The diet libc doesn't respect the TZ environemnt variable */
+               if (do_gmt == -1) {
+                       do_gmt = !strcmp(getenv("TZ"), "GMT");
+               }
                t = inode->i_mtime;
-               time_str = ctime(&t);
+               time_str = asctime(do_gmt ? gmtime(&t) : localtime(&t));
                printf("%.24s", time_str);
                break;
        case 'F':