added more to kernel module
This commit is contained in:
parent
9aa949736e
commit
b5737cb31e
2 changed files with 47 additions and 7 deletions
53
code/lkm.c
53
code/lkm.c
|
@ -4,23 +4,64 @@
|
|||
#include <linux/proc_fs.h>
|
||||
#include <linux/uaccess.h>
|
||||
|
||||
#define DEVICE_NAME "lkm"
|
||||
|
||||
static int lkm_init(void);
|
||||
static int lkm_exit(void);
|
||||
int lkm_open(struct inode *, struct file *);
|
||||
int lkm_release(struct inode *, struct file *);
|
||||
long lkm_ioctl(struct file *, unsigned int, long unsigend int);
|
||||
|
||||
module_init(lkm_init);
|
||||
module_exit(lkm_exit);
|
||||
|
||||
static struct file_operations lkm_fops = {
|
||||
.owner = "",
|
||||
.open = lkm_open,
|
||||
.release = lkm_release,
|
||||
.unlocked_ioctl = lkm_ioctl,
|
||||
};
|
||||
|
||||
MODULE_AUTHOR("Mira Chacku Purakal");
|
||||
MODULE_DESCRIPTION("Generic Module");
|
||||
MODULE_VERSION("0.1");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
static int
|
||||
mod_init(void)
|
||||
lkm_init(void)
|
||||
{
|
||||
printk(KERN_INFO "module init");
|
||||
int ret;
|
||||
printk(KERN_INFO "lkm: init: start");
|
||||
|
||||
ret = register_chrdev(0, DEVICE_NAME, &lkm_fops);
|
||||
if (ret < 0) {
|
||||
printk(KERN_ERR "lkm: init: register chrdev failed");
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
mod_exit(void)
|
||||
lkm_exit(void)
|
||||
{
|
||||
printk(KERN_INFO "module exit");
|
||||
printk(KERN_INFO "lkm: exit: start");
|
||||
}
|
||||
|
||||
module_init(mod_init);
|
||||
module_exit(mod_exit);
|
||||
int
|
||||
lkm_open(struct inode *inode, struct file *fp)
|
||||
{
|
||||
printk(KERN_INFO "lkm: open: start")
|
||||
}
|
||||
|
||||
int
|
||||
lkm_release(struct inode *inode, struct file *fp)
|
||||
{
|
||||
printk(KERN_INFO "lkm: release: start")
|
||||
}
|
||||
|
||||
long
|
||||
lkm_ioctl(struct file *fp, unsigned int num, long unsigned int param)
|
||||
{
|
||||
printk(KERN_INFO "lkm: release: start")
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
gnumake
|
||||
clang-tools
|
||||
gcc
|
||||
linuxHeaders
|
||||
texlab
|
||||
texliveFull
|
||||
flex
|
||||
|
|
Loading…
Add table
Reference in a new issue