Skip to content

manifest: plan and assemble read manifests only through a blocking Reader #49

Open

Description

@brauner

uapi16 can read a manifest without doing any I/O itself. A Decoder
takes the bytes it's fed and hands out the root file object, the
objects after it and the end of the manifest, and Reader is a blocking
driver on top of it (cf. 1). ufat only ever uses the Reader:

  • Plan::add_records(), Volume::assemble() and
    Volume::assemble_with_observer() take a &mut Reader and pull the
    objects out of it (cf. 2, 3).
  • The SHA-256 of the manifest, which the serial number can be derived
    from, is computed in ManifestBytes::read(), the Read the Reader reads
    from (cf. 4).
  • The contents of the files go through ContentSource::copy(), which
    writes them into a Write, and StreamSource reads a stream of them with
    blocking reads (cf. 5).

So a caller that reads the manifest without blocking, from a pipe with
O_NONBLOCK or on an async runtime, can't drive any of it. The Reader
itself takes a WouldBlock and reads on from where it was the next time
it's asked (cf. 6). But add_records() and assemble_with_observer()
pass the error up with ? and are done (cf. 7, 8).

Currently, the service doesn't need more. It refuses a descriptor with
O_NONBLOCK (cf. 9), and a read fails when a client sets the flag
during a call (#26). For non-blocking or async I/O we need a driver on
the ufat side though:

(1) The plan and the assembly take one object at a time. The work per
object is there already, in the loop of add_records() and in
Assembly::apply() and finish() (cf. 7, 10). The Reader
functions become loops over that and keep their API.

(2) A driver that feeds a Decoder from non-blocking reads, hashes
exactly the bytes Decoder::feed() took, and hands each object to
the plan or to the assembly. The hash moves out of ManifestBytes
then.

(3) Contents that come in pieces. The volume writes a file's data as it
arrives, through begin_file(), write_file_data() and finish_file()
(cf. 11), and uapi16's ContentCheck checks its size and hash the
same way (cf. 12).

None of this needs anything from uapi16 that isn't public already, so
it doesn't have to wait for #34.

Activity

  1. added
    enhancement
    on Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions