generated from erix/meta
[FEATURE] Encode GPT image metadata without device authority #3
Labels
No labels
alpha-1
bug
ci
docs
duplicate
enhancement
help wanted
invalid
performance
phase-6
question
refactor
security
wontfix
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
erix/lib-partition#3
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem and motivation
Building disk images inside EriX needs GPT metadata generation without a host partitioning program or device administration. The maintained partition crate parses GPT, while the product image recipe still invokes sgdisk. Its Python GPT helper is a fixed fixture generator.
Proposed behavior and scope
Add an allocation-free, no_std GPT metadata writer to lib-partition. Borrow explicit LBA geometry, GUIDs and optional partition slots, plus caller-owned output and index buffers. Return the protective MBR, primary and backup headers, one shared partition array and their destination spans; do not allocate an entire disk image or perform I/O.
Add an explicit backup-header parser through the shared validator, keeping the existing primary parser primary-only.
Use the current UEFI GPT format, preserving the existing parser's legacy compatibility. Support caller-selected block sizes and entry capacity, checked layout arithmetic, UTF-16 names, reserved-byte clearing and exact CRC extents. The raw-image geometry has no CHS mapping; document the protective MBR's saturated ending field rather than inventing device geometry.
Authority, security and reliability
The writer receives only borrowed values and buffers. It has no device, file, environment, entropy, callback or allocator authority. The caller supplies GUID identity policy and performs writes through its existing output owner. Validate geometry, partition ranges, overlaps, duplicate GUIDs, names, buffer extents and workspace before changing any output buffer. Invalid inputs preserve all four metadata outputs; index scratch may change during preflight.
Keep unused slots and caller entry order. Use caller-owned indices for allocation-free O(n log n) overlap and GUID checks, with no fixed disk or partition maximum. A valid encoding detects format errors and corruption; it does not authenticate contents or prove an image booted.
Acceptance criteria
Alternatives and tradeoffs
Keeping sgdisk as the only producer preserves an external runtime dependency. Extending the fixture helper would leave native callers without a reusable Rust implementation. A pure metadata encoder can serve image-file builders without acquiring their output authority; filesystem assembly and recipe migration remain separate work.
Tracking and rollout
Continue the image/build work and Integration review. Add the reusable writer first, then adopt it through explicit image-file output ownership before claiming the external partitioning dependency has been removed.
The GPT encoder and explicit backup-header validator are now available on
feature/posix-compatin 357cafd1. Callers provide the geometry, GUIDs, scratch and output buffers; refused inputs preserve all metadata outputs. The technical manual update is prepared and awaits publication. Boot-tool #7 tracks the native image-file command and recipe adoption.