Fix ctx->pos updating to properly handle dent gaps

We need to assure we're emitting dents with the proper position
and we already have them as part of our dent. The only caveat is
to increment ctx->pos once beyond the list to make sure the caller
doesn't call us once more.

Signed-off-by: Auke Kok <auke.kok@versity.com>
This commit is contained in:
Auke Kok
2025-01-27 14:46:29 -05:00
parent 6c85879489
commit e9d147260c

View File

@@ -537,15 +537,18 @@ static int scoutfs_readdir(struct file *file, struct dir_context *ctx)
dent = page_address(page);
for (; entries > 0; entries--) {
ctx->pos = le64_to_cpu(dent->pos);
if (!dir_emit(ctx, dent->name, dent->hacky_name_len,
le64_to_cpu(dent->ino),
dentry_type(dent->type))) {
ret = 0;
goto out;
}
ctx->pos = le64_to_cpu(dent->pos) + 1;
dent = next_aligned_dirent(dent, dent->hacky_name_len);
/* always advance ctx->pos past */
ctx->pos++;
}
if (complete)