您的位置:首页 > 其它

第一个内核测试程序

2016-04-30 00:00 190 查看
1.在vmware安装上centos

网络设置,参考http://blog.sina.com.cn/s/blog_3e4dd88d0100yaur.html,注意在centos 右上角的网络图标选择对应的网络设备。

2.安装gcc环境

yum install gcc-c++

3.安装内核文件

yum install kernel-devel

4.编写hello.c文件

例子参考:http://edsionte.com/techblog/archives/1336

#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
//必选
//模块许可声明
MODULE_LICENSE("GPL");
//模块加载函数
static int hello_init(void)
{
printk(KERN_ALERT"hello,I am edsionte\n");
return 0;
}
//模块卸载函数
static void hello_exit(void)
{
printk(KERN_ALERT"goodbye,kernel\n");
}
//模块注册
module_init(hello_init);
module_exit(hello_exit);
//可选
MODULE_AUTHOR("edsionte Wu");
MODULE_DESCRIPTION("This is a simple example!\n");
MODULE_ALIAS("A simplest example");



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: