首页 新闻 论坛 群组 Blog 文档 下载 读书 Tag 网摘 搜索 .NET Java 游戏 视频 人才 外包 培训 数据库 书店 程序员
中国软件网
欢迎您:游客 | 登录 注册 帮助
  • 编译模块 出现Entering directory `/usr/src/kernels/2.6.9-11.EL-i686'是什么原因?
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-07-06 19:40:11 楼主
    提示如下
    [root@localhost Module_test2]# make
    make -C /lib/modules/2.6.9-11.EL/build M=/root/home/Module_test2
    make[1]: Entering directory `/usr/src/kernels/2.6.9-11.EL-i686'
      LD      /root/home/Module_test2/built-in.o
      CC [M]  /root/home/Module_test2/hello.o
      Building modules, stage 2.
      MODPOST
      CC      /root/home/Module_test2/hello.mod.o
      LD [M]  /root/home/Module_test2/hello.ko
    make[1]: Leaving directory `/usr/src/kernels/2.6.9-11.EL-i686'
    [root@localhost Module_test2]#

    源代码如下
    #include <linux/module.h>
    #include <linux/config.h>
    #include <linux/init.h>   

    static int __init hello_init(void)
    {
      printk("Hello module init\n");
      return 0;
    }

    static void __exit hello_exit(void)
    {
      printk("Hello module exit\n");
    }

    module_init(hello_init); 
    module_exit(hello_exit);
    MODULE_LICENSE("GPL");

    Makefile如下
    # Makefile2.6
    ifneq ($(KERNELRELEASE),)
    #kbuild syntax. dependency relationshsip of files and target modules are listed here.
    mymodule-objs := hello.o
    obj-m := hello.o
    else
    PWD := $(shell pwd)
    KVER ?= $(shell uname -r)
    KDIR := /lib/modules/$(KVER)/build
    all:
    $(MAKE) -C $(KDIR) M=$(PWD)
    clean:
    rm -rf .*.cmd *.o *.mod.c *.ko .tmp_versions
    endif

    请高手指点
    20  修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-07-07 01:10:261楼 得分:0

    tail /var/log/messages
    可以看到下面的信息
    [root@localhost Module_test2]#  tail /var/log/messages
    Jul  7 00:19:56 localhost htt_server[1739]: status has not been enabled yet. (1,  1)
    Jul  7 00:20:17 localhost htt_server[1739]: status has not been enabled yet. (1,  2)
    Jul  7 00:20:33 localhost last message repeated 9 times
    Jul  7 00:20:54 localhost htt_server[1739]: status has not been enabled yet. (1,  1)
    Jul  7 00:22:10 localhost htt_server[1739]: status has not been enabled yet. (1,  2)
    Jul  7 00:22:12 localhost htt_server[1739]: status has not been enabled yet. (1,  2)
    Jul  7 00:22:18 localhost htt_server[1739]: status has not been enabled yet. (1,  1)
    Jul  7 00:22:20 localhost htt_server[1739]: status has not been enabled yet. (1,  2)
    Jul  7 00:22:32 localhost htt_server[1739]: status has not been enabled yet. (1,  1)
    Jul  7 00:57:03 localhost last message repeated 2 times


    在日志中只是找到\u5740\u201cxml:readwrite:/root/.gconf\u201d\u89e3\u6790\u4e3a\u4f4d\u4e8e 0 \u7684\u53ef\u5199\u5165\u914d\u7f6e\u6e90
    Jul  7 00:12:37 localhost kernel: Hello module init
    Jul  7 00:17:57 localhost htt_server[1739]: status has not been enabled yet. (1, 1)
    没有找到Hello module exit的打印
    但是
    [root@localhost Module_test2]# lsmod ¦ grep hello
    hello                  1536  0

    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-07-07 08:38:252楼 得分:0
    printk("Hello module init\n");

    修改为:
    printk(KERN_ALERT "Hello module init\n");
    试试..
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-07-07 19:47:523楼 得分:0
    修改后的结果

    [root@localhost Module_test2]# insmod ./hello.ko
    [root@localhost Module_test2]# tail /var/log/messages
    Jul  7 19:31:15 localhost fstab-sync[2388]: added mount point /media/floppy for /dev/fd0
    Jul  7 19:33:04 localhost gdm(pam_unix)[2262]: session opened for user root by (uid=0)
    Jul  7 19:33:06 localhost gconfd (root-2424): 正在启动(版本 2.8.1),pid 2424 用 户“root”
    Jul  7 19:33:07 localhost gconfd (root-2424): 地址“xml:readonly:/etc/gconf/gconf.xml.mandatory”解析为位于 0 的只读配置源
    Jul  7 19:33:07 localhost gconfd (root-2424): 地址“xml:readwrite:/root/.gconf”解析为位于 1 的可写入配置源
    Jul  7 19:33:07 localhost gconfd (root-2424): 地址“xml:readonly:/etc/gconf/gconf.xml.defaults”解析为位于 2 的只读配置源
    Jul  7 19:33:09 localhost htt_server[1704]: Client shut down the connection owned by im_id(1).
    Jul  7 19:33:51 localhost gconfd (root-2424): 地址“xml:readwrite:/root/.gconf”解析为位于 0 的可写入配置源
    Jul  7 19:43:37 localhost kernel: Hello module init
    Jul  7 19:44:40 localhost htt_server[1704]: status has not been enabled yet. (1, 1)
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-07-08 08:40:054楼 得分:0
    如果要看到“Hello module exit”
    就必须运行

    #rmmod hello.ko
    或者
    #rmmod hello
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-07-08 11:48:595楼 得分:0
    这提示信息不是成功的标志吗????
    修改 删除 举报 引用 回复

    网站简介广告服务网站地图帮助联系方式诚聘英才English 问题报告
    北京创新乐知广告有限公司 版权所有 京 ICP 证 070598 号
    世纪乐知(北京)网络技术有限公司 提供技术支持
    Copyright © 2000-2008, CSDN.NET, All Rights Reserved