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

Private portable byte-stream contracts for media exporters. More...

#include <stddef.h>
#include <stdint.h>
#include "mdl_export.h"
#include "mdl_storage.h"
#include "miniz.h"
#include "ra8_attributes.h"
#include "ra8_err.h"
Include dependency graph for mdl_export_io_internal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  mdl_export_source_t
 One open regular source with a snapshotted identity. More...
struct  mdl_export_output_t
 One validated staged publication, including random ZIP backfill. More...

Typedefs

typedef ra8_err_t(* mdl_export_sink_fn_t) (void *ctx, const uint8_t *bytes, uint32_t length)
 Portable archive-output sink signature.

Functions

ra8_err_t priv_mdl_export_output_begin (mdl_export_output_t *output, mdl_storage_t *storage, const char *destination, mdl_format_t format)
 Bind a validated publication transaction to one destination.
ra8_err_t priv_mdl_export_output_begin_new (mdl_export_output_t *output, mdl_storage_t *storage, const char *destination, mdl_format_t format)
 Bind a create-new validated publication transaction.
ra8_err_t priv_mdl_export_output_write (mdl_export_output_t *output, const uint8_t *bytes, uint32_t length)
 Append one complete byte span to an active export stage.
ra8_err_t priv_mdl_export_output_write_at (void *opaque, uint64_t offset, const uint8_t *bytes, uint32_t length, uint32_t *out_written)
 Write one complete span at an absolute active-stage offset.
size_t priv_mdl_export_zip_write (void *opaque, mz_uint64 file_offset, const void *bytes, size_t length)
 Adapt random-offset miniz output to the active export stage.
ra8_err_t priv_mdl_export_output_commit (mdl_export_output_t *output, mdl_export_workspace_t *workspace, bool *out_published)
 Structurally validate and publish one completed export stage.
ra8_err_t priv_mdl_export_output_abort (mdl_export_output_t *output)
 Abort one unpublished export stage, retaining cleanup failure.
ra8_err_t priv_mdl_export_source_open (mdl_export_source_t *source, mdl_storage_t *storage, const char *path)
 Open one regular source and snapshot its exact nonempty extent.
ra8_err_t priv_mdl_export_source_close (mdl_export_source_t *source)
 Close one open source and clear its retained binding.
size_t priv_mdl_export_zip_read (void *opaque, mz_uint64 file_offset, void *destination, size_t capacity)
 Adapt one sequential miniz source read to a portable file stream.
ra8_err_t priv_mdl_export_source_verify_close (mdl_export_source_t *source)
 Verify the first source pass against an independent reread.
ra8_err_t priv_mdl_export_zip_add_file (mz_zip_archive *zip, mdl_storage_t *storage, const char *member, const char *path, mz_uint flags)
 Add one portable source file through miniz callbacks.
ra8_err_t priv_mdl_export_zip_add_memory (mz_zip_archive *zip, const char *member, const uint8_t *bytes, size_t length, mz_uint flags)
 Add caller-owned memory through the deterministic ZIP read seam.
ra8_err_t priv_mdl_export_source_copy (mdl_export_source_t *source, mdl_export_sink_fn_t sink, void *sink_ctx)
 Stream one portable source into a bounded caller sink.
ra8_err_t priv_mdl_export_source_slurp (mdl_storage_t *storage, const char *path, uint8_t *destination, size_t capacity, size_t *out_length)
 Read one complete bounded portable source into caller storage.
ra8_err_t priv_mdl_export_path_join (char *out, size_t capacity, const char *directory, const char *leaf)
 Join a canonical directory and leaf without truncation.

Detailed Description

Private portable byte-stream contracts for media exporters.

Binds archive sources and validated publication transactions to the existing downloader storage dependency. The contract owns no allocation, host descriptor, or device-specific path operation.

[Ring 4 / Domain] {World: NS}

Since
0.1.0

Definition in file mdl_export_io_internal.h.

