summaryrefslogtreecommitdiff
path: root/fs/adfs/dir_f.c
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@armlinux.org.uk>2019-12-09 11:10:16 +0000
committerAl Viro <viro@zeniv.linux.org.uk>2020-01-20 20:12:41 -0500
commit4287e4deb1280633ffbda608f946d6d7c2d76d4a (patch)
tree4494eba3d3a9ce47f4d7772d6332054bdc08ef7e /fs/adfs/dir_f.c
parentcdc46e99e1c9f50802c4f543f10151887e4c4e0e (diff)
fs/adfs: dir: add more efficient iterate() per-format method
Rather than using setpos + getnext to iterate through the directory entries, pass iterate() down to the dir format code to populate the dirents. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/adfs/dir_f.c')
-rw-r--r--fs/adfs/dir_f.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/fs/adfs/dir_f.c b/fs/adfs/dir_f.c
index 682df46d8d33..2e342871d6df 100644
--- a/fs/adfs/dir_f.c
+++ b/fs/adfs/dir_f.c
@@ -302,6 +302,23 @@ adfs_f_getnext(struct adfs_dir *dir, struct object_info *obj)
return ret;
}
+static int adfs_f_iterate(struct adfs_dir *dir, struct dir_context *ctx)
+{
+ struct object_info obj;
+ int pos = 5 + (ctx->pos - 2) * 26;
+
+ while (ctx->pos < 2 + ADFS_NUM_DIR_ENTRIES) {
+ if (__adfs_dir_get(dir, pos, &obj))
+ break;
+ if (!dir_emit(ctx, obj.name, obj.name_len,
+ obj.indaddr, DT_UNKNOWN))
+ break;
+ pos += 26;
+ ctx->pos++;
+ }
+ return 0;
+}
+
static int
adfs_f_update(struct adfs_dir *dir, struct object_info *obj)
{
@@ -359,6 +376,7 @@ bad_dir:
const struct adfs_dir_ops adfs_f_dir_ops = {
.read = adfs_f_read,
+ .iterate = adfs_f_iterate,
.setpos = adfs_f_setpos,
.getnext = adfs_f_getnext,
.update = adfs_f_update,