Re: [PATCH RFC v2 15/15] tools/ctlv: Add ctlvctl

From: Aneesh Kumar K . V

Date: Fri Dec 04 2026 - 03:24:16 EST


Jiri Pirko <jiri@xxxxxxxxxxx> writes:

> From: Jiri Pirko <jiri@xxxxxxxxxx>
>
> Add a command-line client that discovers and queries any CTLV device,
> with optional names from a specification directory.
>

[ ... 182 lines skipped ... ]

> +In JSON, a blob is ``{"file": "<path>"}``, passed as ``va`` memory. An input
> +blob holds the file. An output blob is written to the file whole, so give it
> +the ``"length"`` the operation writes; without one it starts at a byte and
> +grows to each ``required-length`` the operation fails with, the operation
> +being retried. An ``inout`` blob is read from the file and written back.
> +

[ ... 1376 lines skipped ... ]

> +/* The device does not say how much it wrote, so a file gets the whole blob. */
> +static int blobs_save(const struct blob_files *blobs)
> +{
> + unsigned int i;
> +
> + for (i = 0; i < blobs->count; i++) {
> + const struct blob_file *blob = &blobs->files[i];
> + FILE *file;
> + int ret = 0;
> +
> + if (blob->node->blob_direction == CTLV_BLOB_DIRECTION_INPUT)
> + continue;
> + file = fopen(blob->path, "we");
> + if (!file)
> + ret = -errno;
> + else if (fwrite(blob->data, 1, blob->len, file) != blob->len)
>

Should we limit this write to the length returned by evidence-get? IIUC,
blob->len is the output buffer capacity, while evidence-get reports the
actual evidence length in results.length. That can be smaller than
blob->len

> + ret = errno ? -errno : -EIO;
> + if (file && fclose(file) && !ret)
> + ret = errno ? -errno : -EIO;
> + if (ret) {
> + fprintf(stderr, "%s: %s: %s\n", prog, blob->path,
> + strerror(-ret));
> + return ret;
> + }
> + }
> + return 0;
> +}
> +

-aneesh