YAFFS2 (Yet Another Flash File System 2)

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

OffsetSizeTypeFieldNotes
dataPos4u32 LEType
dataPos + 44u32 LEParent
tagPos + 44u32 LEObj Id
dataPos + 82u16 LESum
tagPos + 84u32 LEChunk Id
dataPos + 101u8N0

Constants

special object ids

NameValueTypeNotes
ObjRoot1uint
ObjDeleted4uint
ObjUnlinked3uint

object header types

NameValueTypeNotes
TypeFile1uint
TypeSymlink2uint
TypeDirectory3uint
TypeHardlink4uint
TypeSpecial5uint
ScanCap256L * 1024 * 1024long
MaxFileBytes512 * 1024 * 1024int
PageSizes[512, 2048, 4096, 8192, 16384]int[]
OobSizes[16, 32, 64, 128, 224, 256, 448, 640]int[]
TagOffsets[0, 2]int[]
Structures and constants were extracted from the implementation. Prose sections are a summary from public sources; verify details before relying on them.