[Concept,15/15] ext4l: Add fsmap.c to the build

Message ID 20251221212028.857348-16-sjg@u-boot.org
State New
Headers
Series ext4l: Add jbd2 and remaining ext4l files to build (part F) |

Commit Message

Simon Glass Dec. 21, 2025, 9:20 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Update fsmap.c to use ext4_uboot.h and add the required stubs:
- struct fsmap and related FMR_* macros
- trace_ext4_fsmap_* stub macros
- list_sort and sort stub macros

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/ext4_uboot.h | 32 ++++++++++++++++++++++++++++++++
 fs/ext4l/fsmap.c      |  5 +----
 3 files changed, 34 insertions(+), 5 deletions(-)
  

Patch

diff --git a/fs/ext4l/Makefile b/fs/ext4l/Makefile
index ee929539eb8..e99b900ca6d 100644
--- a/fs/ext4l/Makefile
+++ b/fs/ext4l/Makefile
@@ -6,7 +6,7 @@ 
 obj-y := interface.o stub.o
 
 obj-y	+= balloc.o bitmap.o block_validity.o dir.o ext4_jbd2.o extents.o \
-		extents_status.o file.o fsync.o hash.o ialloc.o \
+		extents_status.o file.o fsmap.o fsync.o hash.o ialloc.o \
 		indirect.o inline.o inode.o mballoc.o migrate.o \
 		mmp.o move_extent.o namei.o page-io.o readpage.o resize.o \
 		super.o symlink.o xattr.o \
diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h
index 8a3143a6d27..1ad9ad7f47a 100644
--- a/fs/ext4l/ext4_uboot.h
+++ b/fs/ext4l/ext4_uboot.h
@@ -2988,4 +2988,36 @@  static inline u64 div64_u64(u64 dividend, u64 divisor)
 /* ext4_update_overhead - declaration for stub.c */
 int ext4_update_overhead(struct super_block *sb, bool force);
 
+/*
+ * Stubs for fsmap.c
+ */
+
+/* fsmap.c stubs - struct fsmap from linux/fsmap.h */
+struct fsmap {
+	__u32	fmr_device;	/* device id */
+	__u32	fmr_flags;	/* mapping flags */
+	__u64	fmr_physical;	/* device offset of segment */
+	__u64	fmr_owner;	/* owner id */
+	__u64	fmr_offset;	/* file offset of segment */
+	__u64	fmr_length;	/* length of segment */
+	__u64	fmr_reserved[3]; /* must be zero */
+};
+
+#define FMR_OWN_FREE		(-1ULL)
+#define FMR_OWN_UNKNOWN		(-2ULL)
+#define FMR_OWNER(type, code)	(((__u64)(type) << 32) | (__u64)(code))
+#define FMR_OF_SPECIAL_OWNER	(1 << 0)
+#define FMH_IF_VALID		0
+#define FMH_OF_DEV_T		(1 << 0)
+
+#define trace_ext4_fsmap_mapping(sb, d, a, p, l, o)	do { } while (0)
+#define trace_ext4_fsmap_low_key(sb, d, a, p, l, o)	do { } while (0)
+#define trace_ext4_fsmap_high_key(sb, d, a, p, l, o)	do { } while (0)
+
+/* list_sort and sort stubs for fsmap.c */
+#define list_sort(priv, head, cmp) \
+	do { (void)(priv); (void)(head); (void)(cmp); } while (0)
+#define sort(base, num, size, cmp, swap) \
+	do { (void)(base); (void)(num); (void)(size); (void)(cmp); (void)(swap); } while (0)
+
 #endif /* __EXT4_UBOOT_H__ */
diff --git a/fs/ext4l/fsmap.c b/fs/ext4l/fsmap.c
index 22fc333244e..da9ee2fac8e 100644
--- a/fs/ext4l/fsmap.c
+++ b/fs/ext4l/fsmap.c
@@ -4,13 +4,10 @@ 
  *
  * Author: Darrick J. Wong <darrick.wong@oracle.com>
  */
+#include "ext4_uboot.h"
 #include "ext4.h"
-#include <linux/fsmap.h>
 #include "fsmap.h"
 #include "mballoc.h"
-#include <linux/sort.h>
-#include <linux/list_sort.h>
-#include <trace/events/ext4.h>
 
 /* Convert an ext4_fsmap to an fsmap. */
 void ext4_fsmap_from_internal(struct super_block *sb, struct fsmap *dest,