From: Simon Glass <simon.glass@canonical.com> Move the directory iteration types and helpers from ext4_uboot.h to linux/fs.h where they belong as part of the VFS interface: - struct dir_context: context for directory iteration - filldir_t: callback type for directory entry emission - dir_emit(): helper to emit a directory entry - dir_relax_shared(): lock relaxation macro (no-op in U-Boot) This makes these types available for other filesystem implementations. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/ext4_uboot.h | 17 ++--------------- include/linux/fs.h | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 4b342089489..4cb9b23a8c7 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -198,14 +198,7 @@ struct kiocb { /* __counted_by attribute - not available in U-Boot */ #define __counted_by(x) -/* dir_context for directory iteration */ -struct dir_context; -typedef int (*filldir_t)(struct dir_context *, const char *, int, loff_t, u64, unsigned); - -struct dir_context { - filldir_t actor; - loff_t pos; -}; +/* dir_context, filldir_t are in linux/fs.h */ /* iomap types and structs are in linux/iomap.h */ @@ -1545,13 +1538,7 @@ extern struct inode *iget_locked(struct super_block *sb, unsigned long ino); #define inode_eq_iversion(i, v) ({ (void)(i); (void)(v); 1; }) #define inode_query_iversion(i) ({ (void)(i); 0ULL; }) -/* Directory context operations - call the actor callback */ -static inline bool dir_emit(struct dir_context *ctx, const char *name, int len, - u64 ino, unsigned int type) -{ - return ctx->actor(ctx, name, len, ctx->pos, ino, type) == 0; -} -#define dir_relax_shared(i) ({ (void)(i); 1; }) +/* dir_emit, dir_relax_shared are in linux/fs.h */ /* File llseek */ #define generic_file_llseek_size(f, o, w, m, e) ({ (void)(f); (void)(o); (void)(w); (void)(m); (void)(e); 0LL; }) diff --git a/include/linux/fs.h b/include/linux/fs.h index 049033c0cd7..af9cf21692b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -173,4 +173,23 @@ static inline void inode_init_once(struct inode *inode) /* S_ISDIR, etc. - already in linux/stat.h */ #include <linux/stat.h> +/* Directory context for readdir iteration */ +struct dir_context; +typedef int (*filldir_t)(struct dir_context *, const char *, int, loff_t, + u64, unsigned); + +struct dir_context { + filldir_t actor; + loff_t pos; +}; + +/* dir_emit - emit a directory entry to the context callback */ +static inline bool dir_emit(struct dir_context *ctx, const char *name, int len, + u64 ino, unsigned int type) +{ + return ctx->actor(ctx, name, len, ctx->pos, ino, type) == 0; +} + +#define dir_relax_shared(i) ({ (void)(i); 1; }) + #endif /* _LINUX_FS_H */ -- 2.43.0