博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
LDDR3中scull编译问题
阅读量:4051 次
发布时间:2019-05-25

本文共 2697 字,大约阅读时间需要 8 分钟。

于实验室需要,要学习Linux下的驱动开发,正好自己也好好学习linux下的驱动开发,但是书本的代码编写碰到一个问题,就是在Ubuntu下不能编译,经过网上的搜索后,找到如下一篇博客,非常不错,如下: 
编译LDD3-scull
1、提示scripts/Makefile.build:46:*** CFLAGS was changed in "/home/chenfang/scull/Makefile",Fix it use EXTRA_CFLAGS.Stop.:
 
由于LDD3使用的是2.6.10内核,很多东西已经发生了变化,这里提示我们修改Makefile中的CFLAGS,用EXTRA_CFLAGS代替,照它说的做就可以。
2、提示找不到文件linux/config.h:
 
 
在2.6.19开始的内核中删除了config.h文件,因此只要在mian.c中注释掉#include<linux/config.h>即可。
3、提示access.c中存在:dereferencing pointer to incomplete type 错误:
在 源码中发现只能是current存在错误,current应该是一个task_struct类型的全局变量,查找task_struct存在于 linux/sched.h中,因此在access.c中加入#include<linux/sched.h>,重新make即可。
顺便看下current这个全局变量是在哪里定义的:
在source ininsight中查找得到的current类似于以下的定义:
static inline struct task_struct *get_current(void) __attribute_const__;
static inline struct task_struct *get_current(void)
{
 
return current_thread_info()->task;
}
#define current (get_current())
可 见,current其实是一个“伪全局变量”,是函数get_current()的宏定义。当access.c中使用current->uid时, 就调用了get_current()函数,从而返回task_struct结构的task,因此current->uid就相当于 task->uid。
之前在Ubuntu里编译scull时有错误,还好有网友提供了解决办法,即删除config.h文件和增加#include 两个头文件:capability.h和sched.h
最近将Ubuntu升级到9.10版本后,重新生成了2.6.31版本的内核树,没想到编译scull模块时出现新的
/home/dengwei/eclipse_workspace/scull/access.c:108: error: ‘struct task_struct’ has no member named ‘uid’
/home/dengwei/eclipse_workspace/scull/access.c:109: error: ‘struct task_struct’ has no member named ‘euid’
/home/dengwei/eclipse_workspace/scull/access.c:116: error: ‘struct task_struct’ has no member named ‘uid’
/home/dengwei/eclipse_workspace/scull/access.c: In function ‘scull_w_available’:
/home/dengwei/eclipse_workspace/scull/access.c:167: error: ‘struct task_struct’ has no member named ‘uid’
/home/dengwei/eclipse_workspace/scull/access.c:168: error: ‘struct task_struct’ has no member named ‘euid’
/home/dengwei/eclipse_workspace/scull/access.c: In function ‘scull_w_open’:
/home/dengwei/eclipse_workspace/scull/access.c:186: error: ‘struct task_struct’ has no member named ‘uid’
原因:
 
 
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
make success
结果:
root@dw:/home/dengwei/eclipse_workspace/scull# ls
access.c  
 
 
main.o  
 
 
 
 
Module.symvers  
scull.init  
scull.mod.o
access.o  
 
 
Makefile  
 
 
 
pipe.c  
 
 
 
 
scull.ko  
 
scull.o
_desktop.ini  
Module.markers  
pipe.o  
 
 
 
 
scull_load  
scull_unload
main.c  
 
 
 
modules.order  
scull.h  
 
 
 
scull.mod.c
root@dw:/home/dengwei/eclipse_workspace/scull# insmod scull.ko
按照上面提示,就可以顺利编译成ko文件,其中include/linux在我的Linux中绝对路径名是
/usr/src/linux-headers-2.6.32-21/include/linux
本篇文章来源于 Linux公社网站(www.linuxidc.com)  
原文链接:file:///D:/Src/Ubuntu下编译LDD3-scull例子时遇到的一些问题.mht

转载地址:http://ilsci.baihongyu.com/

你可能感兴趣的文章
ReactNative使用Redux例子
查看>>
Promise的基本使用
查看>>
coursesa课程 Python 3 programming 统计文件有多少单词
查看>>
coursesa课程 Python 3 programming 输出每一行句子的第三个单词
查看>>
Returning a value from a function
查看>>
coursesa课程 Python 3 programming Functions can call other functions 函数调用另一个函数
查看>>
course_2_assessment_6
查看>>
coursesa课程 Python 3 programming course_2_assessment_7 多参数函数练习题
查看>>
coursesa课程 Python 3 programming course_2_assessment_8 sorted练习题
查看>>
在unity中建立最小的shader(Minimal Shader)
查看>>
1.3 Debugging of Shaders (调试着色器)
查看>>
关于phpcms中模块_tag.class.php中的pc_tag()方法的含义
查看>>
vsftp 配置具有匿名登录也有系统用户登录,系统用户有管理权限,匿名只有下载权限。
查看>>
linux安装usb wifi接收器
查看>>
多线程使用随机函数需要注意的一点
查看>>
getpeername,getsockname
查看>>
关于对象赋值及返回临时对象过程中的构造与析构
查看>>
VS 2005 CRT函数的安全性增强版本
查看>>
Visual Studio 2010:C++0x新特性
查看>>
drwtsn32.exe和adplus.vbs进行dump文件抓取
查看>>