[Concept,06/12] ext4l: Implement super_set_uuid() to display filesystem UUID

Message ID 20251223011632.380026-7-sjg@u-boot.org
State New
Headers
Series ext4l: Add support for listing directoties (Part H) |

Commit Message

Simon Glass Dec. 23, 2025, 1:16 a.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

The super_set_uuid() function was stubbed as a no-op, causing the
filesystem UUID to display as all zeros during mount. Implement it
to copy the UUID from the ext4 superblock to the VFS super_block
structure.

Before: mounted filesystem 00000000-0000-0000-0000-000000000000 r/w
After:  mounted filesystem d4ddb235-df85-4963-a923-7cddc5ad9355 r/w

Add a way to read from tests as well.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 fs/ext4l/ext4_uboot.h | 11 +++++++++--
 fs/ext4l/interface.c  | 13 +++++++++++++
 include/ext4l.h       |  7 +++++++
 3 files changed, 29 insertions(+), 2 deletions(-)
  

Patch

diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h
index 4b7b5d02c82..4b019b77d27 100644
--- a/fs/ext4l/ext4_uboot.h
+++ b/fs/ext4l/ext4_uboot.h
@@ -2324,8 +2324,15 @@  unsigned int bdev_max_discard_sectors(struct block_device *bdev);
 /* Task I/O priority - declaration for stub.c */
 void set_task_ioprio(void *task, int ioprio);
 
-/* Superblock identity stubs */
-#define super_set_uuid(sb, uuid, len)		do { } while (0)
+/* Superblock identity functions */
+static inline void super_set_uuid(struct super_block *sb, const u8 *uuid,
+				  unsigned len)
+{
+	if (len > sizeof(sb->s_uuid.b))
+		len = sizeof(sb->s_uuid.b);
+	memcpy(sb->s_uuid.b, uuid, len);
+}
+
 #define super_set_sysfs_name_bdev(sb)		do { } while (0)
 
 /*
diff --git a/fs/ext4l/interface.c b/fs/ext4l/interface.c
index 7360f44c92b..2ea3915c637 100644
--- a/fs/ext4l/interface.c
+++ b/fs/ext4l/interface.c
@@ -51,6 +51,19 @@  struct disk_partition *ext4l_get_partition(void)
 	return &ext4l_partition;
 }
 
+/**
+ * ext4l_get_uuid() - Get the filesystem UUID
+ * @uuid: Buffer to receive the 16-byte UUID
+ * Return: 0 on success, -ENODEV if not mounted
+ */
+int ext4l_get_uuid(u8 *uuid)
+{
+	if (!ext4l_sb)
+		return -ENODEV;
+	memcpy(uuid, ext4l_sb->s_uuid.b, 16);
+	return 0;
+}
+
 /**
  * ext4l_set_blk_dev() - Set the block device for ext4l operations
  * @blk_dev: Block device descriptor
diff --git a/include/ext4l.h b/include/ext4l.h
index 5a300fd6559..dead8ba8e6f 100644
--- a/include/ext4l.h
+++ b/include/ext4l.h
@@ -28,4 +28,11 @@  int ext4l_probe(struct blk_desc *fs_dev_desc,
  */
 void ext4l_close(void);
 
+/**
+ * ext4l_get_uuid() - Get the filesystem UUID
+ * @uuid: Buffer to receive the 16-byte UUID
+ * Return: 0 on success, -ENODEV if not mounted
+ */
+int ext4l_get_uuid(u8 *uuid);
+
 #endif /* __EXT4L_H__ */