When application has done lseek() to a different offset on a directory fd we skipped one entry too many before we start emitting directory entries from the cache. Signed-off-by: Ronnie Sahlberg <lsahlber@xxxxxxxxxx> --- fs/cifs/readdir.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c index 8e060c00c969..da0d1e188432 100644 --- a/fs/cifs/readdir.c +++ b/fs/cifs/readdir.c @@ -847,9 +847,13 @@ static bool emit_cached_dirents(struct cached_dirents *cde, int rc; list_for_each_entry(dirent, &cde->entries, entry) { - if (ctx->pos >= dirent->pos) + /* + * Skip ahead until we get to the current position of the + * directory. + */ + if (ctx->pos > dirent->pos) continue; - ctx->pos = dirent->pos; + rc = dir_emit(ctx, dirent->name, dirent->namelen, dirent->fattr.cf_uniqueid, dirent->fattr.cf_dtype); -- 2.35.3