JFFS2 (Journalling Flash File System 2)

JFFS2 is a log-structured Linux file system for raw NAND and NOR flash with built-in compression and wear leveling. It is found in older router, set-top box and embedded firmware and is largely replaced by UBIFS and others, but still common in dumped flash images.

Overview

JFFS2 has no central index: the medium is a log of nodes (inode data nodes, directory entry nodes, cleanmarkers, padding), each with a header CRC and a version number. Mounting scans all nodes and keeps the newest per inode or name. Nodes may be compressed (zlib, RTIME, Rubin, LZO). It runs directly on MTD devices and handles wear leveling itself.

History

  • Written by David Woodhouse at Red Hat (2001) as the successor to Axis Communications’ JFFS.
  • Merged into the Linux kernel in the 2.4 series.

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.

Probe

OffsetSizeTypeFieldNotes
p + 11u8–
p + 22u16 LENode Type
p + 44u32 LETotlen

Constants

Jffs2 Reader

NameValueTypeNotes
NodeMagic0x1985ushort
DirentType0xE001ushort
InodeType0xE002ushort

compr types

NameValueTypeNotes
ComprNone0byte
ComprZero1byte
ComprRtime2byte
ComprZlib6byte
ScanCap256L * 1024 * 1024longscan at most this much into memory
MaxFileBytes512 * 1024 * 1024int
Structures and constants were extracted from the implementation. Prose sections are a summary from public sources; verify details before relying on them.