Pkg.ROMFS — API for parsing ROMFS file system images

Overview

The Pkg.ROMFS module contains the API for parsing ROMFS (ROM File System) images.

ROMFS is a simple, space-efficient, read-only file system designed for Linux. Unlike CRAMFS, ROMFS stores data uncompressed, making it suitable for systems where fast read access is more important than storage savings. All on-disk structures use big-endian byte order. ROMFS is commonly found in embedded systems, firmware images, initramfs, and bootloaders.

Enumerating ROMFS Files

The following code example demonstrates how to enumerate files in a ROMFS file system:

from Pro.Core import *
from Pkg.ROMFS import *

def enumerateFiles(fname):
    c = createContainerFromFile(fname)
    if c.isNull():
        return
    obj = ROMFSObject()
    if not obj.Load(c) or not obj.Initialize():
        return
    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.ROMFS module API.

Classes:

ROMFSObject()

This class represents a ROMFS (ROM File System) image.

class ROMFSObject

Bases: Pro.Core.CFFObject

This class represents a ROMFS (ROM File System) image.

ROMFS is a simple, space-efficient, read-only file system designed for Linux. It stores data uncompressed with all on-disk structures in big-endian byte order. The class provides file system support through the CFS interface inherited from CFFObject.

Methods:

GetFSSize()

Returns the total size of the ROMFS file system in bytes as recorded in the superblock.

GetVolumeName()

Returns the volume name stored in the ROMFS superblock.

GetFSSize()int

Returns the total size of the ROMFS file system in bytes as recorded in the superblock.

This is the number of bytes accessible in the image, starting from byte zero.

Returns

Returns the file system size in bytes.

Return type

int

GetVolumeName()str

Returns the volume name stored in the ROMFS superblock.

The volume name is a user-defined identifier set at image creation time, stored as a null-terminated string in the superblock header.

Returns

Returns the volume name.

Return type

str