Skip to content

Add support for oci-archives#78

Merged
cgwalters merged 2 commits into
bootc-dev:mainfrom
alexlarsson:tar-support
Jun 16, 2026
Merged

Add support for oci-archives#78
cgwalters merged 2 commits into
bootc-dev:mainfrom
alexlarsson:tar-support

Conversation

@alexlarsson

Copy link
Copy Markdown
Contributor

This adds support for read-only access to oci-archives by abstracting out the read part of OciDir to a trait that then has a OciDir implementation and an OciArchive implementation.

The goal of this is to use it in composefs-rs to do an efficient local version of delta pulls without using the skopeo proxy (although it will also work for regular local oci-archive pulls).

This change is essentially API compat, except users need to add use ocidir::prelude::* to pull in the new trait.

Move read_blob, read_index, has_blob, and all derived read-only methods
(fsck, find_referrers, open_image_this_platform, etc.) from impl OciDir
into a new OciRead trait with default methods. OciDir implements the
trait, so all existing call sites work once OciRead is in scope.

A prelude module re-exports OciRead for convenient importing.

This prepares for adding OciArchive (read-only tar-based backend) that
will share the same read logic via the trait without any code duplication.
It changes none of the behaviour, or the API (other than the requirement
to import that prelude to use the trait).

Signed-off-by: Alexander Larsson <alexl@redhat.com>
Assisted-by: Claude Code (Claude Opus 4.6)
Add OciArchive, a read-only OCI image backend that reads directly from
tar archives using pread for concurrent access. It implements OciRead
so all manifest resolution, fsck, and referrer logic works without
code duplication.

Key changes:
- ArchiveReader: a Read+Seek adapter over a region of a file using pread
- OciArchive: scans tar entries on open, serves reads via ArchiveReader

Assisted-by: Claude Code (Claude Opus 4.6)
Signed-off-by: Alexander Larsson <alexl@redhat.com>
Comment thread src/lib.rs

/// A reader for a region of a file, using pread for concurrent access.
#[derive(Debug)]
pub struct ArchiveReader {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor bike shed perhaps FileRangeReader

Comment thread src/lib.rs

/// A reader for a region of a file, using pread for concurrent access.
#[derive(Debug)]
pub struct ArchiveReader {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be pub - let's audit this code for unnecessary pub

@cgwalters cgwalters merged commit e137648 into bootc-dev:main Jun 16, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants