/* * hello-2.c - 演示module_init()和module_exit()宏 * 这比使用init_module()和cleanup_module()更受欢迎 */ #include /* 初始化需要的宏 */ #include /* 内核模块必要的头 */ #include /* 引入 pr_info() */ static int __init hello_2_init(void) { pr_info("你好 2\n"); return 0; } static void __exit hello_2_exit(void) { pr_info("再见 2\n"); } module_init(hello_2_init); module_exit(hello_2_exit); MODULE_LICENSE("GPL");