Pkg.EROFS — API for parsing EROFS file system images¶
Overview¶
The Pkg.EROFS module contains the API for parsing EROFS (Enhanced Read-Only File System) images.
EROFS is a high-performance, read-only compressed file system designed for Linux. It was merged into the Linux kernel in version 4.19 and is widely adopted in Android system partitions (from Android 10 onward), container images, and embedded systems. EROFS supports LZ4 and DEFLATE compression with a pcluster-based data layout that enables efficient random read access. It also supports inline data, extended attributes, and chunk-based file storage.
Enumerating EROFS Files¶
The following code example demonstrates how to enumerate files in an EROFS file system:
from Pro.Core import *
from Pkg.EROFS import *
def enumerateFiles(fname):
c = createContainerFromFile(fname)
if c.isNull():
return
obj = EROFSObject()
if not obj.Load(c) or not obj.Initialize():
return
print("UUID:", obj.GetUUID())
print("Compression:", obj.GetCompressionAlgorithms())
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.EROFS module API.
Classes:
This class represents an EROFS (Enhanced Read-Only File System) image.
- class EROFSObject¶
Bases:
Pro.Core.CFFObjectThis class represents an EROFS (Enhanced Read-Only File System) image.
EROFS is a high-performance, read-only file system designed for Linux. It is widely used in Android system partitions, container images, and embedded systems. The class provides file system support through the CFS interface inherited from
CFFObject, with transparent decompression of LZ4 and DEFLATE compressed data.Methods:
Returns the total number of blocks in the EROFS image.
Returns the block size of the EROFS file system in bytes.
Returns a comma-separated string of compression algorithms used in the image.
Returns a comma-separated string of enabled incompatible feature flags.
Returns the total number of inodes in the EROFS image.
GetUUID()Returns the UUID of the EROFS file system as a string.
Returns the volume name stored in the EROFS superblock.
- GetBlockCount() → int¶
Returns the total number of blocks in the EROFS image.
- Returns
Returns the block count.
- Return type
int
- GetBlockSize() → int¶
Returns the block size of the EROFS file system in bytes.
Common values are 4096 (4 KB) and 512.
- Returns
Returns the block size in bytes.
- Return type
int
- GetCompressionAlgorithms() → str¶
Returns a comma-separated string of compression algorithms used in the image.
Possible values include
"LZ4","LZMA","DEFLATE", and"ZSTD". Returns"None"if the image is uncompressed.
- Returns
Returns the compression algorithm names.
- Return type
str
- GetFeatures() → str¶
Returns a comma-separated string of enabled incompatible feature flags.
These flags indicate on-disk format features such as
"LZ4_0PADDING","BIG_PCLUSTER","CHUNKED_FILE","FRAGMENTS", and others.
- Returns
Returns the feature flag names, or
"None"if no incompatible features are set.- Return type
str
- GetInodeCount() → int¶
Returns the total number of inodes in the EROFS image.
- Returns
Returns the inode count.
- Return type
int
- GetUUID() → str¶
Returns the UUID of the EROFS file system as a string.
- Returns
Returns the UUID in standard hyphenated format (e.g.,
"550e8400-e29b-41d4-a716-446655440000"), or an empty string if unavailable.- Return type
str
- GetVolumeName() → str¶
Returns the volume name stored in the EROFS superblock.
The name is a user-defined identifier up to 16 characters long, set at image creation time.
- Returns
Returns the volume name, or an empty string if not set.
- Return type
str