ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
unarch_io.h File Reference

Shared seek+read seam and flat-memory backing for the unarchivers. More...

#include <stddef.h>
#include <stdint.h>
Include dependency graph for unarch_io.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  unarch_mem_t
 Bounded flat-memory backing for unarch_read_fn. More...

Typedefs

typedef size_t(* unarch_read_fn) (void *ctx, uint64_t offset, void *buf, size_t len)
 Seek+read backing over an archive's bytes.

Functions

size_t unarch_mem_read (void *ctx, uint64_t offset, void *buf, size_t len)
 unarch_read_fn over a flat unarch_mem_t view.

Detailed Description

Shared seek+read seam and flat-memory backing for the unarchivers.

Tag
[Ring 4 / Domain] {World: NS}

Every decoder in unarch (tar walker, gzip member, XZ stream) consumes its untrusted input through the same seek+read function shape the streaming EPUB / CBZ / CBR readers already use, so one ra8_fs file or ra8_vmem page-cache backing drives every container format identically. This header owns that typedef plus the one trivial backing everybody needs: a bounded flat-memory view (unarch_mem_t + unarch_mem_read) used to re-open the decompressed bytes of a wrapped archive (.tar.gz, .tar.xz) without copying them again.

Note
Thread-safety follows the backing: the flat-memory reader is a pure read and safe anywhere; file-backed readers are single-threaded.
See also
unarch_tar.h The tar walker driven through this seam.
unarch_gzip.h The gzip member decoder driven through this seam.
unarch_xz.h The XZ stream decoder driven through this seam.
Since
Version 0.1.0

Definition in file unarch_io.h.

Typedef Documentation

◆ unarch_read_fn

typedef size_t(* unarch_read_fn) (void *ctx, uint64_t offset, void *buf, size_t len)

Seek+read backing over an archive's bytes.

Identical in shape to comic_read_fn / ra8_rar_read_fn: an absolute offset plus a byte count in, bytes-actually-read out. A return shorter than len signals end-of-file (or a backing error); the decoders treat any short read fail-closed.

Parameters
[in]ctxOpaque backing context.
[in]offsetAbsolute byte offset within the archive.
[out]bufDestination buffer (len writable bytes).
[in]lenBytes requested.
Returns
Bytes actually read (0 at/after EOF or on error).
Note
Thread-safety follows the backing implementation.
Since
Version 0.1.0

Definition at line 55 of file unarch_io.h.

Function Documentation

◆ unarch_mem_read()

size_t unarch_mem_read ( void * ctx,
uint64_t offset,
void * buf,
size_t len )
nodiscard

unarch_read_fn over a flat unarch_mem_t view.

Serves [offset, offset + len) clamped to the view's bounds by plain copy. Reads at or past the end return 0 (EOF); a NULL context or view base also returns 0, which every decoder treats as a failed read (fail-closed).

Parameters
[in]ctxThe unarch_mem_t view (may be NULL: reads 0).
[in]offsetAbsolute byte offset within the view.
[out]bufDestination buffer (len writable bytes, non-NULL).
[in]lenBytes requested.
Returns
Bytes actually copied.
Return values
0NULL view / NULL destination, EOF, or a zero-length request.
Precondition
buf holds len writable bytes when len > 0.
The view's base/len describe readable storage.
Postcondition
At most len bytes of buf are written; nothing else changes.
The view itself is never modified (pure read).
Note
Thread-safe: pure read of an immutable view.
See also
unarch_mem_t
Since
Version 0.1.0

Definition at line 24 of file unarch_io.c.

References unarch_mem_t::base, unarch_mem_t::len, and memcpy().

Referenced by internal_open_unwrapped().