Typedef Documentation

◆ mdl_export_sink_fn_t

typedef ra8_err_t(* mdl_export_sink_fn_t) (void *ctx, const uint8_t *bytes, uint32_t length)

Portable archive-output sink signature.

Definition at line 47 of file mdl_export_io_internal.h.

Function Documentation

◆ priv_mdl_export_output_abort()

ra8_err_t priv_mdl_export_output_abort ( mdl_export_output_t * output)

Abort one unpublished export stage, retaining cleanup failure.

Delegates stage removal once and clears the exporter binding only after capturing the transaction's cleanup result.

Parameters
[in,out]outputActive caller-owned staged output.
Returns
Abort status.
Return values
k_ra8_okThe unpublished stage was removed.
k_ra8_failThe injected transaction could not clean its stage.
Precondition
output is non-NULL and owns an active transaction.
No writer or verifier continues to borrow the staged handle.
Postcondition
The output no longer reports an active transaction.
The destination is never published by this call.
Note
Not thread-safe for a shared output state.
Since
0.1.0

Definition at line 217 of file mdl_export_io.c.

References k_ra8_err_invalid_arg, k_ra8_ok, mdl_storage_txn_abort(), and mdl_export_output_t::writer.

Referenced by internal_direct_artifact_reset(), internal_emit_container(), internal_export_transaction(), internal_finish_artifact_fetch(), internal_jof_one(), internal_write_temp_epub(), and priv_mdl_export_output_commit().

◆ priv_mdl_export_output_begin()

ra8_err_t priv_mdl_export_output_begin ( mdl_export_output_t * output,
mdl_storage_t * storage,
const char * destination,
mdl_format_t format )

Bind a validated publication transaction to one destination.

Initializes the output cursor only after the injected storage transaction accepts the canonical destination.

Parameters
[out]outputCaller-owned output state to initialize.
[in,out]storageExclusive portable storage transaction provider.
[in]destinationCanonical NUL-terminated destination path.
[in]formatExact format used by the canonical staged verifier.
Returns
Transaction-open status.
Return values
k_ra8_okA new unpublished stage is active.
k_ra8_err_invalid_argAn argument or format is invalid.
Precondition
All pointers are non-NULL and destination is stable for the call.
output is not already bound to an active transaction.
Postcondition
Success initializes every output field and owns one active stage.
Failure leaves output inactive and publishes no destination bytes.
Note
Thread-safe across distinct storage and output bindings.
Since
0.1.0

Definition at line 129 of file mdl_export_io.c.

References k_ra8_err_invalid_arg, k_ra8_ok, mdl_format_is_verifiable(), mdl_storage_txn_begin(), and mdl_export_output_t::writer.

Referenced by internal_direct_artifact_reset(), internal_emit_container(), internal_export_transaction(), and internal_jof_one().

◆ priv_mdl_export_output_begin_new()

ra8_err_t priv_mdl_export_output_begin_new ( mdl_export_output_t * output,
mdl_storage_t * storage,
const char * destination,
mdl_format_t format )

Bind a create-new validated publication transaction.

Mirrors priv_mdl_export_output_begin but refuses an existing destination, which is required for private intermediate artifacts.

Parameters
[out]outputCaller-owned output state to initialize.
[in,out]storageExclusive portable storage transaction provider.
[in]destinationCanonical absent destination path.
[in]formatExact format used by the staged verifier.
Returns
Transaction-open status.
Return values
k_ra8_okA new unpublished stage is active.
k_ra8_err_existsThe destination already exists.
k_ra8_err_invalid_argAn argument or format is invalid.
Precondition
All pointers are non-NULL and destination is stable for the call.
output is not already bound to an active transaction.
Postcondition
Success initializes every output field and owns one active stage.
Failure leaves output inactive and changes no named file.
Note
Thread-safe across distinct storage and output bindings.
Since
0.1.0

