i practise to write a simple linux kernel module, creating a file in the /proc/driver folder. the code works fine, but i got a question.
my question is when looking up the proc_fs.h header file, the definition of proc_root_driver is set to NULL. why still i can create a file under /proc/driver w/t any error occurred?
my code is as below:
Code:
#include <linux/module.h>
#include <linux/proc_fs.h>
MODULE_LICENSE("GPL");
int
init(void)
{
printk(KERN_INFO "[create_proc_file_lkm]init function!\n");
/*create_proc_entry("my_test", 0644, NULL);*/
create_proc_entry("my_test", 0644, proc_root_driver);
return 0;
}
void
exit(void)
{
struct proc_root_driver *root_drv;
printk(KERN_INFO "[create_proc_file_lkm]exit function!\n");
remove_proc_entry("my_test", proc_root_driver);
return;
}
module_init(init);
module_exit(exit);