免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1900 | 回复: 3
打印 上一主题 下一主题

编写2.6驱动程序出现问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-08-06 17:32 |只看该作者 |倒序浏览
[root@local doc]# cat /var/log/messages
..........
Aug  6 16:51:04 local kernel: d: version magic '2.6.23.1-42.fc8 SMP mod_unload 686 4KSTACKS ' should be '2.6.25.11-60.fc8 SMP mod_unload 686 4KSTACKS '
[root@local doc]# uname -r
2.6.25.11-60.fc8


编写下面的代码总是显示insmod: error inserting './d.ko': -1 Invalid module format
#include <linux/module.h>&nbsp;&nbsp;&nbsp;&nbsp;/* Needed by all modules */
#include <linux/kernel.h>&nbsp;&nbsp;&nbsp;&nbsp;/* Needed for KERN_ALERT */
#include <linux/init.h>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Needed for the macros */
MODULES_LICENSE("GPL");
static int hello3_data __initdata = 3;

static int __init hello_3_init(void)
{
&nbsp;&nbsp;&nbsp;&nbsp;printk(KERN_ALERT "Hello, world %d\n", hello3_data);
&nbsp;&nbsp;&nbsp;&nbsp;return 0;
}

static void __exit hello_3_exit(void)
{
&nbsp;&nbsp;&nbsp;&nbsp;printk(KERN_ALERT "Goodbye, world 3\n");
}

module_init(hello_3_init);
module_exit(hello_3_exit);

论坛徽章:
0
2 [报告]
发表于 2008-08-15 15:34 |只看该作者
能具体点么? 你如何编译的?

论坛徽章:
0
3 [报告]
发表于 2008-08-16 23:10 |只看该作者
it is really a problem
you should be more careful.
you are compiling your code with a source does not match you kernel which you are running.

[ 本帖最后由 conjurator 于 2008-8-16 23:15 编辑 ]

论坛徽章:
0
4 [报告]
发表于 2008-08-24 00:52 |只看该作者
楼上正解。
楼主编译模块的时候用的内核代码版本和运行的系统的版本不一致。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP