Prepare clean Sargo images and validated storage inventories

Keep internal documents out of system images while retaining license notices and package versions. Generate boot mappings from a bounded storage inventory, and allow long SSH diagnostics. Hardware boot qualification remains pending.
This commit is contained in:
OverSu 2026-10-01 12:25:53 +02:00
commit 9b606ed5f3
7 changed files with 193 additions and 4 deletions

View file

@ -0,0 +1,32 @@
# SPDX-License-Identifier: MPL-2.0
"""Validate an inventoried, single-extent Sargo userdata mapping."""
import re
def mount_table(layout):
device = layout.get('device')
if device != '/dev/mmcblk0p72':
raise ValueError('Expected Sargo userdata, not another partition')
if not re.fullmatch(r'[0-9a-f]{64}', layout.get('firstMiBSha256', '')):
raise ValueError('Missing userdata identity checksum')
match = re.fullmatch(r'0 ([0-9]+) linear ([0-9]+:[0-9]+) ([0-9]+)',
layout.get('table', ''))
if not match:
raise ValueError('Only a single linear extent is supported')
sectors, backing, offset = int(match[1]), match[2], int(match[3])
size = int(layout['size'])
if size <= 0 or size % 512 or sectors <= 0 or offset < 2048:
raise ValueError('Invalid userdata extent geometry')
if (sectors + offset) * 512 > size:
raise ValueError('Extent exceeds userdata')
if layout.get('schema') == 2:
if (layout.get('partitionLabel') != 'userdata' or
layout.get('filesystem') != 'ext4' or
layout.get('backingDevice') != backing):
raise ValueError('Mapping must be ext4 on the inventoried userdata device')
elif not (layout['table'] == '0 104448000 linear 259:40 329728'
and size == 53648801280):
raise ValueError('A new layout requires a schema 2 inventory')
# Kernel major/minor numbers can change between boots. The partition path
# is stable with this Sargo kernel, and its first MiB is checked before use.
return f'0 {sectors} linear {device} {offset}'