在使用命令ismod helloworld.ko 加载编译成功的模块helloworld.ko时出现错误
一般出错信息被记录在文件/var/log/messages中
[root@hailiang linux-2.6.15.5]# cat /var/log/messages |tail
通过命令看一下模块的相关信息
[root@hailiang tmp]# modinfo helloworld.ko
filename:
alias:
description:
author:
depends:
vermagic:
#include <linux/module.h>
#include <linux/vermagic.h>
#include <linux/compiler.h>
MODULE_INFO(vermagic, VERMAGIC_STRING);找到这个符号,
打开文件/usr/src/kernels/2.6.27.5-117.fc10.i686/include/linux/vermagic.h
#include <linux/utsrelease.h>
#include <linux/module.h>
#ifdef CONFIG_SMP
#define MODULE_VERMAGIC_SMP "SMP "
#else
#define MODULE_VERMAGIC_SMP ""
#endif
。。。。。。。。。。。。。。。。。。。
#ifdef CONFIG_MODVERSIONS
#define MODULE_VERMAGIC_MO
DVERSIONS "modversions "
#else
#define MODULE_VERMAGIC_MODVERSIONS ""
#endif
#ifndef MODULE_ARCH_VERMAGIC
#define MODULE_ARCH_VERMAGIC ""
#endif
#define VERMAGIC_STRING
从这里看出vermagic中多出来的字符modversions是由于编译内核时选上了 “”选项的原因,(其实这是因为在编译helloworld模块前,自己曾试图重新编译内核所致:cd /usr/src/kernel..
[root@hailiang 2.6.27.5-117.fc10.i686]# make menuconfig
scripts/kconfig/mconf arch/x86/Kconfig
#
# configuration written to .config
#
*** End of Linux kernel configuration.
*** Execute 'make' to build the kernel or try 'make help'.
[root@hailiang 2.6.27.5-117.fc10.i686]# make
scripts/kconfig/conf -s arch/x86/Kconfig
make[1]: *** No rule to make target `missing-syscalls'.
make: *** [prepare0] Error 2
)见下图
然后再重新编译helloworld.ko模块,然后再加载helloworld 成功。
(2)在这里直接modprobe
FATAL: Module helloworld not found.
这是因为
使用man modprobe看
DESCRIPTION
modprobe会自动在/lib/modules/'uname -r'下寻找模块加载,将helloworld.ko拷到/lib/modules 下然后再执命令 modprobe helloworld 发现还是找不到,从man modprobe
看出还需要依赖命令:depmod生成的module.dep