Re: print current date and time in a kernel module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In my understading, "xtime" variable stores the current time and date, which has

tv_sec - seconds elapsed since January 1, 1970 (UTC)
tv_nsec - nanoseconds in the last second

- Manoj

On Jan 22, 2008 7:34 PM, Erik Mouw <mouw@xxxxxxxxxxxx> wrote:
On Tue, Jan 22, 2008 at 06:17:29PM +0530, Kathiresan, Lekshmanan wrote:
>    I want to print current date and time in a kernel module.
>
>   1) do we have direct functions that we could use in kernel?

No.

>    2) Can get time from epoch using gettimeofday? So, how do I convert
> it to the current date and time string. Is there something similar to
>
>      userspace ctime in kernel?

You don't. The kernel doesn't have an idea about current date and time.
Date and time depends on timezone rules, and that's userspace. If you
need date and time of your local timezone in your kernel module, your
module is broken by design.


Erik

--
They're all fools. Don't worry. Darwin may be slow, but he'll
eventually get them. -- Matthew Lammers in alt.sysadmin.recovery

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHlff5/PlVHJtIto0RAv8tAJ4qZXc0fWrWiFW6edrigxG7L1hpzgCbBsQW
QGoZuRnkNPoNjE144TohLeI=
=nP2q
-----END PGP SIGNATURE-----



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux