2001-10-02 09:18:36

by MOHAMMED AZAD

[permalink] [raw]
Subject: Getting system time in kernel..

Hi all,

Any idea how to get the system time in a kernel module.... I tried this in
solaris... but i am getting only the GMT (that too elapsed time) how do i
convert this to my locale time....

TIA
azad


2001-10-02 09:46:08

by David Woodhouse

[permalink] [raw]
Subject: Re: Getting system time in kernel..


[email protected] said:
> Any idea how to get the system time in a kernel module.... I tried
> this in solaris... but i am getting only the GMT (that too elapsed
> time) how do i convert this to my locale time....

You can't. You shouldn't need to convert to localtime inside the kernel.
What, precisely, are you trying to achieve?

--
dwmw2


2001-10-03 05:01:28

by David Schwartz

[permalink] [raw]
Subject: Re: Getting system time in kernel..



On Tue, 02 Oct 2001 10:43:23 +0100, David Woodhouse wrote:

>[email protected] said:

>> Any idea how to get the system time in a kernel module.... I tried this
>>in solaris... but i am getting only the GMT (that too elapsed time) how do
>>i convert this to my locale time....

>You can't. You shouldn't need to convert to localtime inside the kernel.
>What, precisely, are you trying to achieve?

As an example, a filesystem might internally store local times in its
inodes. You may not be free to change the on-disk format.

DS


2001-10-03 05:09:31

by Keith Owens

[permalink] [raw]
Subject: Re: Getting system time in kernel..

On Tue, 2 Oct 2001 22:01:41 -0700,
David Schwartz <[email protected]> wrote:
> As an example, a filesystem might internally store local times in its
>inodes. You may not be free to change the on-disk format.

Whose local time? The local time where the machine is or the local
time of the user accessing the machine from the other side of the
world? There is a very good reason why timestamps are GMT (UTC).

2001-10-03 06:31:01

by David Schwartz

[permalink] [raw]
Subject: Re: Getting system time in kernel..


On Wed, 03 Oct 2001 15:09:32 +1000, Keith Owens wrote:
>On Tue, 2 Oct 2001 22:01:41 -0700,
>David Schwartz <[email protected]> wrote:

>> As an example, a filesystem might internally store local times in its
>>inodes. You may not be free to change the on-disk format.

>Whose local time? The local time where the machine is or the local time of
>the user accessing the machine from the other side of the world? There is a
>very good reason why timestamps are GMT (UTC).

Well that's an argument in favor of two things:

1) Avoiding such situations whenever possible by using UTC timestamps in
things like filesystems, and

2) Making local time offsets tuneable for each case where you need one. The
physical location of the machine might or might not be meaningful.

DS




2001-10-03 09:18:26

by David Woodhouse

[permalink] [raw]
Subject: Re: Getting system time in kernel..


[email protected] said:
>
> 2) Making local time offsets tuneable for each case where you need
> one. The physical location of the machine might or might not be
> meaningful.

Indeed. So you make the GMT offset a mount-time parameter for your
filesystem, and the question of how to find the current localtime in the
part of the world where the machine's primary console happens to stick out
remains meaningless.


--
dwmw2


2001-10-03 10:31:42

by kaih

[permalink] [raw]
Subject: Re: Getting system time in kernel..

[email protected] (David Schwartz) wrote on 02.10.01 in <[email protected]@whenever>:

> On Tue, 02 Oct 2001 10:43:23 +0100, David Woodhouse wrote:
>
> >[email protected] said:
>
> >> Any idea how to get the system time in a kernel module.... I tried this
> >>in solaris... but i am getting only the GMT (that too elapsed time) how
> >>do i convert this to my locale time....
>
> >You can't. You shouldn't need to convert to localtime inside the kernel.
> >What, precisely, are you trying to achieve?
>
> As an example, a filesystem might internally store local times in its
> inodes. You may not be free to change the on-disk format.

Such as FAT and derived filesystems?

That's why Linux has sys_tz. Though I think that a mount option to
override that might have been wise.

MfG Kai