Definition at line 146 of file mdl_export_io.c.

References k_ra8_err_invalid_arg, k_ra8_ok, mdl_format_is_verifiable(), mdl_storage_txn_begin_new(), RA8_PRIV, and mdl_export_output_t::writer.

Referenced by priv_mdl_rabook_temp_begin().

◆ priv_mdl_export_output_commit()

ra8_err_t priv_mdl_export_output_commit ( mdl_export_output_t * output,
mdl_export_workspace_t * workspace,
bool * out_published )

Structurally validate and publish one completed export stage.

Runs the canonical format verifier against the borrowed staged file, then asks the injected transaction to publish it once.

Parameters
[in,out]outputCompleted caller-owned staged output.
[in,out]workspaceExclusive caller arena used by the verifier.
[out]out_publishedWhether the transaction reports destination visibility.
Returns
Validation or commit status.
Return values
k_ra8_okValidation and publication completed.
k_ra8_err_validation_failedCanonical structural validation failed.
Precondition
output owns an active transaction with no retained writer error.
workspace and out_published are writable and caller-owned.
Postcondition
Success leaves no active stage and sets out_published true.
Failure reports publication truthfully and leaves cleanup to the transaction.
Note
Power-loss durability depends on the injected storage capabilities.
Since
0.1.0

Definition at line 229 of file mdl_export_io.c.

References fw_fs_transaction_t::active, mdl_export_output_t::error, mdl_export_output_t::extent, mdl_export_output_t::format, fw_fs_transaction_abort(), fw_fs_transaction_commit(), fw_fs_transaction_validate(), mdl_export_workspace::high_water, internal_validate_stage(), k_ra8_err_invalid_arg, k_ra8_err_invalid_state, k_ra8_ok, priv_mdl_export_output_abort(), mdl_storage_txn_t::storage, mdl_storage_txn_t::transaction, and mdl_export_output_t::writer.

Referenced by internal_emit_container(), internal_export_transaction(), internal_fetch_artifact(), internal_jof_one(), and internal_write_temp_epub().

◆ priv_mdl_export_output_write()

ra8_err_t priv_mdl_export_output_write ( mdl_export_output_t * output,
const uint8_t * bytes,
uint32_t length )

Append one complete byte span to an active export stage.

Retries bounded short writes, advances the sequential cursor, and retains the first storage failure in the output state.

Parameters
[in,out]outputActive caller-owned staged output.
[in]bytesReadable bytes to append.
[in]lengthExact byte count to append.
Returns
Complete-write status.
Return values
k_ra8_okEvery requested byte was written.
k_ra8_failThe sink failed or made zero progress.
Precondition
output owns an active transaction and has no retained error.
bytes addresses length readable bytes when length is nonzero.
Postcondition
Success advances offset and extent by exactly length.
Failure retains the first error and never reports partial success.
Note
Not thread-safe for a shared output state.
Since
0.1.0

Definition at line 164 of file mdl_export_io.c.

References fw_fs_transaction_t::active, mdl_export_output_t::error, internal_output_write_at(), k_ra8_err_invalid_arg, k_ra8_ok, mdl_export_output_t::offset, mdl_storage_txn_t::transaction, and mdl_export_output_t::writer.

Referenced by internal_direct_artifact_write(), internal_direct_sink(), internal_gzip_put(), internal_jof_sink(), and priv_mdl_export_tar_gzip().

◆ priv_mdl_export_output_write_at()

ra8_err_t priv_mdl_export_output_write_at ( void * opaque,
uint64_t offset,
const uint8_t * bytes,
uint32_t length,
uint32_t * out_written )

Write one complete span at an absolute active-stage offset.

Adapts the export transaction to the RABOOK container writer's random-write contract while retaining the first output error.

Parameters
[in,out]opaqueBound mdl_export_output_t.
[in]offsetAbsolute stage offset; holes are rejected.
[in]bytesReadable source bytes.
[in]lengthExact requested byte count.
[out]out_writtenExact written byte count on success.
Returns
Complete random-write status.
Return values
k_ra8_okEvery requested byte was staged.
k_ra8_err_invalid_argA pointer or output lifecycle is invalid.
k_ra8_err_invalid_sizeThe write would create a hole or overflow.
Precondition
opaque owns one active transaction and bytes spans length bytes.
out_written is non-NULL and exclusively writable.
Postcondition
Success sets out_written to length and updates the staged extent.
Failure sets out_written to zero and retains the first output error.
Note
Not thread-safe for a shared output.
Since
0.1.0

Definition at line 177 of file mdl_export_io.c.

References fw_fs_transaction_t::active, mdl_export_output_t::error, internal_output_write_at(), k_ra8_err_invalid_arg, k_ra8_ok, RA8_PRIV, mdl_storage_txn_t::transaction, and mdl_export_output_t::writer.

Referenced by internal_emit_container().

◆ priv_mdl_export_path_join()

ra8_err_t priv_mdl_export_path_join ( char * out,
size_t capacity,
const char * directory,
const char * leaf )

Join a canonical directory and leaf without truncation.

Inserts one separator only when required and rejects arithmetic or capacity overflow before copying either component.

Parameters
[out]outCaller-owned destination string.
[in]capacityTotal writable bytes including the terminator.
[in]directoryCanonical NUL-terminated directory.
[in]leafCanonical NUL-terminated leaf.
Returns
Join status.
Return values
k_ra8_okThe complete joined path fits.
k_ra8_err_invalid_sizeThe complete path exceeds capacity.
Precondition
All pointers are non-NULL and input strings are stable.
out is writable for capacity bytes and does not overlap inputs.
Postcondition
Success leaves one NUL-terminated joined path.
Failure leaves out as an empty string when capacity is nonzero.
Note
Pure apart from the caller-owned destination.
Since
0.1.0

Definition at line 551 of file mdl_export_io.c.

References k_ra8_err_invalid_arg, k_ra8_err_invalid_size, k_ra8_ok, and strcmp().

Referenced by internal_build_tar(), internal_cbz_add_pages(), internal_epub_add_page(), internal_epub_media_type_from_sniff(), internal_meta_candidate_path(), internal_metadata_set_page_timestamp(), priv_mdl_export_jof(), and priv_mdl_rabook_temp_begin().

◆ priv_mdl_export_source_close()

ra8_err_t priv_mdl_export_source_close ( mdl_export_source_t * source)

Close one open source and clear its retained binding.

Closes the injected stream exactly once and clears all borrowed storage and cursor state regardless of close status.

Parameters
[in,out]sourceOpen caller-owned source state.
Returns
Close status.
Return values
k_ra8_okThe source closed cleanly.
k_ra8_failThe injected close operation failed.
Precondition
source is non-NULL and owns an open portable stream.
No callback continues to use the source handle.
Postcondition
The source owns no open stream.
The source's retained binding and extent are cleared.
Note
Not thread-safe for a shared source state.
Since
0.1.0

Definition at line 315 of file mdl_export_io.c.

References mdl_export_source_t::file, fw_fs_close(), fw_fs_file_t::is_open, k_ra8_err_invalid_arg, and k_ra8_ok.

Referenced by internal_tar_write_source(), priv_mdl_export_source_slurp(), and priv_mdl_export_zip_add_file().

◆ priv_mdl_export_source_copy()

ra8_err_t priv_mdl_export_source_copy ( mdl_export_source_t * source,
mdl_export_sink_fn_t sink,
void * sink_ctx )

Stream one portable source into a bounded caller sink.

Reads the exact snapshotted extent through storage scratch, offers each bounded span to the sink, then performs an independent reread.

