YAFFS2 is a log-structured file system for NAND flash that stores its metadata in each page’s spare area. It was widely used on early Android phones and embedded Linux devices (mid-2000s to about 2010) and is mostly legacy now, but appears in chip-off dumps from that era.
Overview
YAFFS2 stores per-page tags in the out-of-band (spare) area: object ID, chunk ID, sequence number and byte count. File and directory metadata are object-header chunks; data are chunks tagged with an object and chunk ID. There is no magic number, so the implementation detects page and spare sizes by validating object headers. A dump must include the spare area to be readable.
History
- Written by Charles Manning (Aleph One) from 2002.
- Used on Android devices before ext4 became the norm; never merged into mainline Linux.
Structures
Offsets are in bytes from the start of the structure named in each heading. Field names are descriptive and are not an official specification. Fixed-width integers are shown as u/i (unsigned/signed) followed by bit width and byte order.
Score Geometry
| Offset | Size | Type | Field | Notes |
|---|---|---|---|---|
| dataPos | 4 | u32 LE | Type | |
| dataPos + 4 | 4 | u32 LE | Parent | |
| tagPos + 4 | 4 | u32 LE | Obj Id | |
| dataPos + 8 | 2 | u16 LE | Sum | |
| tagPos + 8 | 4 | u32 LE | Chunk Id | |
| dataPos + 10 | 1 | u8 | N0 |
Constants
special object ids
| Name | Value | Type | Notes |
|---|---|---|---|
| ObjRoot | 1 | uint | |
| ObjDeleted | 4 | uint | |
| ObjUnlinked | 3 | uint |
object header types
| Name | Value | Type | Notes |
|---|---|---|---|
| TypeFile | 1 | uint | |
| TypeSymlink | 2 | uint | |
| TypeDirectory | 3 | uint | |
| TypeHardlink | 4 | uint | |
| TypeSpecial | 5 | uint | |
| ScanCap | 256L * 1024 * 1024 | long | |
| MaxFileBytes | 512 * 1024 * 1024 | int | |
| PageSizes | [512, 2048, 4096, 8192, 16384] | int[] | |
| OobSizes | [16, 32, 64, 128, 224, 256, 448, 640] | int[] | |
| TagOffsets | [0, 2] | int[] |