Skip to content

Commit

Permalink
Add Android super.img (Dynamic Partitions) format
Browse files Browse the repository at this point in the history
The metadata stored by Android at the beginning of a "super" partition,
which is what it calls a disk partition that holds one or more Dynamic
Partitions. Dynamic Partitions do more or less the same thing that LVM
does on Linux, allowing Android to map ranges of non-contiguous extents
to a single logical device. This metadata holds that mapping.

Signed-off-by: Thomas Hebb <[email protected]>
  • Loading branch information
tchebb committed Oct 16, 2020
1 parent d1e58e3 commit 2a00526
Showing 1 changed file with 174 additions and 0 deletions.
174 changes: 174 additions & 0 deletions filesystem/android_super.ksy
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
meta:
id: android_super
title: Android Dynamic Partitions metadata
application: Android
file-extension: img
license: CC0-1.0
ks-version: 0.8
endian: le

doc: |
The metadata stored by Android at the beginning of a "super" partition, which
is what it calls a disk partition that holds one or more Dynamic Partitions.
Dynamic Partitions do more or less the same thing that LVM does on Linux,
allowing Android to map ranges of non-contiguous extents to a single logical
device. This metadata holds that mapping.
doc-ref: https://source.android.com/devices/tech/ota/dynamic_partitions/implement
doc-ref: https://android.googlesource.com/platform/system/core/+/master/fs_mgr/liblp/include/liblp/metadata_format.h

seq:
- id: padding
size: 0x1000
type: dummy

- id: primary_geometry
size: 0x1000
type: geometry

- id: backup_geometry
type: geometry
size: 0x1000

- id: primary_metadata
size: primary_geometry.metadata_max_size
type: metadata
repeat: expr
repeat-expr: primary_geometry.metadata_slot_count

- id: backup_metadata
size: primary_geometry.metadata_max_size
type: metadata
repeat: expr
repeat-expr: primary_geometry.metadata_slot_count

types:
dummy: {}

geometry:
seq:
- id: magic
contents: [0x67, 0x44, 0x6c, 0x61]
- id: struct_size
type: u4
- id: checksum
size: 32
- id: metadata_max_size
type: u4
- id: metadata_slot_count
type: u4
- id: logical_block_size
type: u4

metadata:
seq:
- id: magic
contents: [0x30, 0x50, 0x4c, 0x41]
- id: major_version
type: u2
- id: minor_version
type: u2
- id: header_size
type: u4
- id: header_checksum
size: 32
- id: tables_size
type: u4
- id: tables_checksum
size: 32
- id: partitions
type: table_descriptor(0)
- id: extents
type: table_descriptor(1)
- id: groups
type: table_descriptor(2)
- id: block_devices
type: table_descriptor(3)

types:
table_descriptor:
params:
- id: entry_type
type: u8

seq:
- id: offset
type: u4
- id: num_entries
type: u4
- id: entry_size
type: u4

instances:
table:
pos: _parent.header_size + offset
size: entry_size
type:
switch-on: entry_type
cases:
0: partition
1: extent
2: group
3: block_device
repeat: expr
repeat-expr: num_entries

partition:
seq:
- id: name
size: 36
type: strz
encoding: UTF-8
- id: attributes
type: u4
- id: first_extent_index
type: u4
- id: num_extents
type: u4
- id: group_index
type: u4

extent:
seq:
- id: num_sectors
type: u8
- id: target_type
type: u4
enum: target_type
- id: target_data
type: u8
- id: target_source
type: u4

enums:
target_type:
0: linear
1: zero

group:
seq:
- id: name
size: 36
type: strz
encoding: UTF-8
- id: flags
type: u4
- id: maximum_size
type: u8

block_device:
seq:
- id: first_logical_sector
type: u8
- id: alignment
type: u4
- id: alignment_offset
type: u4
- id: size
type: u8
- id: partition_name
size: 36
type: strz
encoding: UTF-8
- id: flags
type: u4

0 comments on commit 2a00526

Please sign in to comment.