Skip to content

Add patina_partition crate#12

Open
kat-perez wants to merge 1 commit into
OpenDevicePartnership:mainfrom
kat-perez:kat-perez/patina-partition
Open

Add patina_partition crate#12
kat-perez wants to merge 1 commit into
OpenDevicePartnership:mainfrom
kat-perez:kat-perez/patina-partition

Conversation

@kat-perez
Copy link
Copy Markdown
Contributor

Description

Adds a new `patina_partition` crate exposing generic UEFI partition I/O helpers, split by protocol:

  • `patina_partition::block_io::write_partition_raw` — raw block-level write at LBA 0 via `EFI_BLOCK_IO_PROTOCOL`. Zero-pads to the media block size; fails fast on read-only/absent media.
  • `patina_partition::file_system::read_partition_file` — read a file at a partition-relative path (`\EFI\BOOT\...`) via `EFI_SIMPLE_FILE_SYSTEM_PROTOCOL`. Slurps the full file into a `Vec`, closes handles on every exit path.

Both helpers were previously inside `patina_boot` (via patina#1489 "partition raw-write" and patina#1495 "partition file-read"). Reviewer feedback on patina#1488 made the case that storage abstractions don't belong in the boot crate; this PR is the relocation, mirroring the existing patina-components#11 (`patina_nvme`) split.

  • Impacts functionality?
  • Impacts security?
  • Breaking change?
  • Includes tests?
  • Includes documentation?

How This Was Tested

`cargo test --lib -p patina_partition` — all 11 tests pass:

```
test block_io::tests::test_write_partition_raw_empty_data_is_noop ... ok
test block_io::tests::test_write_partition_raw_locate_failure ... ok
test block_io::tests::test_write_partition_raw_handle_protocol_failure ... ok
test block_io::tests::test_write_partition_raw_inner_writes_to_lba_zero_with_aligned_size ... ok
test block_io::tests::test_write_partition_raw_inner_read_only_rejected ... ok
test block_io::tests::test_write_partition_raw_inner_writeblocks_failure_propagates ... ok
test file_system::tests::test_read_partition_file_locate_failure ... ok
test file_system::tests::test_read_partition_file_handle_protocol_failure ... ok
test file_system::tests::test_encode_ucs2_null_terminated_basic ... ok
test file_system::tests::test_encode_ucs2_null_terminated_path ... ok
test file_system::tests::test_encode_ucs2_null_terminated_empty ... ok
```

The unsafe FFI dispatch paths in `block_io` are exercised against mock `BlockIo` function pointers (capture writes, error propagation, read-only rejection).

Integration Instructions

Consumers depend on `patina_partition = "0.1"` from this repo. Until a `patina` release containing the new APIs is published, consumers needing to build against this crate will also need to redirect `patina` to the `feature/patina-boot` branch (matching the existing pattern in `patina_boot`/`patina_nvme`).

Closes #66 (file-read) and #71 (raw-write) on the SRE board once patina#1489 and patina#1495 are closed in favor of this PR.

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 62 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
patina_partition/src/file_system.rs 51.06% 46 Missing ⚠️
patina_partition/src/block_io.rs 89.61% 16 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impact:testing Affects testing type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants