QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 895|回复: 4

升级内核的问题

[复制链接]
发表于 2005-3-7 09:15:18 | 显示全部楼层 |阅读模式
看linux设备驱动程序一书,第一个例子,
hello world

//hello.c

#define MODULE
#include <linux/module.h>
int init_module(void)
{ printk("<1>Hello world\n");return 0;}
void cleanup_module(void)
{ printk("<1>Goodbye cruel world\n");}

我的系统用的是redhat 9,
gcc -c hello.c
没有任何问题,但是下面却出现这样的问题,是怎么一会事呀,
[root@localhost /]# insmod ./hello.o
./hello.o: kernel-module version mismatch
./hello.o was compiled for kernel version 2.4.28
while this kernel is version 2.4.20-8.

按照书上说的我在程序里加了 #define __NO_VERSION__,都没有用,我是装了redhat9后自己重新编译使用2。4。28的内核,请教是不是头文件问题,怎么把头文件路径指向这个新内核的?还有<<linux设备驱动程序>>里的例子或函数接口是不是都过时了,我看好多都用不了,像kerneld.h这个文件根本就没有;current这个变量也没有(看sched.h里)。谢谢!
 楼主| 发表于 2005-3-7 10:17:51 | 显示全部楼层
[root@localhost /]# gcc -I/usr/src/linux-2.4/include -D __KERNEL__ -c modt.c
[root@localhost /]# insmod modt.o
Warning: loading modt.o will taint the kernel: no license
  See http://www.tux.org/lkml/#export-tainted for information about tainted
modules
Module modt loaded, with warnings
[root@localhost /]# gcc -I/usr/src/linux-2.4/include -c modt.c
[root@localhost /]# insmod modt.o
insmod: a module named modt already exists
[root@localhost /]# rmmod modt.o
rmmod: module modt.o is not loaded
回复

使用道具 举报

发表于 2005-3-7 10:24:23 | 显示全部楼层
搜索本版或编程版,以前的帖子有答案,应该在精华区里
回复

使用道具 举报

 楼主| 发表于 2005-3-7 15:16:46 | 显示全部楼层
我查看/proc/modules文件,显示 modt 812 0(unused)
可是这又删不掉,我修改程序编译的新模块也insmod不了,没法试,请教怎么办,谢谢!!
回复

使用道具 举报

发表于 2005-3-7 16:12:29 | 显示全部楼层
卸载模块用rmmod modt试试
不用全名,只用前缀

关于
./hello.o was compiled for kernel version 2.4.28
while this kernel is version 2.4.20-8.

查找一下编程版的精华区,记得以前有答案
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-5-21 03:40 , Processed in 0.360001 second(s), 16 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表