Bug 5300

Summary: file timestamps on msdos floppies written in red hat linux are wrong
Product: [Retired] Red Hat Linux Reporter: erapopor
Component: timeconfigAssignee: David Lawrence <dkl>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 5.2CC: ewt, vek
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
URL: http://x30.deja.com/[ST_rn=ap]/getdoc.xp?AN=527885544&CONTEXT=938013931.465109003&hitnum=0
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2000-04-05 21:05:25 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description erapopor 1999-09-22 15:59:28 UTC
The kernel variable sys_tz which is used by the msdos
filesystem is not being set by the date command or the
timeconfig utility in /usr/sbin/setup.

As a result, the files written to an msdos floppy in linux
are stamped in UTC rather than local clock time which msdos
and windows assume.

Note: a call to settimeofday() can be used to correct this,
but this should be done by the O.S. itself, not by an
application.

here is code to test and correct the problem and a test run:
code (timetest.cpp):
==========================================
//////////////////////////////////////////////////////
// timetest.cpp
// code to demonstrate and fix failure to update kernel
timezone variable
// in redhat linux which causes incorrect timestamps to be
written on msdos
// filesystems
// Ed Rapoport 22.9.1999
// erapopor
//
#include <sys/time.h>
#include <unistd.h>
#include <ostream.h>
#include <errno.h>
#include <stdio.h>

main(int argc, char* argv[])
{
    struct timezone fred;
    time_t now = time(NULL);
    int stat=0;

    stat = gettimeofday(NULL, &fred);
    if(stat)
    {
	perror("perror: ");
    }
    else
    {
	cout << fred.tz_minuteswest << " current minutes
west of UTC.\n";
    }

    fred.tz_minuteswest = (int) difftime( mktime(gmtime(
&now )),
				    mktime(localtime(
&now ))) / 60;
    fred.tz_dsttime=0;
    cout << "Minutes west of UTC to set for local time: "
<<
      fred.tz_minuteswest << endl;

    stat = settimeofday(NULL, &fred);
    if(stat)
    {
	perror("perror: ");
    }

    stat = gettimeofday(NULL, &fred);
    if(stat)
    {
	perror("perror: ");
    }
    else
    {
	cout << fred.tz_minuteswest << " now minutes west
of UTC.\n";
    }
}

testrun:
==========================================
g++ timetest.cpp -o timetest
% su
# ./timetest
0 current minutes west of UTC.
Minutes west of UTC to set for local time: 300
300 now minutes west of UTC.

Comment 1 Trond Eivind Glomsrxd 2000-04-05 21:05:59 UTC
It works in 6.2:

[root@hoser /root]# ~teg/timetest
300 current minutes  west of UTC.
Minutes west of UTC to set for local time: 300
300 now minutes west  of UTC.
[root@hoser /root]#