编译驱动scull出错后解决方案

编译驱动scull出错后解决方案

1、scripts/Makefile.build:49: *** CFLAGS was changed in "/home/robin/drivers/scull/Makefile". Fix it to use EXTRA_CFLAGS.  Stop.

将makefile中的 CFLAGS 替换成 EXTRA_CFLAGS就可以了。

原因是在2.6的内核的版本中所有的 EXTRA_ 变量只在所定义的Kbuild Makefile中起作用。EXTRA_ 变量可    以在Kbuild Makefile中所有命令中使用。    $(EXTRA_CFLAGS) 是用 $(CC) 编译C源文件时的选项。   

2、error: 'TASK_INTERRUPTIBLE' undeclared (first use in this function)

错误定位行,原因缺少头文件 #include <linux/sched.h> 添加后即可通过编译 !微笑


3、scull:
main.c时提示错误:main.c:17:26: error: linux/config.h: No such file or directory

解决办法:把#include<linux/config.h>注释掉或者在内核源码中创建空的config.h文件,从2.6.19后的新版本的内核已经不再包含config.h文件了,

4、/home/robin/drivers/scull/access.c: In function ‘scull_w_available’:
/home/robin/drivers/scull/access.c:165: error: ‘struct task_struct’ has no member named ‘uid’
/home/robin/drivers/scull/access.c:166: error: ‘struct task_struct’ has no member named ‘euid’
/home/robin/drivers/scull/access.c: In function ‘scull_w_open’:
/home/robin/drivers/scull/access.c:184: error: ‘struct task_struct’ has no member named ‘uid’

根据提示,错误在于task_struct结构体没有uid,euid成员变量,查看源码发现struct task_struct定义在include/linux/sched.h中,确实没有这两个成员,逐个成员分析发现,这两个成员在2.6.35内核中放在const struct cred *cred成员中了,所以,我们尝试将所有出现错误的地方做如下改动:

current->uid 修改为 current->cred->uid

current->euid 修改为 current->cred->euid

接着make,发现成功编译。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值