yaffs文件类型_yaffs文件系统

1. 概述

yaffs文件系统专为Nandflash设计的日志文件系统,占用page中oob区域。目前有两个版本的yaffs文件系统。nandflash不可靠,存在坏块,存在数据错误,需要软件弥补纠正此错误。

在yaffs中分配单元为CHUNK(chunk),一般情况,典型情况下其值与一页(page)大小相同(同时可灵活配置)。yaffs中文件数据的存储以chunk为单位。

YAFFS是专为为NandFlash设计的文件系统,基于MTD,为单线程程序。官网:

http://www.yaffs.net/

yaffs架构:

2578c5616013529dde683a43af98715b.png

读文档 HowYaffsWorks 了解YAFFS演进过程及实现原理、特性。

2.YDI为移植和应用提供方便

The Yaffs Direct Interface (YDI) which allows Yaffs to be simply integrated with embedded systems, with or without an RTOS.

YDI包装Yaffs以易于集成的方式。

Yaffs Direct Interface (YDI) wraps Yaffs in a way that is simple to integrate. You need to provide a few functions for Yaffs to use to talk to your hardware and OS. Yaffs provides a set of POSIX-compliant functions for applications to use to talk to it.

In addition to the Yaffs core file system, the YDI has three parts which are each explained in more detail in further sections:

>>POSIX Application Interface: This is the interface that the application code uses to access the Yaffs file system. (open, close, read, write, etc)

>>RTOS Integration Interface: These are the functions that must be provided for Yaffs to access the RTOSsystem resources. (initialise, lock, unlock, get time, set error)

>>Flash Configuration and Access Interface: These are the functions that must be provided for Yaffs to access the NAND flash. (initialise, read chunk, write chunk, erase block, etc). These functions might be supplied by a chipset vendor or might need to be written by the integrator.

3.Yaffs1 VS Yaffs2

Yaffs1为小块设计(512bytes),布局为工厂模式(Smart-Media-like)。应用deletion makers标记坏块(打乱顺序写规则)。

Yaffs2兼容大小块(2Kbytes),可灵活配置布局。舍弃deletion marker,0回写(不允许重复写),一块内顺序写。

4.YAFFS tags

YAFFS tags in YAFFS1 mode:

18-bit Object ID (2^18 files, i.e. > 260,000 files). File id 0- is not valid and indicates a deleted page. File od 0x3ffff is also not valid. Synonymous with inode.

2-bit serial number

20-bit Chunk ID within file. Limit of 2^20 chunks/pages per file (i.e. > 500MB max file size). Chunk ID 0 is the file header for the file.

10-bit counter of the number of bytes used in the page.

12 bit ECC on tags

YAFFS tags in YAFFS2 mode:

4 bytes 32-bit chunk ID

4 bytes 32-bit object ID

2 bytes Number of data bytes in this chunk

4 bytes Sequence number for this block

3 bytes ECC on tags

12 bytes ECC on data (3 bytes per 256 bytes of data)

注:现在yaffs2对tags支持有较大变化,不再提供ECC on data支持,其余字段全为4字节。

5.源码

yaffs_allocator.cAllocates Yaffs object and tnode structures.

yaffs_checkpointrw.cStreamer for writing checkpoint data

yaffs_ecc.cECC code,软件ECC算法

yaffs_guts.cThe major Yaffs algorithms.

yaffs_nand.cFlash interfacing abstraction.

yaffs_packedtags1.c

yaffs_packedtags2.cTags packing code

yaffs_qsort.cQsort used during Yaffs2 scanning,现无

yaffs_tagscompat.cTags compatibility code to support Yaffs1 mode.

yaffs_tagsvalidity.cTags validity checking. 现无

最新版yaffs2还增加如下文件:

yaffs_atribs.c设置YAFFS对象(object)属性

yaffs_bitmap.cYaffs位图操作(页bitmap)

yaffs_endian.cYaffs对大小端支持

yaffs_mtdif.c与mtd对接端口

yaffs_nameval.c对name-value存储的支持

yaffs_summary.c对一块中每页tags摘要支持

yaffs_tagsmarshall.c对internal(内存)tags和stored tags之间转换的支持

yaffs_verify.c.cYaffs各种校验支持

yaffs_vfs.c与vfs接口(对linux vfs支持)

Yaffs_yaffs1.cYaffs1扫描实现

Yaffs_yaffs2.cYaffs2中checkpoint及两次扫描支持

从中可以看出yaffs对上层及下层接口文件:

>>对下层(硬件)采用mtd设备,对接文件yaffs_mtdif.c,

void yaffs_mtd_drv_install(struct yaffs_dev *dev)

{

struct yaffs_driver *drv = &dev->drv;

drv->drv_write_chunk_fn = yaffs_mtd_write;

drv->drv_read_chunk_fn = yaffs_mtd_read;

drv->drv_erase_fn = yaffs_mtd_erase;

drv->drv_mark_bad_fn = yaffs_mtd_mark_bad;

drv->drv_check_bad_fn = yaffs_mtd_chec

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值