Parameters
[in,out]sourceOpen caller-owned source.
[in]sinkNon-NULL bounded output callback.
[in,out]sink_ctxOpaque sink context retained by the caller.
Returns
Copy, identity, or close status.
Return values
k_ra8_okThe whole stable source reached the sink.
k_ra8_err_validation_failedThe source changed during the copy.
Precondition
source owns an open stream and sink is callable.
The storage I/O scratch is exclusive to this operation.
Postcondition
The source is closed on every return path.
Success offers every source byte exactly once in order.
Note
Sink ownership never transfers to the exporter.
Since
0.1.0

Definition at line 499 of file mdl_export_io.c.

References mdl_export_source_t::error, mdl_export_source_t::file, mdl_storage_t::io_buffer, mdl_storage_t::io_buffer_bytes, fw_fs_file_t::is_open, k_ra8_err_invalid_arg, k_ra8_ok, mdl_export_source_t::offset, priv_mdl_export_source_verify_close(), priv_mdl_export_zip_read(), mdl_export_source_t::size, and mdl_export_source_t::storage.

Referenced by internal_tar_write_source().

◆ priv_mdl_export_source_open()

ra8_err_t priv_mdl_export_source_open ( mdl_export_source_t * source,
mdl_storage_t * storage,
const char * path )

Open one regular source and snapshot its exact nonempty extent.

Rejects missing, empty, symlink, and nonregular nodes before opening the stream through the injected portable filesystem.

Parameters
[out]sourceCaller-owned source state to initialize.
[in,out]storageExclusive portable stream provider.
[in]pathCanonical NUL-terminated source path.
Returns
Source-open status.
Return values
k_ra8_okA regular nonempty source is open.
k_ra8_err_invalid_argThe node is symlinked or nonregular.
Precondition
Pointers are non-NULL and path remains stable for the call.
source does not own an open stream.
Postcondition
Success snapshots size and initializes hash/cursor state.
Failure leaves source clear and owns no stream.
Note
Not thread-safe against concurrent source replacement.
Since
0.1.0

Definition at line 270 of file mdl_export_io.c.

References fw_fs_stat_t::exists, mdl_export_source_t::file, mdl_storage_t::file_workspace, mdl_storage_t::file_workspace_bytes, mdl_storage_t::fs, fw_fs_close(), fw_fs_file_size(), fw_fs_open(), fw_fs_stat(), fw_fs_file_t::is_open, k_fw_fs_node_file, k_fw_fs_open_read, k_mdl_fnv_offset, k_mdl_hash_max_file_bytes, k_ra8_err_invalid_arg, k_ra8_err_invalid_size, k_ra8_err_not_found, k_ra8_err_protocol_error, k_ra8_ok, fw_fs_t::names, mdl_export_source_t::size, fw_fs_stat_t::size_bytes, fw_fs_t::streams, and fw_fs_stat_t::type.

Referenced by internal_tar_write_source(), priv_mdl_export_source_slurp(), and priv_mdl_export_zip_add_file().

◆ priv_mdl_export_source_slurp()

ra8_err_t priv_mdl_export_source_slurp ( mdl_storage_t * storage,
const char * path,
uint8_t * destination,
size_t capacity,
size_t * out_length )

Read one complete bounded portable source into caller storage.

Opens and consumes one stable regular file without truncation, verifies it through an independent reread, and returns exact length.

Parameters
[in,out]storageExclusive portable source storage.
[in]pathCanonical source path.
[out]destinationCaller-owned byte buffer.
[in]capacityWritable destination capacity.
[out]out_lengthExact copied extent on success.
Returns
Bounded read status.
Return values
k_ra8_okA stable complete source was copied.
k_ra8_err_invalid_sizeThe snapshot exceeds capacity.
Precondition
Pointers are non-NULL and destination is writable for capacity.
storage is initialized and exclusive to this read.
Postcondition
Success sets out_length and fills exactly that many bytes.
Failure sets out_length to zero and closes any opened stream.
Note
No partial buffer content is claimed on failure.
Since
0.1.0

