移植YAFFS2文件系统到linux3.18.4内核(原)

时间:2022-09-19 09:06:16
移植YAFFS文件系统:  (linux-3.18.4内核)
 
1.git clone git://www.aleph1.co.uk/yaffs2  //用此获得yaffs2源码包
 
1.1 解压源码包
 
2. 打补丁
cd yaffs-dir
./patch-ker.sh  c m linux-tree   比如 ./patch-ker.sh c m /home/fedora/workspace/linux-3.18.4
 
 
3. 配置内核支持YAFFS
-> File systems                                                     |
  |       -> Miscellaneous filesystems (MISC_FILESYSTEMS [=y])              |
  |         -> yaffs2 file system support (YAFFS_FS [=n])                   |
  |           -> 512 byte / page devices (YAFFS_YAFFS1 [=n])                |
  |             -> Use older-style on-NAND data format with pageStatus byte
选上,使用默认值

4. 编译、使用zImage
   make ARCH=arm CROSS_COMPILE=arm-linux- zImage
编译出现错误:

fs/yaffs2/yaffs_vfs.c: In function 'yaffs_file_flush':
fs/yaffs2/yaffs_vfs.c:741: error: too few arguments to function 'yaffs_flush_file'
fs/yaffs2/yaffs_vfs.c: In function 'yaffs_sync_object':
fs/yaffs2/yaffs_vfs.c:771: error: too few arguments to function 'yaffs_flush_file'
fs/yaffs2/yaffs_vfs.c: At top level:
fs/yaffs2/yaffs_vfs.c:781: error: 'generic_file_aio_read' undeclared here (not in a function)
fs/yaffs2/yaffs_vfs.c:782: error: 'generic_file_aio_write' undeclared here (not in a function)
fs/yaffs2/yaffs_vfs.c:787: error: 'generic_file_splice_write' undeclared here (not in a function)
fs/yaffs2/yaffs_vfs.c: In function 'yaffs_flush_inodes':
fs/yaffs2/yaffs_vfs.c:2190: error: too few arguments to function 'yaffs_flush_file'
fs/yaffs2/yaffs_vfs.c: In function 'yaffs_flush_super':
fs/yaffs2/yaffs_vfs.c:2203: error: too few arguments to function 'yaffs_flush_whole_cache'

 

代码修改如下:

diff --git a/yaffs_vfs.c b/yaffs_vfs.c
index 76bc1db..f6e4ec2 100755
--- a/yaffs_vfs.c
+++ b/yaffs_vfs.c
@@ -738,7 +738,7 @@ static int yaffs_file_flush(struct file *file)

yaffs_gross_lock(dev);

- yaffs_flush_file(obj, 1, 0);
+ yaffs_flush_file(obj, 1, 0, 1);

yaffs_gross_unlock(dev);

@@ -768,7 +768,7 @@ static int yaffs_sync_object(struct file *file, struct dentry *dentry,
yaffs_trace(YAFFS_TRACE_OS | YAFFS_TRACE_SYNC,
"yaffs_sync_object");
yaffs_gross_lock(dev);
- yaffs_flush_file(obj, 1, datasync);
+ yaffs_flush_file(obj, 1, datasync, 1);
yaffs_gross_unlock(dev);
return 0;
}
@@ -778,13 +778,13 @@ static int yaffs_sync_object(struct file *file, struct dentry *dentry,
static const struct file_operations yaffs_file_operations = {
.read = do_sync_read,
.write = do_sync_write,
- .aio_read = generic_file_aio_read,
- .aio_write = generic_file_aio_write,
+ .read_iter = generic_file_read_iter,
+ .write_iter = generic_file_write_iter,
.mmap = generic_file_mmap,
.flush = yaffs_file_flush,
.fsync = yaffs_sync_object,
- .splice_read = generic_file_splice_read,
- .splice_write = generic_file_splice_write,
+ .splice_read = generic_file_splice_read,
+ .splice_write = iter_file_splice_write,
.llseek = generic_file_llseek,
};

@@ -2187,7 +2187,7 @@ static void yaffs_flush_inodes(struct super_block *sb)
yaffs_trace(YAFFS_TRACE_OS,
"flushing obj %d",
obj->obj_id);
- yaffs_flush_file(obj, 1, 0);
+ yaffs_flush_file(obj, 1, 0, 1);
}
}
}
@@ -2200,7 +2200,7 @@ static void yaffs_flush_super(struct super_block *sb, int do_checkpoint)

yaffs_flush_inodes(sb);
yaffs_update_dirty_dirs(dev);
- yaffs_flush_whole_cache(dev);
+ yaffs_flush_whole_cache(dev, 1);
if (do_checkpoint)
yaffs_checkpoint_save(dev);
}

重新编译:
 

CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
make[1]: “include/generated/mach-types.h”是最新的。
CALL scripts/checksyscalls.sh
CHK include/generated/compile.h
CC fs/yaffs2/yaffs_vfs.o
CC fs/yaffs2/yaffs_guts.o
CC fs/yaffs2/yaffs_checkptrw.o
CC fs/yaffs2/yaffs_packedtags1.o
CC fs/yaffs2/yaffs_packedtags2.o
CC fs/yaffs2/yaffs_nand.o
CC fs/yaffs2/yaffs_tagscompat.o
CC fs/yaffs2/yaffs_tagsmarshall.o
CC fs/yaffs2/yaffs_mtdif.o
CC fs/yaffs2/yaffs_nameval.o
CC fs/yaffs2/yaffs_attribs.o
CC fs/yaffs2/yaffs_allocator.o
CC fs/yaffs2/yaffs_yaffs1.o
CC fs/yaffs2/yaffs_yaffs2.o
CC fs/yaffs2/yaffs_bitmap.o
CC fs/yaffs2/yaffs_summary.o
CC fs/yaffs2/yaffs_verify.o
LD fs/yaffs2/yaffs.o
LD fs/yaffs2/built-in.o
LD fs/built-in.o
LINK vmlinux
LD vmlinux.o
MODPOST vmlinux.o
GEN .version
CHK include/generated/compile.h
UPD include/generated/compile.h
CC init/version.o
LD init/built-in.o
KSYM .tmp_kallsyms1.o
KSYM .tmp_kallsyms2.o
LD vmlinux
SORTEX vmlinux
SYSMAP System.map
OBJCOPY arch/arm/boot/Image
Kernel: arch/arm/boot/Image is ready
GZIP arch/arm/boot/compressed/piggy.gzip
AS arch/arm/boot/compressed/piggy.gzip.o
LD arch/arm/boot/compressed/vmlinux
OBJCOPY arch/arm/boot/zImage
Kernel: arch/arm/boot/zImage is ready

OK!