美文网首页
内核编程入门

内核编程入门

作者: 码畜笔记 | 来源:发表于2020-03-11 16:43 被阅读0次

转载:https://www.cnblogs.com/bitor/p/9608725.html

1、hello world

//必要的头文件

#include<linux/module.h>

#include<linux/kernel.h>

#include<linux/init.h>

//模块许可证声明(必须)

MODULE_LICENSE("Dual BSD/GPL");

//模块加载函数(必须)

staticinthello_init(void){

    printk(KERN_ALERT "Hello World enter/n");

    return 0;

}

//模块卸载函数(必须)

staticvoidhello_exit(void){

    printk(KERN_ALERT "Hello World exit/n");

}

//模块的注册

module_init(hello_init);

module_exit(hello_exit);

//声明模块的作者(可选)

MODULE_AUTHOR("XXX");

//声明模块的描述(可选)

MODULE_DESCRIPTION("This is a simple example!/n");

//声明模块的别名(可选)

MODULE_ALIAS("A simplest example");

相关文章

网友评论

      本文标题:内核编程入门

      本文链接:https://www.haomeiwen.com/subject/pkxhjhtx.html