#include <linux/version.h>
#include <linux/kernel.h>
#include <linux/jiffies.h>
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/fs.h>
#include <linux/types.h>
#include <linux/string.h>
#include <linux/socket.h>
#include <linux/errno.h>
#include <linux/fcntl.h>
#include <linux/in.h>
#include <linux/init.h>
#include <linux/miscdevice.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <asm/system.h>
#include <asm/uaccess.h>
#include <asm/io.h>
#include <linux/mm.h>
#include <net/checksum.h>
#include <linux/cdev.h>
static int t_open(struct inode *inode, struct file *filp)
{
return nonseekable_open(inode, filp);
}
static struct file_operations testmod_fops = {
.open = t_open,
.owner = THIS_MODULE
};
static struct miscdevice testmod_miscdev = {
MISC_DYNAMIC_MINOR,
"my_module",
&testmod_fops,
};
static int __init testmod_init(void)
{
printk("module is on\n");
misc_register(&testmod_miscdev);
return 0;
};
static void __exit testmod_exit(void)
{
printk("about exit \n");
misc_deregister(&testmod_miscdev);
}
module_init(testmod_init);
module_exit(testmod_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("0x90");
MODULE_DESCRIPTION("my_module");
why do I get the errno2 in this simple example?
Basically you’d have to enter the internal module name and not the file name. You can find the module name by typing
lsmod.So
rmmod <your_module_name>should work.