编译 scull 的问题

配套代码可以在http://www.oreilly.com.cn/codeexample/ldd3sc/ 下载
我的内核版本是 4.13.0-32-generic
由于LDD3使用的版本比较老,在新版本上会有编译问题。下面对scull 的编译问题做个总结
- Makefile报错
scripts/Makefile.build:49: * CFLAGS was changed in “/linux_device/driver/scull/Makefile”. Fix it to use EXTRA_CFLAGS. Stop.
将makefile中的 CFLAGS 替换成 EXTRA_CFLAGS

  • linux/config.h: No such file or directory
    原因是2.6.19之后的内核没有了config.h文件,因此直接把对应的include注释掉即可。

asm/system.h 要替换成 linux/slab.h

asm/uaccess.h 要替换成 linux/uaccess.h

  • ioctrl 报错
    取消了原先的
      int (ioctl)(struct inode, struct file*, unsigned int, unsigned long);
    添加来新的成员
    long (unlocked_ioctl) (struct file , unsigned int, unsigned long);原来的ioctl 但是返回值变为long

  • init_MUTEX 没有了
    改成 sema_init(&sema,1)

  • SPIN_LOCK_UNLOCKED 找不到
    //static spinlock_t scull_u_lock = SPIN_LOCK_UNLOCKED;
    static DEFINE_SPINLOCK(scull_u_lock);

  • uid 找不到
    current->uid 修改为 current->cred->uid.val
    current->euid 修改为 current->cred->euid.val

  • /access.c:287:26: error: dereferencing pointer to incomplete type ‘struct signal_struct’
    signal 结构定义在sched/signal.h里,在access.c中加入

#include <linux/sched/signal.h>
  • 找不到 signal_pending
    在pipe.c 中加入
#include <linux/sched/signal.h>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值