- 操作系统版本
root@ubuntu:~/vm_disk_dpdk/study/drive/examples/scull# sudo lsb_release -a
No LSB modules are available.
- Distributor ID: Ubuntu
Description: Ubuntu 14.04.3 LTS
Release: 14.04
Codename: trusty
root@ubuntu:~/vm_disk_dpdk/study/drive/examples/scull# uname -a
Linux ubuntu 3.13.0-66-generic #108-Ubuntu SMP Wed Oct 7 15:20:27 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
- 问题一:scripts/Makefile.build:49: *** CFLAGS was changed in "/home/enjoy/vm_disk_dpdk/study/drive/examples/scull/Makefile". Fix it to use ccflags-y. Stop.
change
CFLAGS += $(PSTN_DEF) -Wall -O $(INCLUDES) -fno-common -DTARGET_CATAWBA
to
EXTRA_CFLAGS += $(PSTN_DEF) -Wall -O $(INCLUDES) -fno-common -DTARGET_CATAWBA
and try
you could use something like this:
sed -i 's/^CFLAGS/EXTRA_CFLAGS/' Makefile
- 问题二:/home/enjoy/vm_disk_dpdk/study/drive/examples/scull/main.c:17:26: fatal error: linux/config.h: No such file or directory
现在不用config.h,而是autoconf.h
root@ubuntu:/usr/src/linux-headers-3.13.0-66-generic/include/linux# ln -s ../generated/autoconf.h config.h
root@ubuntu:/usr/src/linux-headers-3.13.0-66-generic/include/linux# ll config.h
lrwxrwxrwx 1 root root 23 Dec 10 01:01 config.h -> ../generated/autoconf.h
- 问题三:/home/enjoy/vm_disk_dpdk/study/drive/examples/scull/main.c:32:46: fatal error: asm/system.h: No such file or directory
直接注释,有问题后面接着加别的头文件
This file was removed in Linux 3.4, commit f05e798ad4c0; its contents have been moved into various other headers.
It's possible that just removing the #include <asm/system.h>
might work, but it's much more likely that your driver is simply incompatible with current Linux versions.
- 问题四:/home/enjoy/vm_disk_dpdk/study/drive/examples/scull/main.c:556:2: error: unknown field ‘ioctl’ specified in initializer
这个错误网上搜索发现2.6.38版本内核 file_operation结构体已经删除了ioctl函数,取代的是:
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
file_operation结构体在 include/linux/fs.h定义
解决方案:
替换为unlocked_ioctl 即可,注意函数原型,第一个参数不需要(代码中没用到),还有返回值为long类型。
- 问题五:/home/enjoy/vm_disk_dpdk/study/drive/examples/scull/main.c:652:3: error: implicit declaration of function ‘init_MUTEX’ [-Werror=implicit-function-declaration]
2.6.25及以后的linux内核版本废除了init_MUTEX函数,新版本使用sema_init函数
static inline void init_MUTEX (struct semaphore *sem) { sema_init(sem, 1); }
- 问题六:include/linux/wait.h:307:31: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
增加头文件:#include <linux/sched.h>
- 问题七:/usr/src/linux-source-3.2.0/drivers/scull/access.c:98:34: error: ‘SPIN_LOCK_UNLOCKED’未声明(不在函数内)
将:static spinlock_t scull_u_lock = SPIN_LOCK_UNLOCKED;
改为:static DEFINE_SPINLOCK(scull_u_lock);
- 问题八:
/usr/src/linux-source-3.2.0/drivers/scull/access.c:107:29: 错误: 提领指向不完全类型的指针
解决办法是在access.c中就加入两个头文件 #include<linux/sched.h>
- 问题九:‘struct task_struct’ has no member named ‘uid’、‘euid’
/home/enjoy/vm_disk_dpdk/study/drive/examples/scull/access.c:107:29: error: ‘struct task_struct’ has no member named ‘uid’
/home/enjoy/vm_disk_dpdk/study/drive/examples/scull/access.c:108:29: error: ‘struct task_struct’ has no member named ‘euid’
current->uid 修改为 current->cred->uid.val
current->euid 修改为 current->cred->euid.val
http://blog.csdn.net/zjq_1990/article/details/51684912