tony之linux driver_LDD3_scull字符设备驱动编译在新内核编译问题
2011-09-20 23:22
711 查看
在编译ldd3的scull程序的时候碰到编译不通过的情况,发现遇到的问题和下面的哥们遇到的问题一样,
照着做了一下,解决问题,记录于此。
/*******************************************************************************************************************************************/
最近在看《LINUX设备驱动程序》,给出的字符设备驱动程序scull,在linux 2.6.32-22内核上make编译时出现了下面的问题:
make -C /lib/modules/2.6.32-22-generic/build M=/home/savi0r/Desktop/linux设备驱动开发/examples/scull LDDINC=/home/savi0r/Desktop/linux设备驱动开发/examples/scull/../include modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.32-22-generic'
scripts/Makefile.build:49: *** CFLAGS was changed in "/home/savi0r/Desktop/linux设备驱动开发/examples/scull/Makefile". Fix it to use EXTRA_CFLAGS. Stop.
make[1]: *** [_module_/home/savi0r/Desktop/linux设备驱动开发/examples/scull] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-22-generic'
make: *** [modules] Error 2
打开Makefile,将CFLAGS屏蔽掉:
# CFLAGS += $(DEBFLAGS)
# CFLAGS += -I$(LDDINC)
继续make,又出现了下面的问题:
make -C /lib/modules/2.6.32-22-generic/build M=/home/savi0r/Desktop/linux设备驱动开发/examples/scull LDDINC=/home/savi0r/Desktop/linux设备驱动开发/examples/scull/../include modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.32-22-generic'
CC [M] /home/savi0r/Desktop/linux设备驱动开发/examples/scull/main.o
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/main.c:17:26: error: linux/config.h: No such file or directory
make[2]: *** [/home/savi0r/Desktop/linux设备驱动开发/examples/scull/main.o] Error 1
make[1]: *** [_module_/home/savi0r/Desktop/linux设备驱动开发/examples/scull] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-22-generic'
make: *** [modules] Error 2
linux/config.h文件找不到,可能时新版内核结构改变了,这个文件被删除了吧。
打开main.c,把#include <linux/config.h>删除掉。
继续make,还有问题:
make -C /lib/modules/2.6.32-22-generic/build M=/home/savi0r/Desktop/linux设备驱动开发/examples/scull LDDINC=/home/savi0r/Desktop/linux设备驱动开发/examples/scull/../include modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.32-22-generic'
CC [M] /home/savi0r/Desktop/linux设备驱动开发/examples/scull/main.o
CC [M] /home/savi0r/Desktop/linux设备驱动开发/examples/scull/pipe.o
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/pipe.c: In function ‘scull_p_read’:
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/pipe.c:131: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/pipe.c:131: error: (Each undeclared identifier is reported only once
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/pipe.c:131: error: for each function it appears in.)
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/pipe.c:131: error: implicit declaration of function ‘signal_pending’
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/pipe.c:131: error: implicit declaration of function ‘schedule’
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/pipe.c: In function ‘scull_getwritespace’:
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/pipe.c:168: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/pipe.c: In function ‘scull_p_write’:
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/pipe.c:219: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/pipe.c:223: error: ‘SIGIO’ undeclared (first use in this function)
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/pipe.c:223: error: ‘POLL_IN’ undeclared (first use in this function)
make[2]: *** [/home/savi0r/Desktop/linux设备驱动开发/examples/scull/pipe.o] Error 1
make[1]: *** [_module_/home/savi0r/Desktop/linux设备驱动开发/examples/scull] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-22-generic'
make: *** [modules] Error 2
TASK_INTERRUPTIBLE找不到,既然前面删除掉了了一个头文件,必然有很多变量找不到,
那就到/usr/src/linux-headers-2.6.32-22-generic下grep一下呗:
最终找到头文件,添加上:
#include <linux/sched.h>
access.c也需要添加上面的头文件。
然后,还得make,痛苦阿。。。。
make -C /lib/modules/2.6.32-22-generic/build M=/home/savi0r/Desktop/linux设备驱动开发/examples/scull LDDINC=/home/savi0r/Desktop/linux设备驱动开发/examples/scull/../include modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.32-22-generic'
CC [M] /home/savi0r/Desktop/linux设备驱动开发/examples/scull/access.o
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/access.c: In function ‘scull_u_open’:
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/access.c:107: error: ‘struct task_struct’ has no member named ‘uid’
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/access.c:108: error: ‘struct task_struct’ has no member named ‘euid’
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/access.c:115: error: ‘struct task_struct’ has no member named ‘uid’
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/access.c: In function ‘scull_w_available’:
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/access.c:166: error: ‘struct task_struct’ has no member named ‘uid’
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/access.c:167: error: ‘struct task_struct’ has no member named ‘euid’
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/access.c: In function ‘scull_w_open’:
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/access.c:185: error: ‘struct task_struct’ has no member named ‘uid’
make[2]: *** [/home/savi0r/Desktop/linux设备驱动开发/examples/scull/access.o] Error 1
make[1]: *** [_module_/home/savi0r/Desktop/linux设备驱动开发/examples/scull] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-22-generic'
make: *** [modules] Error 2
说task_struct结构体没有uid,euid成员变量,struct task_struct定义在include/linux/sched.h中,这主要是由于原来task_struct结构体定义有所改动,将uid和euid等挪到 cred中,见include/linux/sched.h和include/linux/cred.h。
因此只需要将报error的代码做如下修改
current->uid 修改为 current->cred->uid
current->euid 修改为 current->cred->euid
然后编译,即可通过。
/*******************************************************************************************************************************************/
在redhat2.6.9.55上面编译是OK的,貌似LDD3是基于内核2.6.10来写的。
照着做了一下,解决问题,记录于此。
/*******************************************************************************************************************************************/
最近在看《LINUX设备驱动程序》,给出的字符设备驱动程序scull,在linux 2.6.32-22内核上make编译时出现了下面的问题:
make -C /lib/modules/2.6.32-22-generic/build M=/home/savi0r/Desktop/linux设备驱动开发/examples/scull LDDINC=/home/savi0r/Desktop/linux设备驱动开发/examples/scull/../include modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.32-22-generic'
scripts/Makefile.build:49: *** CFLAGS was changed in "/home/savi0r/Desktop/linux设备驱动开发/examples/scull/Makefile". Fix it to use EXTRA_CFLAGS. Stop.
make[1]: *** [_module_/home/savi0r/Desktop/linux设备驱动开发/examples/scull] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-22-generic'
make: *** [modules] Error 2
打开Makefile,将CFLAGS屏蔽掉:
# CFLAGS += $(DEBFLAGS)
# CFLAGS += -I$(LDDINC)
继续make,又出现了下面的问题:
make -C /lib/modules/2.6.32-22-generic/build M=/home/savi0r/Desktop/linux设备驱动开发/examples/scull LDDINC=/home/savi0r/Desktop/linux设备驱动开发/examples/scull/../include modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.32-22-generic'
CC [M] /home/savi0r/Desktop/linux设备驱动开发/examples/scull/main.o
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/main.c:17:26: error: linux/config.h: No such file or directory
make[2]: *** [/home/savi0r/Desktop/linux设备驱动开发/examples/scull/main.o] Error 1
make[1]: *** [_module_/home/savi0r/Desktop/linux设备驱动开发/examples/scull] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-22-generic'
make: *** [modules] Error 2
linux/config.h文件找不到,可能时新版内核结构改变了,这个文件被删除了吧。
打开main.c,把#include <linux/config.h>删除掉。
继续make,还有问题:
make -C /lib/modules/2.6.32-22-generic/build M=/home/savi0r/Desktop/linux设备驱动开发/examples/scull LDDINC=/home/savi0r/Desktop/linux设备驱动开发/examples/scull/../include modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.32-22-generic'
CC [M] /home/savi0r/Desktop/linux设备驱动开发/examples/scull/main.o
CC [M] /home/savi0r/Desktop/linux设备驱动开发/examples/scull/pipe.o
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/pipe.c: In function ‘scull_p_read’:
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/pipe.c:131: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/pipe.c:131: error: (Each undeclared identifier is reported only once
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/pipe.c:131: error: for each function it appears in.)
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/pipe.c:131: error: implicit declaration of function ‘signal_pending’
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/pipe.c:131: error: implicit declaration of function ‘schedule’
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/pipe.c: In function ‘scull_getwritespace’:
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/pipe.c:168: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/pipe.c: In function ‘scull_p_write’:
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/pipe.c:219: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/pipe.c:223: error: ‘SIGIO’ undeclared (first use in this function)
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/pipe.c:223: error: ‘POLL_IN’ undeclared (first use in this function)
make[2]: *** [/home/savi0r/Desktop/linux设备驱动开发/examples/scull/pipe.o] Error 1
make[1]: *** [_module_/home/savi0r/Desktop/linux设备驱动开发/examples/scull] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-22-generic'
make: *** [modules] Error 2
TASK_INTERRUPTIBLE找不到,既然前面删除掉了了一个头文件,必然有很多变量找不到,
那就到/usr/src/linux-headers-2.6.32-22-generic下grep一下呗:
最终找到头文件,添加上:
#include <linux/sched.h>
access.c也需要添加上面的头文件。
然后,还得make,痛苦阿。。。。
make -C /lib/modules/2.6.32-22-generic/build M=/home/savi0r/Desktop/linux设备驱动开发/examples/scull LDDINC=/home/savi0r/Desktop/linux设备驱动开发/examples/scull/../include modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.32-22-generic'
CC [M] /home/savi0r/Desktop/linux设备驱动开发/examples/scull/access.o
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/access.c: In function ‘scull_u_open’:
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/access.c:107: error: ‘struct task_struct’ has no member named ‘uid’
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/access.c:108: error: ‘struct task_struct’ has no member named ‘euid’
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/access.c:115: error: ‘struct task_struct’ has no member named ‘uid’
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/access.c: In function ‘scull_w_available’:
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/access.c:166: error: ‘struct task_struct’ has no member named ‘uid’
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/access.c:167: error: ‘struct task_struct’ has no member named ‘euid’
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/access.c: In function ‘scull_w_open’:
/home/savi0r/Desktop/linux设备驱动开发/examples/scull/access.c:185: error: ‘struct task_struct’ has no member named ‘uid’
make[2]: *** [/home/savi0r/Desktop/linux设备驱动开发/examples/scull/access.o] Error 1
make[1]: *** [_module_/home/savi0r/Desktop/linux设备驱动开发/examples/scull] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-22-generic'
make: *** [modules] Error 2
说task_struct结构体没有uid,euid成员变量,struct task_struct定义在include/linux/sched.h中,这主要是由于原来task_struct结构体定义有所改动,将uid和euid等挪到 cred中,见include/linux/sched.h和include/linux/cred.h。
因此只需要将报error的代码做如下修改
current->uid 修改为 current->cred->uid
current->euid 修改为 current->cred->euid
然后编译,即可通过。
/*******************************************************************************************************************************************/
在redhat2.6.9.55上面编译是OK的,貌似LDD3是基于内核2.6.10来写的。
相关文章推荐
- [linux设备驱动程序]scull字符设备驱动编译在新内核编译问题解决方案
- linux设备驱动——scull源码编译问题
- linux下编译新内核,解决无法找到eth0设备问题,安装eth0网卡驱动
- 简单的LINUX字符设备驱动及编译进Linux内核…
- Linux字符设备驱动-globalmem驱动编译加载遇到的问题及解决办法
- 利用linux 内核所提供的input子系统编写字符设备驱动的步骤
- Linux内核部件分析--设备驱动模型之device-driver
- ldd3 源码编译之 scullc 字符设备驱动 错误解决办法
- linux 2.6内核 字符设备驱动 相关函数
- linux内核字符设备驱动之发送命令接口
- 在Ubuntu 9.04 内核2.6.32.2 上编译Linux driver edit3 例子详解scull
- linux驱动开发之字符设备--内核和用户空间数据的交换(ioctl)
- 在编写最简单的linux 内核驱动, 编译后出现的问题以及解决方法。
- Linux 内核--总线设备驱动模型(字符/块/网络设备 && platform设备)
- 编译LDD3的scull驱动问题总结
- linux内核之字符设备驱动图解
- Linux 内核设备驱动之GPIO驱动之GPIO GPIO字符设备初始化
- 从 2.4 到 2.6:Linux 内核可装载模块机制的改变对设备驱动的影响—linux2.4单独编译驱动模块
- Linux 内核编译,解决网卡驱动缺少的问题,使用更新的内核来完善驱动
- Linux内核部件分析 设备驱动模型之device-driver