2440移植Linux Kernel笔记(四)------yaffs2打补丁

本文介绍了解决YAFFS2文件系统在新内核上遇到的兼容性问题的方法,包括修改源码以适配新内核的结构变化,并更新编译配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

你好!这里是风筝的博客,

欢迎和我一起交流。

 


cd /work/system/
获取yaffs2源码:
git clone git://www.aleph1.co.uk/yaffs2

记得要安装git才能获取源码(

安装git:sudo apt-get install git

这里我们下载的yaffs2官网上2017年5月(最新)的源码:

http://download.youkuaiyun.com/detail/guet_kite/9856481

)
cd yaffs2/


打补丁:
cd yaffs2/
./patch-ker.sh c m /work/system/linux-4.4.66
cd /work/system/linux-4.4.66/
make menuconfig
选中:File systems->Miscellaneous filesystems->yaffs2 file system support
make uImage 

开始编译内核.

报错:
fs/yaffs2/yaffs_vfs.c: In function 'yaffs_readpage_nolock':
fs/yaffs2/yaffs_vfs.c:299: error: 'struct file' has no member named 'f_dentry'
fs/yaffs2/yaffs_vfs.c: In function 'yaffs_hold_space':
fs/yaffs2/yaffs_vfs.c:497: error: 'struct file' has no member named 'f_dentry'
fs/yaffs2/yaffs_vfs.c: In function 'yaffs_release_space':
fs/yaffs2/yaffs_vfs.c:515: error: 'struct file' has no member named 'f_dentry'
fs/yaffs2/yaffs_vfs.c: In function 'yaffs_file_write':
fs/yaffs2/yaffs_vfs.c:607: error: 'struct file' has no member named 'f_dentry'
fs/yaffs2/yaffs_vfs.c:619: error: 'struct file' has no member named 'f_dentry'
fs/yaffs2/yaffs_vfs.c: In function 'yaffs_file_flush':
fs/yaffs2/yaffs_vfs.c:743: error: 'struct file' has no member named 'f_dentry'
fs/yaffs2/yaffs_vfs.c: At top level:
fs/yaffs2/yaffs_vfs.c:794: error: 'new_sync_read' undeclared here (not in a function)
fs/yaffs2/yaffs_vfs.c:795: error: 'new_sync_write' undeclared here (not in a function)
fs/yaffs2/yaffs_vfs.c:1050: warning: initialization from incompatible pointer type
fs/yaffs2/yaffs_vfs.c: In function 'yaffs_follow_link':
fs/yaffs2/yaffs_vfs.c:1106: error: implicit declaration of function 'nd_set_link'
fs/yaffs2/yaffs_vfs.c: At top level:
总的来说就是内核版本太新了,yaffs支持未跟上.
现在我们可以自己修改yaffs文件.

 

First error).error: 'struct file' has no member named 'f_dentry’:
由于新内核的file结构体发生了变化,把f_dentry这个成员放到了path结构体(include/linux/path.h)里.
在fs.h(include/linux/fs.h)加上:
#define f_dentry f_path.dentry

Second error).error: 'new_sync_read' undeclared here (not in a function):
新内核没有"new_sync_read"和"new_sync_write"这两个导出函数了.
修改yaffs_vfs.c的794、795行为:
.read = __vfs_read,
.write = __vfs_write,
Third error).error: implicit declaration of function 'nd_set_link':
由于我们Kernel太新,内核里已经不用nd_set_link这个函数了.在老内核中找到源码:
static inline void nd_set_link(struct nameidata *nd, char *path)
{
    nd->saved_names[nd->depth] = path;
}
但是新的kernel没有这个函数了,而且nameidata结构体的定义也变了,因此要修改用到这个函数的地方.主要就是yaffs_follow_link这个函数.
yaffs_follow_link的定义主要参考include/Linux/fs.h里的struct inode_operations.follow_link来定义 .
以前的alias是保存在 nd->saved_names里,现在这个成员已经被删除了,现在我们直接通过函数返回值返回,并且保存在*cookie中

 

 

make uImage

发现,编译内核成功!

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值