Chinaunix首页 | 论坛 | 博客
  • 博客访问: 222701
  • 博文数量: 34
  • 博客积分: 741
  • 博客等级: 上士
  • 技术积分: 606
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-08 09:54
文章分类

全部博文(34)

文章存档

2016年(1)

2015年(1)

2014年(1)

2013年(1)

2012年(30)

分类: LINUX

2012-07-03 18:34:14

编译环境Ubuntu12.04   linux-3.2

    1. make -C /lib/modules/3.2.0/build M=/home/wrk/works/drivers/ldd3/examples/scull LDDINC=/home/wrk/works/drivers/ldd3/examples/scull/../include modules
    2. make[1]: Entering directory `/home/wrk/works/drivers/linux-kernel/linux-3.2'
    3. scripts/Makefile.build:49: *** CFLAGS was changed in "/home/wrk/works/drivers/ldd3/examples/scull/Makefile". Fix it to use ccflags-y. Stop.
    如提示所示:在Makefile中用ccflags-y替换CFLAGS                                             

    1. /home/wrk/works/drivers/ldd3/examples/scull/main.c:17:26: fatal error: linux/config.h: No such file or directory
    2. compilation terminated.
    3. make[2]: *** [/home/wrk/works/drivers/ldd3/examples/scull/main.o] Error 1
    直接删掉config.h这行

    1. /home/wrk/works/drivers/ldd3/examples/scull/main.c:556:2: error: unknown field ‘ioctl’ specified in initializer
    2. /home/wrk/works/drivers/ldd3/examples/scull/main.c:556:2: warning: initialization from incompatible pointer type [enabled by default]
    unlocded_ioctl替换ioctl

    1. /home/wrk/works/drivers/ldd3/examples/scull/main.c:652:3: error: implicit declaration of function ‘init_MUTEX’ [-Werror=implicit-function-declaration]
    2. cc1: some warnings being treated as errors
    解决方案:在相应文件开始添加
    1. #include <linux/semaphore.h>
    2. #define init_MUTEX(a) sema_init(a,1)
    3. #define init_MUTEX_LOCKED(a) sema_init(a,0)

    1. /home/wrk/works/drivers/ldd3/examples/scull/pipe.c: In function ‘scull_p_read’:
    2. /home/wrk/works/drivers/ldd3/examples/scull/pipe.c:131:7: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
    3. /home/wrk/works/drivers/ldd3/examples/scull/pipe.c:131:7: note: each undeclared identifier is reported only once for each function it appears in
    4. /home/wrk/works/drivers/ldd3/examples/scull/pipe.c:131:3: error: implicit declaration of function ‘signal_pending’ [-Werror=implicit-function-declaration]
    5. /home/wrk/works/drivers/ldd3/examples/scull/pipe.c:131:3: error: implicit declaration of function ‘schedule’ [-Werror=implicit-function-declaration]
    在pipe.c和access.c中添加“#include <linux/sched.h>"

    1. /home/wrk/works/drivers/ldd3/examples/scull/access.c:101:34: error: ‘SPIN_LOCK_UNLOCKED’ undeclared here (not in a function)

    原因:新版本内核中,SPIN_LOCK_UNLOCKED被移除

    建议:使用DEFINE_SPINLOCK(lock)宏来替代

    1. /*static spinlock_t scull_w_lock = SPIN_LOCK_UNLOCKED;*改成下面到方式/
    2. static DEFINE_SPINLOCK(scull_w_lock);

    1. /home/wrk/works/drivers/ldd3/examples/scull/access.c:111:29: error: ‘struct task_struct’ has no member named ‘uid’
    2. /home/wrk/works/drivers/ldd3/examples/scull/access.c:112:29: error: ‘struct task_struct’ has no member named ‘euid’
    3. /home/wrk/works/drivers/ldd3/examples/scull/access.c:119:26: 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,就大功告成了
阅读(2627) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~