lib-partition is the no-std GPT parser used by blockd
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Erik Inkinen 229ddeb818
All checks were successful
CI / markdown (push) Successful in 2s
CI / test (push) Successful in 23s
feat: Merge caller-buffer GPT image encoding
2026-11-21 07:02:24 +02:00
.github feat: Encode GPT image metadata in caller buffers 2026-11-14 22:30:53 +02:00
src feat: Encode GPT image metadata in caller buffers 2026-11-14 22:30:53 +02:00
.editorconfig Initial commit 2026-04-22 04:02:34 +02:00
.gitignore Initial commit 2026-04-22 04:02:34 +02:00
.markdownlint-cli2.yaml Tighten CI markdown policy 2026-05-22 15:10:28 +03:00
ARCHITECTURE.md feat: Encode GPT image metadata in caller buffers 2026-11-14 22:30:53 +02:00
Cargo.toml ci: Use checked sources and main dependencies for baseline checks 2026-10-30 11:12:21 +02:00
CODE_OF_CONDUCT.md docs: Synchronize shared contribution and review policies 2026-09-12 06:38:18 +03:00
CONTRIBUTING.md docs: Align dependency selection and review policy 2026-10-30 18:26:45 +02:00
LICENSE Initial commit 2026-04-22 04:02:34 +02:00
README.md feat: Encode GPT image metadata in caller buffers 2026-11-14 22:30:53 +02:00
ROADMAP.md feat: Encode GPT image metadata in caller buffers 2026-11-14 22:30:53 +02:00
rustfmt.toml Initial commit 2026-04-22 04:02:34 +02:00
SECURITY.md docs: Synchronize shared contribution and review policies 2026-09-12 06:38:18 +03:00

lib-partition

lib-partition provides the no_std GPT parser used by blockd and a caller-buffer metadata writer for new raw disk images.

EriX is a clean-room, capability-based microkernel operating system written entirely in Rust.

Technical requirements are tracked in the EriX requirements, conventions, and project documentation.

See:

  • docs for design documents, specifications, and development plans.
  • Related architecture repositories for kernel, services, libraries, drivers, and integration tooling.

Purpose of This Repository

This repository implements the EriX partition library. Its purpose in EriX is to provide reusable partition primitives and contracts to EriX components.

Functionally, it exposes the partition APIs, validation tests, and documentation used by dependent repositories. The repository keeps the implementation, interface contracts, tests, and documentation for that behavior in one reviewable ownership boundary.

The maintained responsibilities are:

  • expose the lib-partition crate API for partition behavior used by dependent components
  • validate the full declared GPT header length without a legacy-sector scratch limit
  • validate and parse complete GPT entry arrays incrementally without requiring array-sized storage
  • construct protective MBR, primary/backup headers and matching partition tables in explicitly supplied memory, without file or device access
  • keep data formats, constants, and validation helpers documented and tested
  • preserve clean-room, no-external-crate implementation boundaries
  • maintain compatibility expectations for downstream repositories

Clean-Room Policy

EriX follows a strict clean-room philosophy:

  • No external source code may be copied.
  • No external Rust crates are allowed.
  • No code generation tools that embed third-party code.
  • All code must be authored within the project.

Violations will result in rejection of the contribution.

License

All EriX repositories are licensed under the ISC License.

Development Model

EriX development is modular, deterministic, reproducible, authority-explicit, security-first, and self-hosting oriented.

This repository follows the project roadmap and the validation rules documented in its own roadmap.

Parsed headers, entries, and names are validated value types. Their representation is private, and callers inspect them through read-only accessors, so invalid parser output cannot be manufactured through public fields. GptEntryArrayStreamV1 covers every format-declared entry and extension byte with the GPT CRC while retaining only the standardized 128-byte prefix crossing a chunk boundary. Stream visitors must hold provisional results until finish verifies the complete array's CRC.

GptHeaderV1::parse_backup checks a caller-selected final-LBA backup header, including its link to LBA 1 and the backup array's placement. The existing parse_primary remains primary-only; neither method falls back or repairs media.

Constructing GPT metadata

GptWritePlanV1::prepare borrows an explicit disk specification and a slice of optional partition entries. Each position remains its original table slot; unused trailing slots and None entries are zero. Callers provide one usize of scratch per active entry. Only those indices are sorted for O(n log n) overlap and GUID checks; scratch may change on refusal, while original entries and their names remain immutable.

The plan reports four output capacities: one logical block each for PMBR and the two headers, plus one shared table region. encode checks every capacity before writing any byte. Extra buffer tails remain untouched. The table covers at least 16 KiB of reserved space, rounded to logical blocks; its CRC covers only the declared entry bytes. The caller writes that same table to both LBA spans returned by the plan. No disk-sized allocation or I/O is hidden here.

New images use current UEFI entry sizes, zero reserved extensions and explicit GUIDs; no clock or randomness is consulted. Names must fit 36 UTF-16 units including their terminator, with embedded NUL refused. Logical blocks need not be 512 bytes. The raw image has no CHS mapping, so its protective MBR uses the specified saturated ending-CHS field. Legacy parser acceptance is unchanged. Image-file publication, storage permissions and durability belong to callers.

Format provenance: UEFI 2.11, chapter 5. The implementation is original EriX code derived from the format specification.

Validation

  • cargo test
  • cargo fmt
  • strict clippy with warnings denied

Governance Principles

lib-partition governance is scoped to reusable partition contracts shared by dependent repositories.

The scoped governance rules are:

  • It must expose narrow, documented APIs rather than component-specific policy.
  • It keeps wire formats, constants, parsers, and validation helpers deterministic and testable.
  • It preserves clean-room implementation boundaries and does not introduce external crate dependencies.
  • Breaking API or format changes require coordinated updates in every dependent repository.

Library Boundaries

  • lib-partition carries no runtime authority by itself; authority is held by callers that use the library.
  • The crate must not hide ambient I/O, allocation policy, or service discovery behind helper APIs.

Contact

Development occurs in EriX organization and discussions happen in issues and design documents.

No decisions are considered valid without documented rationale.

Maintainers can be reached via email: admin@erikinkinen.fi.