Pkg.YAFFS — API for parsing YAFFS/YAFFS2 file system images¶
Overview¶
The Pkg.YAFFS module contains the API for parsing YAFFS and YAFFS2 (Yet Another Flash File System) images.
YAFFS2 is a log-structured file system designed for NAND flash memory, widely used in embedded Linux devices, Android phones, routers, and IoT firmware. The parser automatically detects the NAND page geometry (page size, spare size) and byte order from the image data.
Enumerating YAFFS Files¶
The following code example demonstrates how to enumerate files in a YAFFS file system:
from Pro.Core import *
from Pkg.YAFFS import *
def enumerateFiles(fname):
c = createContainerFromFile(fname)
if c.isNull():
return
obj = YAFFSObject()
if not obj.Load(c) or not obj.Initialize():
return
print("Page: %d Spare: %d" % (obj.GetPageSize(), obj.GetSpareSize()))
nre = CFSNonRecursiveEnum(obj)
nre.AddPath(obj.FSRootDirectory())
while True:
f = nre.Next(None)
if not f:
break
entry = obj.FSGetEntry(f, None)
if not entry.IsNull():
print(entry.Name(), entry.DataSize())
Module API¶
Pkg.YAFFS module API.
Classes:
This class represents a YAFFS/YAFFS2 (Yet Another Flash File System) image.
- class YAFFSObject¶
Bases:
Pro.Core.CFFObjectThis class represents a YAFFS/YAFFS2 (Yet Another Flash File System) image.
YAFFS2 is a log-structured file system designed for NAND flash memory, commonly found in embedded Linux devices, Android phones, routers, and IoT firmware. The class provides file system support through the CFS interface inherited from
CFFObject, with automatic detection of NAND page geometry and byte order.Methods:
Returns the total number of valid chunks parsed from the image.
Returns the detected NAND page size in bytes.
Returns the detected NAND spare (OOB) area size in bytes.
- GetChunkCount() → int¶
Returns the total number of valid chunks parsed from the image.
This includes both object header chunks and data chunks.
- Returns
Returns the chunk count.
- Return type
int
- GetPageSize() → int¶
Returns the detected NAND page size in bytes.
Common values are 512 (YAFFS1), 2048, 4096, or 8192 (YAFFS2).
- Returns
Returns the page size.
- Return type
int
- GetSpareSize() → int¶
Returns the detected NAND spare (OOB) area size in bytes.
Common values are 16 (YAFFS1), 64, 128, or 256 (YAFFS2).
- Returns
Returns the spare size.
- Return type
int