yaffs2 文件系统在Linux上的移植问题


最近刚学嵌入式Linux这块儿,在参考朱兆琪 的 《嵌入式Linux手册》中的文件系统移植,书中写到

yaffs2 文件系统在Linux上的移植问题_第1张图片




















下载好yaffs2之后打补丁,之后配置,在执行make uImage,可是没有出现书中所说的错误,在网上搜索一些资料,在Linux 2.6之后确实存在 yaffs2 在Linux 上的移植问题,

大概原因是 之后的Linux版本的 VFS发生了一些变化。但当我下载 亚飞yaffs2后,并给Linux打补丁,make uImage ,发现并没有问题,这是什么原因的?当我打开文件

./Linux 3.6.7/fs/yaffs2/yaffs2_vfs.c 文件,发现了一个地方


/*
 * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
 *
 * Copyright (C) 2002-2011 Aleph One Ltd.
 *   for Toby Churchill Ltd and Brightstar Engineering
 *
 * Created by Charles Manning 
 * Acknowledgements:
 * Luc van OostenRyck for numerous patches.
 * Nick Bane for numerous patches.
 * Nick Bane for 2.5/2.6 integration.
 * Andras Toth for mknod rdev issue.
 * Michael Fischer for finding the problem with inode inconsistency.
 * Some code bodily lifted from JFFS
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

/*
 *
 * This is the file system front-end to YAFFS that hooks it up to
 * the VFS.
 *
 * Special notes:
 * >> 2.4: sb->u.generic_sbp points to the struct yaffs_dev associated with
 *         this superblock
 * >> 2.6: sb->s_fs_info  points to the struct yaffs_dev associated with this
 *         superblock
 * >> inode->u.generic_ip points to the associated struct yaffs_obj.
 */

/*
 * There are two variants of the VFS glue code. This variant should compile
 * for any version of Linux.
 */
#include 

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10))
#define YAFFS_COMPILE_BACKGROUND
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 23))
#define YAFFS_COMPILE_FREEZER
#endif
#endif

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28))
#define YAFFS_COMPILE_EXPORTFS
#endif

#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 35))
#define YAFFS_USE_SETATTR_COPY
#define YAFFS_USE_TRUNCATE_SETSIZE
#endif
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 35))
#define YAFFS_HAS_EVICT_INODE
#endif

#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 13))
#define YAFFS_NEW_FOLLOW_LINK 1
#else
#define YAFFS_NEW_FOLLOW_LINK 0
#endif

#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0))
#define YAFFS_HAS_WRITE_SUPER
#endif


#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19))
#include 
#endif

#include 
#include 
#include 
#include 
#include 
#include 
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39))
#include 
#endif
#include 
#include 
#include 
#include 
#include 

#if (YAFFS_NEW_FOLLOW_LINK == 1)
#include 
#endif

#ifdef YAFFS_COMPILE_EXPORTFS
#include 
#endif

#ifdef YAFFS_COMPILE_BACKGROUND
#include 
#include 
#endif
#ifdef YAFFS_COMPILE_FREEZER
#include 
#endif

#include 

#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))

#include 

#define UnlockPage(p) unlock_page(p)
#define Page_Uptodate(page)	test_bit(PG_uptodate, &(page)->flags)

/* FIXME: use sb->s_id instead ? */
#define yaffs_devname(sb, buf)	bdevname(sb->s_bdev, buf)

#else

#include 
#define	BDEVNAME_SIZE		0
#define	yaffs_devname(sb, buf)	kdevname(sb->s_dev)

#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0))
/* added NCB 26/5/2006 for 2.4.25-vrs2-tcl1 kernel */
#define __user
#endif

#endif

#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26))
#define YPROC_ROOT  (&proc_root)
#else
#define YPROC_ROOT  NULL
#endif

#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26))
#define Y_INIT_TIMER(a)	init_timer(a)
#else
#define Y_INIT_TIMER(a)	init_timer_on_stack(a)
#endif

#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 27))
#define YAFFS_USE_WRITE_BEGIN_END 1
#else
#define YAFFS_USE_WRITE_BEGIN_END 0
#endif

#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0))
#define YAFFS_SUPER_HAS_DIRTY
#endif


#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 2, 0))
#define set_nlink(inode, count)  do { (inode)->i_nlink = (count); } while(0)
#endif

#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 28))
static uint32_t YCALCBLOCKS(uint64_t partition_size, uint32_t block_size)
{
	uint64_t result = partition_size;
	do_div(result, block_size);
	return (uint32_t) result;
}
#else
#define YCALCBLOCKS(s, b) ((s)/(b))
#endif


具体查看 该文件。


经过分析,最新的yaffs2是应该支持 linux 3.6.7 的,意即可以直接给Linux 3.6.7以上版本打补丁而不需修改,但是目前没有发现时候是其他地方的问题,如有发现分析错误的地方可以与我联系,一起分享。

好了,新手第一篇博客,我会更加努力改进学习~

你可能感兴趣的:(嵌入式Linux)