this code creates the module named dc_clock_mod in /proc folder.
I will place my additional code in the init_module function.
Code:
#include<linux/kernel.h>
#include<linux/module.h>
#include<linux/proc_fs.h>
#define BUF_LEN 50
int read_my_clock( char *a, char **b, off_t c, int d, int e)
{
printk(KERN_ALERT, "\nread_my_clock\n") ;
/* this is the function that I write to read
the clock file info that I created in proc
*/
}
struct proc_dir_entry dc_clock_mod_file = {
0,
12,
"dc_clock_mod",
S_IFREG | S_IRUGO,
1,
0,
0,
BUF_LEN,
NULL,
read_my_clock,
NULL
};
int init_module()
{
return proc_register(&proc_root, &dc_clock_mod_file);
}
void cleanup_module()
{
proc_unregister(&proc_root, dc_clock_mod_file.low_ino) ;
}