(1)将yaffs2代码加入内核
这可以通过yaffs2目录下的脚本文件patch-ker.sh来给内核打补丁,用法如下:
usage: ./patch-ker.sh c/l kernelpath
if c/l is c, then copy. if l then link.
这表明,如果c/l是c,则yaffs2的代码会被复制到内核目录下,如果是l,则在内核的目录下创建一些链接文件。这里yaff2所在的目录/root/linux-test/,和linux-2.6.32.2在同一个目录下,执行如下命令打补丁:
[root@localhost yaffs2]# ./patch-ker.sh c /root/linux-test/linux-2.6.32.2
usage: ./patch-ker.sh c/l m/s kernelpath
if c/l is c, then copy. If l then link
if m/s is m, then use multi version code. If s then use single version code
[root@localhost yaffs2]# ./patch-ker.sh c s /root/linux-test/linux-2.6.32.2
*** Warning ***
You have chosen to use the single kernel variant of the yaffs VFS glue code
that only works with the latest Linux kernel tree. If you are using an older
version of Linux then you probably wanted to use the multi-version variant by
re-running the patch-ker.sh script using m as a the second argument.
ie ./patch-ker.sh c m /root/linux-test/linux-2.6.32.2
Updating /root/linux-test/linux-2.6.32.2/fs/Kconfig
Updating /root/linux-test/linux-2.6.32.2/fs/Makefile
[root@localhost yaffs2]#
注意第二个参数m/s,如果不指定,有时会执行失败。
上述命令完成下面三件事:
<1>修改内核文件/fs/Kconfig,增加下面两行(在177行附近):
if MISC_FILESYSTEMS
source "fs/adfs/Kconfig"
source "fs/affs/Kconfig"
source "fs/ecryptfs/Kconfig"
source "fs/hfs/Kconfig"
source "fs/hfsplus/Kconfig"
source "fs/befs/Kconfig"
source "fs/bfs/Kconfig"
source "fs/efs/Kconfig"
source "fs/yaffs2/Kconfig"
source "fs/jffs2/Kconfig"
# UBIFS File system configuration
<2>修改内核文件/fs/Makefile,增加下面两行(在129行附近):
obj-$(CONFIG_GFS2_FS) += gfs2/
obj-$(CONFIG_EXOFS_FS) += exofs/
obj-$(CONFIG_YAFFS_FS) += yaffs2/
<3>在内核文件的fs目录下创建yaffs2子目录,然后复制如下文件:
将yaffs2源码目录下的Makefile.kernel文件复制为内核fs/yaffs2/Makefile文件。
将yaffs2源码目录下的Kconfig文件复制为内核fs/yaffs2/目录下。
将yaffs2源码目录下的*.c、*.h文件(不包括子目录下的文件)复制为内核fs/yaffs2/目录下。
本篇文章来源于 Linux公社网站(www.linuxidc.com) 原文链接:http://www.linuxidc.com/Linux/2012-11/74829.htm