免费注册 查看新帖 |

Chinaunix

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

insmod命令加载Hello,World模块问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-05-25 09:26 |只看该作者 |倒序浏览
我的LINUX内核是2.6.9。我按照《LINUX设备驱动程序》第三版里的“Hello,World”示例来测试,
程序名为hello.c      程序如下;
#include<linux/init.h>
#include<linux/module.h>
MODULE_LICENSE,("Dual BSD/GPL");
static int hello_init(void)
{
    printk(KERN_ALERT "Hello,world\n");
    return 0;
}
staic void hello_exit(void)
{
    printk(KERN_ALERT "Goodbye,cruel world\n");
  }
   module_init(hello_init);
   module_exit(hello_exit);

makefile文件内容是:
  obj-m := hello.o
我用make来编译很顺利,产生了hello.mod.c  ,hello.o ,hello.ko,hello.mod.o四个文件,
在用下列命令来加载:insmod ./hello.ko,可出现以下结果:
bash: insmo:command not found.
怎么结果说找不到命令,我还试着加载其他文件,都出现同样的错误。
不会出现书上'Hello,world"字符串的结果。真是奇怪,到底是哪出了问题?还请指点下。
以上命令都是在超级用户下执行的,而且都是按照书上所写的内容自己去做测试。

[ 本帖最后由 linye09 于 2007-5-25 13:28 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2007-05-25 13:32 |只看该作者
怎么没人帮我解答?
高手快近来指点指点我这个新手啊!
谢谢谢谢!!!!!!!!!


呵呵,我自己先up下

论坛徽章:
0
3 [报告]
发表于 2007-05-29 11:51 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
4 [报告]
发表于 2007-05-29 11:52 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
5 [报告]
发表于 2007-05-29 16:18 |只看该作者
有可能是你安装的系统里面没有安装insmod,rmmod这些命令。他一般包含在modutils的rpm包里。
你可以通过命令查看自己的系统是否已经安装modutils

rpm -qa | grep modutils

我的RH9输出是
modutils-2.4.22-8
modutils-devle-2.4.22-8

论坛徽章:
0
6 [报告]
发表于 2007-05-29 16:25 |只看该作者
tail /var/log/messsages

论坛徽章:
0
7 [报告]
发表于 2007-05-29 17:34 |只看该作者
bash: insmo:command not found.

你的命令打错了
insmod ./xxx.ko

论坛徽章:
0
8 [报告]
发表于 2007-05-29 18:03 |只看该作者
我又执行了几次,结果是这样:
[root@localhost hello]# insmod ./hello.ko
[root@localhost hello]# insmod ./hello.ko
insmod: error inserting './hello.ko': -1 File exists
[root@localhost hello]# insmod ./hello.ko
insmod: error inserting './hello.ko': -1 File exists
[root@localhost hello]# insmod hello.o
insmod: error inserting 'hello.o': -1 Invalid module format
[root@localhost hello]# insmod hello.ko
insmod: error inserting 'hello.ko': -1 File exists
我是按照书上的命令:insmod ./hello.ko ,来执行,就是不行,命令没有打错吧.
谢谢!!!

论坛徽章:
0
9 [报告]
发表于 2007-05-29 18:05 |只看该作者
原帖由 gomo1234 于 2007-5-29 16:18 发表于 5楼  
有可能是你安装的系统里面没有安装insmod,rmmod这些命令。他一般包含在modutils的rpm包里。
你可以通过命令查看自己的系统是否已经安装modutils

rpm -qa | grep modutils

我的RH9输出是
modutils-2. ...



我按你的做法,可什么反应都没有,为什么啊???
请看我的结果:
[root@localhost ~]# rpm -qa | grep modules
[root@localhost ~]# rpm -qa|grep modules
[root@localhost ~]#
谢谢!!!

论坛徽章:
0
10 [报告]
发表于 2007-05-29 18:19 |只看该作者
原帖由 maluyao 于 2007-5-29 16:25 发表于 6楼  
tail /var/log/messsages



你的命令我已经执行了,可出现了些信息,我看不太懂,请看:
May 29 18:10:01 localhost crond(pam_unix)[7009]: session opened for user root by (uid=0)
May 29 18:10:01 localhost crond(pam_unix)[7010]: session opened for user root by (uid=0)
May 29 18:10:01 localhost crond(pam_unix)[7009]: session closed for user root
May 29 18:10:02 localhost crond(pam_unix)[7010]: session closed for user root
还请高手帮忙解决解决.
谢谢啊!!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP