[Concept,02/16] ext4l: Add linux/fs/super_types.h for struct super_block
Commit Message
From: Simon Glass <simon.glass@canonical.com>
Create include/linux/fs/super_types.h with the struct super_block
definition and sb_rdonly() helper, matching the Linux kernel location.
This allows other headers like linux/fs.h to access the full struct
definition rather than just a forward declaration.
Remove the duplicate definitions from ext4_uboot.h.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---
fs/ext4l/ext4_uboot.h | 41 ++------------------
include/linux/fs.h | 2 +-
include/linux/fs/super_types.h | 68 ++++++++++++++++++++++++++++++++++
3 files changed, 72 insertions(+), 39 deletions(-)
create mode 100644 include/linux/fs/super_types.h
@@ -194,8 +194,7 @@ extern struct user_namespace init_user_ns;
/* might_sleep - stub */
#define might_sleep() do { } while (0)
-/* sb_rdonly - check if filesystem is mounted read-only */
-#define sb_rdonly(sb) ((sb)->s_flags & SB_RDONLY)
+/* sb_rdonly is in linux/super.h */
/* Trace stubs are now in ext4_trace.h */
@@ -328,10 +327,7 @@ void iput(struct inode *inode);
/* SB_FREEZE_* constants are in linux/fs.h */
-/* sb_writers stub */
-struct sb_writers {
- int frozen;
-};
+/* sb_writers is in linux/super.h */
/* mapping_large_folio_support is in linux/pagemap.h */
@@ -424,38 +420,7 @@ struct fstrim_range {
/* uuid_t is now in linux/uuid.h */
-/* Forward declarations for super_block */
-struct super_operations;
-struct export_operations;
-struct xattr_handler;
-
-/* super_block - minimal stub */
-struct super_block {
- void *s_fs_info;
- unsigned long s_blocksize;
- unsigned char s_blocksize_bits;
- unsigned long s_magic;
- loff_t s_maxbytes;
- unsigned long s_flags;
- unsigned long s_iflags; /* Internal flags */
- struct rw_semaphore s_umount;
- struct sb_writers s_writers;
- struct block_device *s_bdev;
- char s_id[32];
- struct dentry *s_root;
- uuid_t s_uuid;
- struct file_system_type *s_type;
- s32 s_time_gran; /* Time granularity (ns) */
- time64_t s_time_min; /* Min supported time */
- time64_t s_time_max; /* Max supported time */
- const struct super_operations *s_op;
- const struct export_operations *s_export_op;
- const struct xattr_handler * const *s_xattr;
- struct dentry *d_sb; /* Parent dentry - stub */
-
- /* U-Boot: list of all inodes, for freeing on unmount */
- struct list_head s_inodes;
-};
+/* super_block is now in linux/super.h */
/* Block device read-only check */
static inline int bdev_read_only(struct block_device *bdev)
@@ -10,10 +10,10 @@
#include <linux/types.h>
#include <linux/list.h>
#include <linux/mutex.h>
+#include <linux/fs/super_types.h>
/* Forward declarations */
struct inode;
-struct super_block;
struct buffer_head;
struct file;
struct folio;
new file mode 100644
@@ -0,0 +1,68 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Superblock definitions
+ *
+ * Minimal version for U-Boot - based on Linux
+ */
+#ifndef _LINUX_FS_SUPER_TYPES_H
+#define _LINUX_FS_SUPER_TYPES_H
+
+#include <linux/list.h>
+#include <linux/rwsem.h>
+#include <linux/time.h>
+#include <linux/types.h>
+#include <linux/uuid.h>
+
+/* Forward declarations */
+struct block_device;
+struct dentry;
+struct file_system_type;
+struct super_operations;
+struct export_operations;
+struct xattr_handler;
+
+/* sb_writers stub */
+struct sb_writers {
+ int frozen;
+};
+
+/* super_block - filesystem superblock */
+struct super_block {
+ void *s_fs_info;
+ unsigned long s_blocksize;
+ unsigned char s_blocksize_bits;
+ unsigned long s_magic;
+ loff_t s_maxbytes;
+ unsigned long s_flags;
+ unsigned long s_iflags; /* Internal flags */
+ struct rw_semaphore s_umount;
+ struct sb_writers s_writers;
+ struct block_device *s_bdev;
+ char s_id[32];
+ struct dentry *s_root;
+ uuid_t s_uuid;
+ struct file_system_type *s_type;
+ s32 s_time_gran; /* Time granularity (ns) */
+ time64_t s_time_min; /* Min supported time */
+ time64_t s_time_max; /* Max supported time */
+ const struct super_operations *s_op;
+ const struct export_operations *s_export_op;
+ const struct xattr_handler * const *s_xattr;
+ struct dentry *d_sb; /* Parent dentry - stub */
+
+ /* U-Boot: list of all inodes, for freeing on unmount */
+ struct list_head s_inodes;
+};
+
+/* Superblock flags - also defined in linux/fs.h */
+#ifndef SB_RDONLY
+#define SB_RDONLY (1 << 0) /* Read-only mount */
+#endif
+
+/* sb_rdonly - check if filesystem is mounted read-only */
+static inline bool sb_rdonly(const struct super_block *sb)
+{
+ return sb->s_flags & SB_RDONLY;
+}
+
+#endif /* _LINUX_FS_SUPER_TYPES_H */