From: Simon Glass <sjg@chromium.org>
U-Boot's VFS layer iterates directories one entry at a time,
calling iterate_shared() repeatedly. The Linux implementation
advances ctx->pos after a successful dir_emit(), but this causes
the U-Boot single-entry iterator to see the same entry twice
since it re-enters with the old position.
Move ctx->pos advancement before the dir_emit() call for '.', '..',
and regular entries so that when dir_emit() signals "buffer full"
and iteration resumes, the position already points past the current
entry.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
fs/isofs/dir.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
@@ -175,9 +175,9 @@ static int do_isofs_readdir(struct inode *inode, struct file *file,
/* Handle the case of the '.' directory */
if (de->name_len[0] == 1 && de->name[0] == 0) {
+ ctx->pos += de_len;
if (!dir_emit_dot(file, ctx))
break;
- ctx->pos += de_len;
continue;
}
@@ -185,9 +185,9 @@ static int do_isofs_readdir(struct inode *inode, struct file *file,
/* Handle the case of the '..' directory */
if (de->name_len[0] == 1 && de->name[0] == 1) {
+ ctx->pos += de_len;
if (!dir_emit_dotdot(file, ctx))
break;
- ctx->pos += de_len;
continue;
}
@@ -232,11 +232,11 @@ static int do_isofs_readdir(struct inode *inode, struct file *file,
len = de->name_len[0];
}
}
+ ctx->pos += de_len;
if (len > 0) {
if (!dir_emit(ctx, p, len, inode_number, DT_UNKNOWN))
break;
}
- ctx->pos += de_len;
}
if (bh)
brelse(bh);