Hello Michael and mantainers,

Michael Kerrisk wrote:
> 
> Kunihiko IMAI wrote:
>> Package: manpages-dev
>> Version: 2.67-1
>> Severity: minor
>> File: /usr/share/man/man2/settimeofday.2.gz
>>
>>
>>
>> -- System Information:
>> Debian Release: lenny/sid
>>   APT prefers oldstable
>>   APT policy: (500, 'oldstable'), (500, 'testing')
>> Architecture: i386 (i686)
>>
>> Kernel: Linux 2.6.18-4-486
>> Locale: LANG=ja_JP.EUC-JP, LC_CTYPE=ja_JP.EUC-JP (charmap=EUC-JP)
>> Shell: /bin/sh linked to /bin/bash
>>
>> Versions of packages manpages-dev depends on:
>> ii  manpages                      2.67-1     Manual pages about using a
>> GNU/Lin
>>
>> manpages-dev recommends no packages.
>>
>> -- no debconf information
>>
>>
>>
>> `man settimeofday' says:
>>
>>      The use of the timezone structure is obsolete; the tz  argument
>>      should normally  be  specified  as  NULL.
>>
>> But, on linux kernel, the FAT filesystem driver uses tz->tz_minuteswest
>> parameter for timestamp conversion.  `tz' argument is still alive, not
>> retired.
> 
> Hello Kunihiko,
> 
> Elsewhere in the man page it says:
> 
>        Under Linux there are some peculiar "warp  clock"  seman-
>        tics associated with the settimeofday() system call if on
>        the very first call (after booting) that has  a  non-NULL
>        tz  argument,  the  tv  argument  is NULL and the tz_min-
>        uteswest field is nonzero.  In such a case it is  assumed
>        that  the CMOS clock is on local time, and that it has to
>        be incremented by this amount to get UTC system time.  No
>        doubt it is a bad idea to use this feature.
> 
> This seems to cover the point you are describing.  Do you still think some
> change is required?

Hmm....  Is this enough description?  For example, to write 'date' or
'hwclock' from full scratch.

I sure that it is good at some computers that have localtime RTCs.
Imagine a computer which has a UTC RTC.  What sequence of settimeofday()
we should make at the early boot time?  We don't have to set tz?

I think, for the best way of understanding tz, describe like that:

        MS-DOS and some non-native filesystems use tz.minuteswest for
        adjusting timestamps.  You must set tz.minuteswest at least once
        from the boottime before using those filesystems.

        ( I wish someone rewrite this more natural description.  I am
        a non-native English user. )

Hiding this fact makes this manual misleadable.



By the way, I think that we don't have to describe on the manual about
unobservable thing from userspace, for example, 'jiffies' kernel
valiable.  But this timestamp adjusting feature is observable to do as
follows:

1. do settimeofday() with tz.minuteswest = -540 (Japanese Standard Time;
or your localtime.)

2. mount a MS-DOS floppy and do 'ls -l'.

3. umount the floppy.

4. do settimeofday() with tz.minuteswest = 0 (UTC)

5. again, mount the same MS-DOS floopy and do 'ls -l'.




Thanks.

Kunihiko IMAI

> 
> Cheers,
> 
> Michael
> 
>> Here is the detail in kernel:
>> linux-2.6.17.1/kernel/time.c handles settimeofday(2) syscall and stores
>> tz parameter into sys_tz global variable.
>> //////////
>> struct timezone sys_tz;
>>
>> EXPORT_SYMBOL(sys_tz);
>>
>> ...(snip)...
>>
>> int do_sys_settimeofday(struct timespec *tv, struct timezone *tz)
>> {
>>         static int firsttime = 1;
>>         int error = 0;
>>
>>         if (tv && !timespec_valid(tv))
>>                 return -EINVAL;
>>
>>         error = security_settime(tv, tz);
>>         if (error)
>>                 return error;
>>
>>         if (tz) {
>>                 /* SMP safe, global irq locking makes it work. */
>>                 sys_tz = *tz;
>>                 if (firsttime) {
>>                         firsttime = 0;
>>                         if (!tv)
>>                                 warp_clock();
>>                 }
>>         }
>>         if (tv)
>>         {
>>                 /* SMP safe, again the code in arch/foo/time.c should
>>                  * globally block out interrupts when it runs.
>>                  */
>>                 return do_settimeofday(tv);
>>         }
>>         return 0;
>> }
>> //////////
>>
>>
>>
>> linux-2.6.17.1/fs/fat/misc.c uses the `sys_tz' variable for timestamp
>> conversion.   FAT filesystem has only yy-mm-dd-hh-mm-ss format
>> timestamp, no timezone infomation.  So linux kernel handles the
>> timestamp as localtime with using tz->tz_minuteswest parameter.
>> //////////
>> extern struct timezone sys_tz;
>>
>> ...(snip)...
>>
>> /* Convert a MS-DOS time/date pair to a UNIX date (seconds since 1 1 70). */
>> int date_dos2unix(unsigned short time, unsigned short date)
>> {
>>         int month, year, secs;
>>
>>         /*
>>          * first subtract and mask after that... Otherwise, if
>>          * date == 0, bad things happen
>>          */
>>         month = ((date >> 5) - 1) & 15;
>>         year = date >> 9;
>>         secs = (time & 31)*2+60*((time >> 5) & 63)+(time >> 11)*3600+86400*
>>             ((date & 31)-1+day_n[month]+(year/4)+year*365-((year & 3) ==
>> 0 &&
>>             month < 2 ? 1 : 0)+3653);
>>                         /* days since 1.1.70 plus 80's leap day */
>>         secs += sys_tz.tz_minuteswest*60;
>>         return secs;
>> }
>> //////////
>>
>>
>> Thanks.
>> ----
>> Kunihiko IMAI
>>
>>
>>
>>
> 




-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to