diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-03-18 10:53:12 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-03-26 22:06:14 -0600 |
commit | 865bb702f828784a0225b5eae9ed8803094140d5 (patch) | |
tree | b579303cc5df38191ee9e8ad63793fbe4c867c02 /lib9p_util | |
parent | 63fcccd84cb348b1b4194024a0dea4dd81941daf (diff) |
lib9p: Adjust for reads to be zero-copy
Diffstat (limited to 'lib9p_util')
-rw-r--r-- | lib9p_util/static.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib9p_util/static.c b/lib9p_util/static.c index 50bb129..7f1e6b7 100644 --- a/lib9p_util/static.c +++ b/lib9p_util/static.c @@ -218,27 +218,27 @@ static uint32_t util9p_static_file_iounit(struct util9p_static_file *self) { assert(self); return 0; } -static uint32_t util9p_static_file_pread(struct util9p_static_file *self, struct lib9p_srv_ctx *ctx, - void *buf, - uint32_t byte_count, - uint64_t byte_offset) { +static void util9p_static_file_pread(struct util9p_static_file *self, struct lib9p_srv_ctx *ctx, + uint32_t byte_count, uint64_t byte_offset, + struct iovec *ret) { assert(self); assert(ctx); + assert(ret); size_t data_size = util9p_static_file_size(self); if (byte_offset > (uint64_t)data_size) { lib9p_error(&ctx->basectx, LINUX_EINVAL, "offset is past end-of-file length"); - return 0; + return; } size_t beg_off = (size_t)byte_offset; size_t end_off = beg_off + (size_t)byte_count; if (end_off > data_size) end_off = data_size; - memcpy(buf, &self->data_start[beg_off], end_off-beg_off); - return (uint32_t)(end_off-beg_off); + ret->iov_base = &self->data_start[beg_off]; + ret->iov_len = end_off-beg_off; } static uint32_t util9p_static_file_pwrite(struct util9p_static_file *self, struct lib9p_srv_ctx *ctx, void *LM_UNUSED(buf), |