#include<linux/kernel.h>
#include<linux/module.h>
#if CONFIG_MODVERSIONS==1
#define MODVERSIONS
#include<linux/modversions.h>
#endif
int init_module()
{
printk("Hello!This is a testing module!\n");
return 0;
}
void cleanup_module()
{
printk("Sorry!The testing module is unloading now!\n");
}
int open(struct inode*inode,struct file*filp)
{
MOD_INC_USE_COUNT;
printk("This module is in open!\n");
return 0;
}
void release(struct inode*inode,struct file*filp)
{
MOD_DEC_USE_COUNT;
printk("This module is in release!\n");
return 0;
#ifdef DEBUG
printk("release(%p,%p)\n",inode,filp);
#endif
}
int read(struct inode*inode, struct file*filp, char*buf, int count)
{
int leave;
if(verify_area(VERIFY_WRITE, buf, count)==DEFAULT)
return DEFAULT;
for(leave=count;leave>0;leave--)
{
__put_user(1,buf,1);
buf++;
}
return count;
}