Skip to content

Commit

Permalink
Fix ctx->pos updating to properly handle dent gaps
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
aversecat committed Jan 27, 2025
1 parent 6c85879 commit e9d1472
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion kmod/src/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e9d1472

Please sign in to comment.