[Concept,04/33] ext4l: Move file_operations and inode_operations to linux/fs.h

Message ID 20260121220857.2137568-5-sjg@u-boot.org
State New
Headers
Series Reorganise ext4l compatibility stubs |

Commit Message

Simon Glass Jan. 21, 2026, 10:08 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Move the file_operations and inode_operations structure definitions
from ext4_uboot.h to include/linux/fs.h where they belong according
to Linux kernel conventions.

Add necessary forward declarations for types used by these structures
(delayed_call, fiemap_extent_info, file_kattr, posix_acl, mnt_idmap,
kstat).

Co-developed-by: Claude (Anthropic)
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 fs/ext4l/ext4_uboot.h | 48 ---------------------------------
 include/linux/fs.h    | 63 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+), 48 deletions(-)
  

Patch

diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h
index 5d62c49663c..fb5c7cc8872 100644
--- a/fs/ext4l/ext4_uboot.h
+++ b/fs/ext4l/ext4_uboot.h
@@ -524,18 +524,6 @@  ssize_t generic_read_dir(struct file *f, char __user *buf, size_t count,
 /* struct_size - use linux/overflow.h */
 #include <linux/overflow.h>
 
-/* 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 *);
-};
-
-/* delayed_call - use linux/delayed_call.h */
 #include <linux/delayed_call.h>
 
 #define kfree_link		kfree
@@ -546,42 +534,6 @@  static inline void nd_terminate_link(void *name, loff_t len, int maxlen)
 	((char *)name)[min_t(loff_t, len, maxlen)] = '\0';
 }
 
-/* inode_operations - for file and directory operations */
-struct inode_operations {
-	/* Symlink operations */
-	const char *(*get_link)(struct dentry *, struct inode *,
-				struct delayed_call *);
-	/* Common operations */
-	int (*getattr)(struct mnt_idmap *, const struct path *,
-		       struct kstat *, u32, unsigned int);
-	ssize_t (*listxattr)(struct dentry *, char *, size_t);
-	int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64, u64);
-	int (*setattr)(struct mnt_idmap *, struct dentry *, struct iattr *);
-	struct posix_acl *(*get_inode_acl)(struct inode *, int, bool);
-	int (*set_acl)(struct mnt_idmap *, struct dentry *,
-		       struct posix_acl *, int);
-	int (*fileattr_get)(struct dentry *, struct file_kattr *);
-	int (*fileattr_set)(struct mnt_idmap *, struct dentry *,
-			    struct file_kattr *);
-	/* Directory operations */
-	struct dentry *(*lookup)(struct inode *, struct dentry *, unsigned int);
-	int (*create)(struct mnt_idmap *, struct inode *, struct dentry *,
-		      umode_t, bool);
-	int (*link)(struct dentry *, struct inode *, struct dentry *);
-	int (*unlink)(struct inode *, struct dentry *);
-	int (*symlink)(struct mnt_idmap *, struct inode *, struct dentry *,
-		       const char *);
-	struct dentry *(*mkdir)(struct mnt_idmap *, struct inode *,
-				struct dentry *, umode_t);
-	int (*rmdir)(struct inode *, struct dentry *);
-	int (*mknod)(struct mnt_idmap *, struct inode *, struct dentry *,
-		     umode_t, dev_t);
-	int (*rename)(struct mnt_idmap *, struct inode *, struct dentry *,
-		      struct inode *, struct dentry *, unsigned int);
-	int (*tmpfile)(struct mnt_idmap *, struct inode *, struct file *,
-		       umode_t);
-};
-
 /* file open helper */
 #define simple_open(i, f)		({ (void)(i); (void)(f); 0; })
 
diff --git a/include/linux/fs.h b/include/linux/fs.h
index aac88e7c68c..3f82a027931 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -402,4 +402,67 @@  struct fstrim_range {
 	u64 minlen;
 };
 
+/* Forward declarations for file/inode operations */
+struct delayed_call;
+struct fiemap_extent_info;
+struct file_kattr;
+struct posix_acl;
+struct mnt_idmap;
+struct kstat;
+
+/**
+ * struct file_operations - filesystem file operations
+ *
+ * Methods for file I/O and directory iteration.
+ */
+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 *);
+};
+
+/**
+ * struct inode_operations - filesystem inode operations
+ *
+ * Methods for inode manipulation, including symlinks and directories.
+ */
+struct inode_operations {
+	/* Symlink operations */
+	const char *(*get_link)(struct dentry *, struct inode *,
+				struct delayed_call *);
+	/* Common operations */
+	int (*getattr)(struct mnt_idmap *, const struct path *,
+		       struct kstat *, u32, unsigned int);
+	ssize_t (*listxattr)(struct dentry *, char *, size_t);
+	int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64, u64);
+	int (*setattr)(struct mnt_idmap *, struct dentry *, struct iattr *);
+	struct posix_acl *(*get_inode_acl)(struct inode *, int, bool);
+	int (*set_acl)(struct mnt_idmap *, struct dentry *,
+		       struct posix_acl *, int);
+	int (*fileattr_get)(struct dentry *, struct file_kattr *);
+	int (*fileattr_set)(struct mnt_idmap *, struct dentry *,
+			    struct file_kattr *);
+	/* Directory operations */
+	struct dentry *(*lookup)(struct inode *, struct dentry *, unsigned int);
+	int (*create)(struct mnt_idmap *, struct inode *, struct dentry *,
+		      umode_t, bool);
+	int (*link)(struct dentry *, struct inode *, struct dentry *);
+	int (*unlink)(struct inode *, struct dentry *);
+	int (*symlink)(struct mnt_idmap *, struct inode *, struct dentry *,
+		       const char *);
+	struct dentry *(*mkdir)(struct mnt_idmap *, struct inode *,
+				struct dentry *, umode_t);
+	int (*rmdir)(struct inode *, struct dentry *);
+	int (*mknod)(struct mnt_idmap *, struct inode *, struct dentry *,
+		     umode_t, dev_t);
+	int (*rename)(struct mnt_idmap *, struct inode *, struct dentry *,
+		      struct inode *, struct dentry *, unsigned int);
+	int (*tmpfile)(struct mnt_idmap *, struct inode *, struct file *,
+		       umode_t);
+};
+
 #endif /* _LINUX_FS_H */