error in time program
I tried this program for getting current time but i am getting errors.
code:
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include<linux/time.h>
static int
hz_show(struct seq_file *m, void *v)
{
struct timeval time;
unsigned long local_time;
do_gettimeofday(&time);
local_time = (u32)(time.tv_sec - (sys_tz.tz_minuteswest * 60));
rtc_time_to_tm(local_time, &tm);
printk(" @ (%04d-%02d-%02d %02d:%02d:%02d)\n", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
return 0;
}
static int
hz_open(struct inode *inode, struct file *file)
{
return single_open(file, hz_show, NULL);
}
static const struct file_operations hz_fops = {
.owner = THIS_MODULE,
.open = hz_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static int __init
hz_init(void)
{
printk(KERN_INFO "Loading hz module, HZ = %d.\n", HZ);
proc_create("hi", 0, NULL, &hz_fops);
return 0;
}
static void __exit
hz_exit(void)
{
remove_proc_entry("hz", NULL);
printk(KERN_INFO "Unloading hz module.\n");
}
module_init(hz_init);
module_exit(hz_exit);
MODULE_LICENSE("GPL");
error:
In function ‘hz_show’:
/home/s/lt.c:16: error: implicit declaration of function ‘rtc_time_to_tm ’
/home/s/lt.c:16: error: ‘tm’ undeclared (first use in this function)
/home/s/lt.c:16: error: (Each undeclared identifier is reported only once /home/s/lt.c:16: error: for each function it appears in.)
make[2]: *** [/home/s/lt.o] Error 1
make[1]: *** [_module_/home/s] Error 2
How should i correct this?
|