liblp.include.liblp

Module Attributes

LpMetadata([geometry, header, partitions, ...])

FlashPartitionTable(super_partition, metadata)

UpdatePartitionTable(super_partition, ...[, ...])

ReadMetadata(super_partition, slot_number[, ...])

IsEmptySuperImage(file)

WriteToImageFile(file, metadata, block_size, ...)

ReadFromImageBlob(data)

Note: signature should have been ReadFromImageBlob(data: bytes, bytes: int) -> LpMetadata but we don't need size in Python

WriteSplitImageFiles(output_dir, metadata, ...)

GetMetadataSuperBlockDevice(metadata)

GetTotalSuperPartitionSize(metadata)

GetBlockDevicePartitionNames(metadata)

liblp.include.liblp.FlashPartitionTable(super_partition: str, metadata: LpMetadata, opener: IPartitionOpener = None) bool

Place an initial partition table on the device. This will overwrite the existing geometry, and should not be used for normal partition table updates. False can be returned if the geometry is incompatible with the block device or an I/O error occurs.

liblp.include.liblp.GetBlockDevicePartitionNames(metadata: LpMetadata) List[str]

Get the list of block device names required by the given metadata.

liblp.include.liblp.GetMetadataSuperBlockDevice(metadata: LpMetadata) LpMetadataBlockDevice

Return the block device that houses the super partition metadata; returns null on failure.

liblp.include.liblp.GetTotalSuperPartitionSize(metadata: LpMetadata) int

Return the total size of all partitions comprising the super partition.

liblp.include.liblp.IsEmptySuperImage(file: str) bool

Returns whether an image is an “empty” image or not. An empty image contains only metadata. Unlike a flashed block device, there are no reserved bytes or backup sections, and only one slot is stored (even if multiple slots are supported). It is a format specifically for storing only metadata.

class liblp.include.liblp.LpMetadata(geometry: LpMetadataGeometry = None, header: LpMetadataHeader = None, partitions: List[LpMetadataPartition] = None, extents: List[LpMetadataExtent] = None, groups: List[LpMetadataPartitionGroup] = None, block_devices: List[LpMetadataBlockDevice] = None)
liblp.include.liblp.ReadFromImageBlob(data: bytes) LpMetadata

Read/Write logical partition metadata to an image file, for producing a super_empty.img (for fastboot wipe-super/update-super) or for diagnostics.

liblp.include.liblp.ReadMetadata(super_partition: str, slot_number: int, opener: IPartitionOpener = None) LpMetadata

Read logical partition metadata from its predetermined location on a block device. If readback fails, we also attempt to load from a backup copy.

liblp.include.liblp.UpdatePartitionTable(super_partition: str, metadata: LpMetadata, slot_number: int, opener: IPartitionOpener = None) bool

Update the partition table for a given metadata slot number. False is returned if an error occurs, which can include:

  • Invalid slot number.

  • I/O error.

  • Corrupt or missing metadata geometry on disk.

  • Incompatible geometry.

liblp.include.liblp.WriteSplitImageFiles(output_dir: str, metadata: LpMetadata, block_size: int, images: Dict[str, str], sparsify: bool) bool

Similar to WriteToSparseFile, this will generate an image that can be flashed to a device directly. However unlike WriteToSparseFile, it is intended for retrofit devices, and will generate one sparse file per block device (each named super_<name>.img) and placed in the specified output folder.

liblp.include.liblp.WriteToImageFile(file: str, metadata: LpMetadata, block_size: int, images: Dict[str, str], sparsify: bool) bool

Read/Write logical partition metadata and contents to an image file, for flashing.