#include <linux/kernel.h> /* Needed by all modules */
#include <linux/module.h> /* Needed for KERN_* */
#include <linux/init.h> /* Needed for the macros */
#include <asm/current.h> /* Macro current point to the current process */
#include <linux/sched.h>
MODULE_LICENSE("GPL");
static int hello_init(void)
{
// current->comm是进程名, current->pid是进程PID;
printk(KERN_WARNING "the process is \"%s\"(pid %i)\n", current->comm, current->pid); return 0;
}
static void hello_exit(void) {
printk("Bye, kernel!\n");
}
/* main module function */
module_init(hello_init);
module_exit(hello_exit);