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
| Offset | Size | Type | Field | Notes |
|---|---|---|---|---|
| p + 1 | 1 | u8 | – | |
| p + 2 | 2 | u16 LE | Node Type | |
| p + 4 | 4 | u32 LE | Totlen |
Constants
Jffs2 Reader
| Name | Value | Type | Notes |
|---|---|---|---|
| NodeMagic | 0x1985 | ushort | |
| DirentType | 0xE001 | ushort | |
| InodeType | 0xE002 | ushort |
compr types
| Name | Value | Type | Notes |
|---|---|---|---|
| ComprNone | 0 | byte | |
| ComprZero | 1 | byte | |
| ComprRtime | 2 | byte | |
| ComprZlib | 6 | byte | |
| ScanCap | 256L * 1024 * 1024 | long | scan at most this much into memory |
| MaxFileBytes | 512 * 1024 * 1024 | int |