1、./scripts/Makefile.build:49: *** CFLAGS was changed in "/home/jerry/luo/module/examples/scull/Makefile". Fix it to use ccflags-y.
很明确了。直接将Makefile的CFLAGS改成ccflags-y。
2、 fatal error: linux/config.h: No such file or directory
#include <linux/config.h>
直接注释掉。
3、fatal error: asm/system.h: No such file or directory
#include <asm/system.h> /* cli(), *_flags */
3.3以后的内核用switch_to.h 替代了 system.h
4、 error: unknown field ‘ioctl’ specified in initializer
.ioctl = scull_ioctl,
原先的
int (*ioctl)(struct inode*, struct file*, unsigned int, unsigned long);
被改为了
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
5、implicit declaration of function ‘init_MUTEX’ [-Werror=implicit-function-declaration]
init_MUTEX(&scull_devices[i].sem);
3.x内核以后用sema_init(xxxxxx);
6、‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
改为static DEFINE_SPINLOCK(scull_u_lock);
8、error: ‘struct task_struct’ has no member named ‘uid’
error: ‘struct task_struct’ has no member named ‘euid’
加头文件cred.h,将 current->uid改为current->cred->uid,current->euid改为current->cred->euid
9、error: invalid operands to binary != (have ‘uid_t’ and ‘kuid_t’)
error: incompatible types when assigning to type ‘uid_t’ from type ‘kuid_t’
首先是类型不匹配。kuid_t类型:
typedef struct {
uid_t val;
} kuid_t;
改为current->cred->uid.val;
current->cred->euid.val;
剩下还会报一些警告,是因为unclocked_ioctl与ioctl的指针指向的类型不太一样。改一下就好了。
本文针对在编译Linux内核模块过程中遇到的多种典型错误进行了详细解析,并提供了有效的修正方法,包括修改Makefile配置、注释或替换过时的头文件引用、调整函数声明及参数类型等。
372

被折叠的 条评论
为什么被折叠?