Definition at line 520 of file mdl_export_io.c.

References k_ra8_err_invalid_arg, k_ra8_err_invalid_size, k_ra8_err_protocol_error, k_ra8_ok, priv_mdl_export_source_close(), priv_mdl_export_source_open(), priv_mdl_export_source_verify_close(), priv_mdl_export_zip_read(), and mdl_export_source_t::size.

Referenced by internal_jof_load_source(), and internal_meta_load_candidate().

◆ priv_mdl_export_source_verify_close()

ra8_err_t priv_mdl_export_source_verify_close ( mdl_export_source_t * source)

Verify the first source pass against an independent reread.

Requires complete first-pass consumption, seeks to the beginning, hashes an independent bounded reread, checks size stability, and closes.

Parameters
[in,out]sourceOpen source after a complete first pass.
Returns
Identity and close status.
Return values
k_ra8_okBoth passes and the final size snapshot match.
k_ra8_err_validation_failedThe source changed between passes.
Precondition
source owns an open regular stream.
Its first-pass cursor and hash describe the exported member bytes.
Postcondition
The source is closed on every return path.
Success proves both passes consumed the snapshotted extent identically.
Note
Fails closed on seek, read, stat, truncation, or growth.
Since
0.1.0

Definition at line 368 of file mdl_export_io.c.

References mdl_export_source_t::error, mdl_export_source_t::file, fw_fs_close(), fw_fs_seek(), mdl_export_source_t::hash, mdl_storage_t::io_buffer, mdl_storage_t::io_buffer_bytes, fw_fs_file_t::is_open, k_ra8_err_invalid_arg, k_ra8_err_protocol_error, k_ra8_ok, mdl_hash_stream(), mdl_export_source_t::offset, mdl_export_source_t::size, and mdl_export_source_t::storage.

Referenced by priv_mdl_export_source_copy(), priv_mdl_export_source_slurp(), and priv_mdl_export_zip_add_file().

◆ priv_mdl_export_zip_add_file()

ra8_err_t priv_mdl_export_zip_add_file ( mz_zip_archive * zip,
mdl_storage_t * storage,
const char * member,
const char * path,
mz_uint flags )

Add one portable source file through miniz callbacks.

Opens the source through injected storage, supplies deterministic callback metadata to miniz, then independently rereads before success.

Parameters
[in,out]zipInitialized caller-arena miniz writer.
[in,out]storageExclusive portable source storage.
[in]memberCanonical archive member name.
[in]pathCanonical source path.
[in]flagsMiniz compression flags.
Returns
Member-add status.
Return values
k_ra8_okThe complete stable source was added.
k_ra8_err_validation_failedThe source changed during export.
Precondition
Pointers and strings are non-NULL and stable for the call.
zip is initialized with caller-owned allocator and output callbacks.
Postcondition
Success appends exactly one deterministic member.
Every opened source closes on success and failure.
Note
Uses a NULL member timestamp to preserve byte determinism.
Since
0.1.0

Definition at line 399 of file mdl_export_io.c.

References mdl_export_source_t::error, k_ra8_fail, k_ra8_ok, priv_mdl_export_source_close(), priv_mdl_export_source_open(), priv_mdl_export_source_verify_close(), priv_mdl_export_zip_read(), and mdl_export_source_t::size.

Referenced by internal_cbz_add_pages(), internal_epub_add_external_cover(), internal_epub_add_page(), and priv_mdl_export_cbz().

◆ priv_mdl_export_zip_add_memory()

ra8_err_t priv_mdl_export_zip_add_memory ( mz_zip_archive * zip,
const char * member,
const uint8_t * bytes,
size_t length,
mz_uint flags )

Add caller-owned memory through the deterministic ZIP read seam.

Binds an immutable bounded cursor to miniz's read-callback API so generated metadata uses the same deterministic member path.

Parameters
[in,out]zipInitialized caller-arena miniz writer.
[in]memberCanonical archive member name.
[in]bytesImmutable caller-owned member bytes.
[in]lengthExact member extent.
[in]flagsMiniz compression flags.
Returns
Member-add status.
Return values
k_ra8_okThe memory member was added completely.
k_ra8_failMiniz rejected or incompletely consumed the member.
Precondition
Pointers are non-NULL and bytes remains readable for length.
zip is initialized and its caller arena remains live.
Postcondition
Success appends exactly one deterministic member.
Input bytes and caller ownership remain unchanged.
Note
Uses a NULL member timestamp to avoid host-clock dependence.
Since
0.1.0

Definition at line 472 of file mdl_export_io.c.

References internal_memory_read(), k_ra8_err_invalid_arg, k_ra8_fail, k_ra8_ok, internal_export_memory_t::length, and internal_export_memory_t::offset.

Referenced by internal_cbz_add_metadata(), and priv_mdl_epub_add_str().

◆ priv_mdl_export_zip_read()

size_t priv_mdl_export_zip_read ( void * opaque,
mz_uint64 file_offset,
void * destination,
size_t capacity )

Adapt one sequential miniz source read to a portable file stream.

Enforces exact sequential offsets, bounded progress, snapshotted extent, and a running first-pass identity hash for later reread.

Parameters
[in,out]opaqueBorrowed mdl_export_source_t callback context.
[in]file_offsetAbsolute source offset requested by miniz.
[out]destinationWritable callback destination.
[in]capacityMaximum bytes requested.
Returns
Bytes read, or zero on EOF/failure.
Return values
0End of the snapshot or a retained protocol/storage failure.
Precondition
opaque owns an open source and destination is writable.
Calls are sequential and do not exceed the snapshotted extent.
Postcondition
Success advances the source cursor and hash by the returned count.
Failure retains a non-ok error unless the snapshot is exactly exhausted.
Note
Called synchronously by one miniz writer.
Since
0.1.0

Definition at line 331 of file mdl_export_io.c.

References mdl_export_source_t::calls, mdl_export_source_t::error, mdl_export_source_t::file, fw_fs_read(), mdl_export_source_t::hash, fw_fs_file_t::is_open, k_export_io_calls, k_ra8_err_invalid_size, k_ra8_err_invalid_state, k_ra8_err_protocol_error, k_ra8_ok, mdl_hash_bytes_seed(), mdl_export_source_t::offset, and mdl_export_source_t::size.

Referenced by priv_mdl_export_source_copy(), priv_mdl_export_source_slurp(), and priv_mdl_export_zip_add_file().

◆ priv_mdl_export_zip_write()

size_t priv_mdl_export_zip_write ( void * opaque,
mz_uint64 file_offset,
const void * bytes,
size_t length )

Adapt random-offset miniz output to the active export stage.

Seeks the injected transaction for ZIP backfill, writes the whole span with bounded progress, and returns miniz-compatible byte count.

Parameters
[in,out]opaqueBorrowed mdl_export_output_t callback context.
[in]file_offsetAbsolute staged-file offset selected by miniz.
[in]bytesReadable archive bytes.
[in]lengthRequested byte count.
Returns
length on complete success, otherwise zero.
Return values
0Seek, size, or write failure occurred.
Precondition
opaque is a live output and bytes is readable for length.
file_offset and length admit a uint64 extent without overflow.
Postcondition
Success updates the cursor and greatest staged extent exactly.
Failure retains the first error for the owning writer.
Note
Called synchronously by one miniz writer.
Since
0.1.0

Definition at line 201 of file mdl_export_io.c.

References fw_fs_transaction_t::active, mdl_export_output_t::error, internal_output_write_at(), k_ra8_ok, mdl_storage_txn_t::transaction, and mdl_export_output_t::writer.

Referenced by priv_mdl_export_cbz(), and priv_mdl_export_epub().