Created
January 5, 2020 22:07
-
-
Save cvam0000/fa7320cee96af022e4ed340157c0aa76 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<linux/module.h> | |
#include<linux/init.h> | |
#include<linux/kernel.h> | |
#include<linux/fs.h> | |
MODULE_LICENSE("GPL"); | |
MODULE_AUTHOR("CVAM"); | |
MODULE_VERSION("0.1"); | |
dev_t dev=MKDEV(235,0); // dev is the dev_t structure variable for major and minor no. | |
static int static_init_no(void) | |
{ | |
register_chrdev_region(dev,1,"ohmyarch_dev"); | |
printk(KERN_INFO "Major = %d Minor = %d \n", MAJOR(dev),MINOR(dev)); | |
printk(KERN_ALERT "Module Inserted Successfully"); | |
return 0; | |
} | |
static void exit_driver(void) | |
{ | |
unregister_chrdev_region(dev,1); | |
printk(KERN_INFO "Time to leave the planet kernel"); | |
} | |
module_init(static_init_no); | |
module_exit(exit_driver); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment