How to use derived class instance in a base class?
How to use derived class instance in a base class?
April 26, 2022
What is Exploratory Testing?
What is Exploratory Testing?
May 10, 2022

May 3, 2022

Kernel Module init and cleanup functions

Kernel modules must have at least two functions: a "start" (initialization) function called init_module() which is called when the module is insmoded into the kernel, and an "end" (cleanup) function called cleanup_module() which is called just before it is rmmoded. Actually, things have changed starting with kernel 2.3.13. You can now use whatever name you like for the start and end functions of a module. In fact, the new method is the preferred method.

#include <linux/module.h> /* Needed by all modules */ 
#include <linux/kernel.h> /* Needed for KERN_INFO */ 
#include <linux/init.h> /* Needed for the macros */

static int __init new_method_init(void)
{
  printk (KERN_INFO "Hello, world 2\n"); 
  return 0;

}
static void exit new_method_exit(void)
{
  printk (KERN_INFO "Goodbye, world 2\n");
}
module_init(new_method_init); 
module_exit(new_method_exit);
Kernel Module init and cleanup functions
This website uses cookies to improve your experience. By using this website you agree to our Data Privacy Statement
Read more