Bug 5300 - file timestamps on msdos floppies written in red hat linux are wrong
file timestamps on msdos floppies written in red hat linux are wrong
Status: CLOSED CURRENTRELEASE
Product: Red Hat Linux
Classification: Retired
Component: timeconfig (Show other bugs)
5.2
All Linux
medium Severity medium
: ---
: ---
Assigned To: David Lawrence
http://x30.deja.com/[ST_rn=ap]/getdoc...
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 1999-09-22 11:59 EDT by erapopor
Modified: 2008-05-01 11:37 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2000-04-05 17:05:25 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description erapopor 1999-09-22 11:59:28 EDT
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@stratasys.com
//
#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 17:05:59 EDT
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]#

Note You need to log in before you can comment on or make changes to this bug.