From 8ff1a86005121edcbf04cfaf8f0812591cb916c6 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Tue, 30 Nov 2004 19:57:20 -0500 Subject: [PATCH] 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. --- debugfs/ChangeLog | 5 +++++ debugfs/util.c | 8 +++++++- e2fsck/ChangeLog | 6 ++++++ e2fsck/message.c | 11 ++++++++--- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/debugfs/ChangeLog b/debugfs/ChangeLog index dc7dcc7..3b6b25d 100644 --- a/debugfs/ChangeLog +++ b/debugfs/ChangeLog @@ -1,5 +1,10 @@ 2004-11-30 Theodore Ts'o + * 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. diff --git a/debugfs/util.c b/debugfs/util.c index 0c1cfed..ea82e32 100644 --- a/debugfs/util.c +++ b/debugfs/util.c @@ -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)); } /* diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog index cf99a87..c2addbb 100644 --- a/e2fsck/ChangeLog +++ b/e2fsck/ChangeLog @@ -1,5 +1,11 @@ 2004-11-30 Theodore Ts'o + * 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 diff --git a/e2fsck/message.c b/e2fsck/message.c index 6c19f57..a3250e1 100644 --- a/e2fsck/message.c +++ b/e2fsck/message.c @@ -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': -- 1.8.3.1