From: Simon Glass <simon.glass@canonical.com> Add dir.c to the Makefile and provide necessary stubs: - Replace Linux includes with ext4_uboot.h - Add fscrypt directory operation stubs - Add readahead, inode version, and dir_emit stubs - Add struct file_operations with needed members - Add generic_read_dir, ext4_llseek, ext4_htree_fill_tree stubs - Add ext4_ioctl, ext4_sync_file, ext4_dirblock_csum_verify stubs Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- fs/ext4l/Makefile | 2 +- fs/ext4l/dir.c | 6 +----- fs/ext4l/ext4_uboot.h | 49 +++++++++++++++++++++++++++++++++++++++++++ fs/ext4l/stub.c | 48 +++++++++++++++++++++++++++++++++++++++++- 4 files changed, 98 insertions(+), 7 deletions(-) diff --git a/fs/ext4l/Makefile b/fs/ext4l/Makefile index f9c0f77b8ed..28d483a7810 100644 --- a/fs/ext4l/Makefile +++ b/fs/ext4l/Makefile @@ -5,7 +5,7 @@ obj-y := interface.o stub.o -obj-y += balloc.o bitmap.o block_validity.o ext4_jbd2.o extents.o \ +obj-y += balloc.o bitmap.o block_validity.o dir.o ext4_jbd2.o extents.o \ extents_status.o hash.o ialloc.o \ indirect.o inode.o \ xattr_hurd.o xattr_trusted.o \ diff --git a/fs/ext4l/dir.c b/fs/ext4l/dir.c index d4164c507a9..9c4b853defa 100644 --- a/fs/ext4l/dir.c +++ b/fs/ext4l/dir.c @@ -22,11 +22,7 @@ * */ -#include <linux/fs.h> -#include <linux/buffer_head.h> -#include <linux/slab.h> -#include <linux/iversion.h> -#include <linux/unicode.h> +#include "ext4_uboot.h" #include "ext4.h" #include "xattr.h" diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 3f11fb47544..5380b7ed701 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -1402,4 +1402,53 @@ static inline unsigned int i_gid_read(const struct inode *inode) #define truncate_inode_pages_final(m) do { } while (0) #define truncate_pagecache_range(i, s, e) do { } while (0) +/* + * Additional stubs for dir.c + */ + +/* fscrypt_str - encrypted filename string */ +#define FSTR_INIT(n, l) { .name = (n), .len = (l) } + +/* fscrypt directory operations */ +#define fscrypt_prepare_readdir(i) ({ (void)(i); 0; }) +#define fscrypt_fname_alloc_buffer(len, buf) ({ (void)(len); (void)(buf); 0; }) +#define fscrypt_fname_free_buffer(buf) do { (void)(buf); } while (0) +#define fscrypt_fname_disk_to_usr(i, h1, h2, d, u) ({ (void)(i); (void)(h1); (void)(h2); (void)(d); (void)(u); 0; }) + +/* Readahead operations */ +#define ra_has_index(ra, idx) ({ (void)(ra); (void)(idx); 0; }) +#define page_cache_sync_readahead(m, ra, f, i, n) do { } while (0) + +/* Inode version operations */ +#define inode_eq_iversion(i, v) ({ (void)(i); (void)(v); 1; }) +#define inode_query_iversion(i) ({ (void)(i); 0ULL; }) + +/* Directory context operations */ +#define dir_emit(ctx, name, len, ino, type) ({ (void)(ctx); (void)(name); (void)(len); (void)(ino); (void)(type); 1; }) +#define dir_relax_shared(i) ({ (void)(i); 1; }) + +/* File llseek */ +#define generic_file_llseek_size(f, o, w, m, e) ({ (void)(f); (void)(o); (void)(w); (void)(m); (void)(e); 0LL; }) + +/* generic_read_dir - stub function (needs to be a real function for struct init) */ +ssize_t generic_read_dir(struct file *f, char __user *buf, size_t count, + loff_t *ppos); + +/* struct_size helper */ +#define struct_size(p, member, count) (sizeof(*(p)) + sizeof((p)->member[0]) * (count)) + +/* file_operations - extended for dir.c */ +struct file_operations { + int (*open)(struct inode *, struct file *); + loff_t (*llseek)(struct file *, loff_t, int); + ssize_t (*read)(struct file *, char *, size_t, loff_t *); + int (*iterate_shared)(struct file *, struct dir_context *); + long (*unlocked_ioctl)(struct file *, unsigned int, unsigned long); + int (*fsync)(struct file *, loff_t, loff_t, int); + int (*release)(struct inode *, struct file *); +}; + +/* file open helper */ +#define simple_open(i, f) ({ (void)(i); (void)(f); 0; }) + #endif /* __EXT4_UBOOT_H__ */ diff --git a/fs/ext4l/stub.c b/fs/ext4l/stub.c index 2c9c460f0e7..13d2ce7b54b 100644 --- a/fs/ext4l/stub.c +++ b/fs/ext4l/stub.c @@ -520,7 +520,7 @@ int ext4_find_inline_data_nolock(struct inode *inode) char ext4_file_inode_operations; char ext4_file_operations; char ext4_dir_inode_operations; -char ext4_dir_operations; +/* ext4_dir_operations is now in dir.c */ char ext4_special_inode_operations; char ext4_symlink_inode_operations; char ext4_fast_symlink_inode_operations; @@ -580,3 +580,49 @@ int jbd2_journal_try_to_free_buffers(journal_t *journal, struct folio *folio) void jbd2_journal_init_jbd_inode(void *jinode, struct inode *inode) { } + +/* + * Stubs for dir.c + */ +ssize_t generic_read_dir(struct file *f, char *buf, size_t count, loff_t *ppos) +{ + return -EISDIR; +} + +void __ext4_error_file(struct file *file, const char *func, unsigned int line, + unsigned long long block, const char *fmt, ...) +{ +} + +loff_t ext4_llseek(struct file *file, loff_t offset, int whence) +{ + return 0; +} + +int ext4_htree_fill_tree(struct file *dir_file, unsigned long long pos, + unsigned long long start_hash, + unsigned long long start_minor_hash, + unsigned long long *next_hash) +{ + return 0; +} + +int ext4_read_inline_dir(struct file *file, void *ctx, void *f_pos) +{ + return 0; +} + +int ext4_dirblock_csum_verify(struct inode *inode, struct buffer_head *bh) +{ + return 1; +} + +long ext4_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + return 0; +} + +int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync) +{ + return 0; +} -- 2.43.0