lkml.org 
[lkml]   [1998]   [Oct]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectQuick hack for smbfs/*fs timezone/dst prob. w/ util-linux-2.7
On Mon, 19 Oct 1998 14:57:41 +0100 (BST), Alan Cox (quoting Andries) wrote:

>> However, clock was patched to do precisely this, and util-linux has
>> contained this patched version of clock for a long time (between
>> util-linux-1.6 and util-linux-2.6). Moreover, util-linux-2.6 is still used
>> by SuSE 5.3.
>
> And that would reasonably explain why the kernel code works.
>
>> So, I withdraw my scepticism, it is true that there is such buggy software
>> around, but of course still maintain that the kernel should be fixed.
>
> That needs someone to provide a source for for 'adjusted local time' or
> daylight savings info to the kernel from userspace. Once it exists I'll
> fix the rest

Until that happens, util-linux-2.7 users with timezone problems on non-Unix
filesystems can either downgrade to util-linux-2.6's clock or try out the
following program. It fixed my smbfs-problem w/ RedHat 5.1 and 2.0.36pre12.

===== cut here =============================================================
/*
* Author: Ulrik Dickow <ukd@kampsax.dk>, 1998/10/30.
* Copyright: Public Domain (due to the tiny & hackish nature of this)
* Warranty: NONE, USE AT YOUR OWN RISK.
*
* Purpose: Hack Linux kernel sys_tz with appropriate minuteswest & dsttime,
* so that msdossy filesystems (affs, fat, hpfs, isofs, ncpfs, smbfs)
* get the best chance of converting "correctly" from localtime to UTC.
*
* Personal motivation:
* The atime/mtime/ctime seen on SMBFS became wrong by 1 or 2 hours when
* I upgraded from RedHat 4.2 to 5.1. This hack is the fastest way to
* make it work again _now_, using 2.0.36pre{2-15}.
*
* You do NOT need this program if:
* you use an util-linux between 1.6 and 2.6 (e.g. RedHat 4.x or S.u.S.E 5.3)
* (according to
* http://www.linuxhq.com/lnxlists/linux-kernel/lk_9810_03/msg00919.html;
* read the entire thread for more information)
* you use some future kernel & utilities that do things a nicer way
* (i.e. without abusing the gettimeofday/settimeofday interface)
*/

#include <stdio.h>
#include <stdlib.h>

#include <sys/time.h>

int main(void)
{
time_t t;
struct tm *tp;
struct timeval tv;
struct timezone old_tz, new_tz;

time(&t);
tp = localtime(&t);
new_tz.tz_minuteswest = timezone/60; /* This one is from a side effect */
new_tz.tz_dsttime = tp->tm_isdst; /* 0 in Winter; we hope 1 in Summer */

printf("New minuteswest: %d\n", new_tz.tz_minuteswest);
printf("New dsttime: %d\n", new_tz.tz_dsttime);

/* Get tv to pass to settimeofday(2) to be sure we avoid hour-sized warp */
/* (see gettimeofday(2) man page, or /usr/src/linux/kernel/time.c) */
if (gettimeofday(&tv, &old_tz)) {
perror("gettimeofday");
exit(EXIT_FAILURE);
}
/* Set time before printing, to minimize microsecond-sized time warp */
if (settimeofday(&tv, &new_tz)) {
perror("settimeofday");
exit(EXIT_FAILURE);
}
printf("Old minuteswest: %d\n", old_tz.tz_minuteswest);
printf("Old dsttime: %d\n", old_tz.tz_dsttime);

return EXIT_SUCCESS;
}
===== cut here =============================================================


--
Ulrik Dickow / ukd@kampsax.dk / Phone +45 36 39 08 00 / Fax +45 36 77 03 01
.............. Linux -- the choice of a GNU generation ....................
..................... http://www.sslug.dk/ ................................

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:45    [W:1.666 / U:1.304 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site