Pkg.CRAMFS — API for parsing CRAMFS file system images

Overview

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

CRAMFS is a simple, read-only compressed file system designed for Linux ROM devices. It uses zlib to compress file data one page at a time, allowing random read access while keeping the image compact. CRAMFS is commonly found in embedded systems, firmware images, and devices with limited storage. It supports both little-endian and big-endian byte orders.

Enumerating CRAMFS Files

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

from Pro.Core import *
from Pkg.CRAMFS import *

def enumerateFiles(fname):
    c = createContainerFromFile(fname)
    if c.isNull():
        return
    obj = CRAMFSObject()
    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.CRAMFS module API.

Classes:

CRAMFSObject()

This class represents a CRAMFS (Compressed ROM File System) image.

class CRAMFSObject

Bases: Pro.Core.CFFObject

This class represents a CRAMFS (Compressed ROM File System) image.

CRAMFS is a simple, read-only compressed file system designed for Linux ROM devices. It compresses data one page at a time using zlib, allowing random read access. The class provides file system support through the CFS interface inherited from CFFObject, with transparent decompression and support for both little-endian and big-endian images.

Methods:

GetBlockCount()

Returns the total number of compressed data blocks in the image.

GetFSName()

Returns the file system name stored in the CRAMFS superblock.

GetFSSize()

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

GetFileCount()

Returns the total number of files recorded in the CRAMFS superblock.

GetBlockCount()int

Returns the total number of compressed data blocks in the image.

Returns

Returns the block count.

Return type

int

GetFSName()str

Returns the file system name stored in the CRAMFS superblock.

The name is a user-defined identifier up to 16 characters long, set at image creation time.

Returns

Returns the file system name.

Return type

str

GetFSSize()int

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

Returns

Returns the file system size in bytes.

Return type

int

GetFileCount()int

Returns the total number of files recorded in the CRAMFS superblock.

This count includes regular files, directories, symlinks, and special files as stored in the superblock metadata.

Returns

Returns the file count.

Return type

int