Here is my source code —-
#include
#include
#include
#include
#include
#include
#ifndef DEBUG
#define DEBUG
#endif
MODULE_LICENSE(“GPL”);
MODULE_AUTHOR(“VAIBHAV”);
MODULE_DESCRIPTION(“Simple Modules init and exit”);
static short int data=4;
static int i=2;
static long int j=1;
static char *si=” vaibhav “;
static int pvtdata __initdata=1234;
static int __init vaibhav(void)
{
#ifdef DEBUG
printk(KERN_INFO “Begin !%s \n”,__func__);
#endif
#ifdef DEBUG
printk(KERN_ALERT “hello kernel !\n”);
#endif
#ifdef DEBUG
printk(KERN_ALERT “data=%d \t i=%d \t j=%ld\t si=%s\t pvtdata=%d\n”,data,i,j,si,pvtdata);
#endif
#ifdef DEBUG
printk(KERN_ALERT “The process is %s and its pid is %d \n”,current->comm,current->pid );
#endif
#ifdef DEBUG
printk(KERN_INFO “%s End\n”,__func__);
#endif
return 0;
}
module_init(vaibhav);
module_param(data,short,S_IRUGO);
module_param(i,int,S_IRUGO );
module_param(j,long,S_IRUGO);
module_param(si,charp,S_IRUGO);
module_param(pvtdata,int,S_IRUGO);
static void __exit vaibhav1(void)
{
#ifdef DEBUG
printk(KERN_INFO “Begin !%s \n”,__func__);
#endif
#ifdef DEBUG
printk(KERN_ALERT “Execution compleate \n”);
#endif
#ifdef DEBUG
printk(KERN_INFO “%s End \n”,__func__);
#endif
}
module_exit(vaibhav1);