diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-10-12 18:39:00 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-10-12 18:39:00 -0600 |
commit | c0aa439917eb204ef481bc037dc3f552ab9d36c0 (patch) | |
tree | d03ff95462239229652db2dd10c17269b670a669 /lib9p/srv.c | |
parent | eb4e0bc7dd140b356a62071bf8e0427fc0cee816 (diff) |
lib9p: Fix directory listing
Diffstat (limited to 'lib9p/srv.c')
-rw-r--r-- | lib9p/srv.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib9p/srv.c b/lib9p/srv.c index 6953687..a3e4335 100644 --- a/lib9p/srv.c +++ b/lib9p/srv.c @@ -813,6 +813,7 @@ static void handle_Tread(struct _lib9p_srv_req *ctx, /* Do it. */ if (fidinfo->flags & FIDFLAG_ISDIR) { + /* Translate byte-offset to object-index. */ size_t idx; if (req->offset == 0) idx = 0; @@ -824,16 +825,19 @@ static void handle_Tread(struct _lib9p_srv_req *ctx, fidinfo->dir_off, req->offset); return; } + /* Do it. */ size_t num = file->vtable->dread(&ctx->ctx, file, (uint8_t *)resp->data.dat, req->count, idx); - fidinfo->dir_idx = idx+num; + /* Translate object-count back to byte-count. */ uint32_t len = 0; for (size_t i = 0; i < num; i++) { uint32_t i_len; - lib9p_validate_stat(&ctx->ctx.basectx, req->count, (uint8_t *)resp->data.dat, &i_len, NULL); + lib9p_validate_stat(&ctx->ctx.basectx, req->count, &((uint8_t *)resp->data.dat)[len], &i_len, NULL); len += i_len; } - fidinfo->dir_off = req->offset + len; resp->data.len = len; + /* Remember. */ + fidinfo->dir_idx = idx+num; + fidinfo->dir_off = req->offset + len; } else resp->data.len = file->vtable->pread(&ctx->ctx, file, resp->data.dat, req->count, req->offset); } |