From patchwork Sat Dec 27 20:43:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1090 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868286; bh=yDwKcjUS7qCNJI8hfH2gIk72EADpA+vDrEW0TG8wPM8=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=kA1+oQovP9oV8V6d3kCAWhS/cdO6DRcKPeH/PYi5N9ozsv9BnaoH5aDo8lCYykXXS vMR6Ghf0U5oGAqoxRqccHcq58chcNBcKggpzN09uvlmxPXI0wM1DbYGGe0tDbp4Hak Nn89W8ydKfV77QTPmR2SFb17ETj285sW/CT4CG8zHzTWRI3ANSpZ2U3FQ2TdGKrCk3 6ZzJh12e0KacgYT5RFFN9Z26vSRng+6hAXlMpPWpDXMsF0i9fH3PjpdVJswveKKMSd SNGBR5NqQNyHRnWFwabESOBvhymiKnB09oe5ou53+2XqqIW5XDc7rr7t81QkDNSyGU 7vxeFl3UuegyQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 68D8164E44 for ; Sat, 27 Dec 2025 13:44:46 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 4_8YOsVfOPoZ for ; Sat, 27 Dec 2025 13:44:46 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868286; bh=yDwKcjUS7qCNJI8hfH2gIk72EADpA+vDrEW0TG8wPM8=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=kA1+oQovP9oV8V6d3kCAWhS/cdO6DRcKPeH/PYi5N9ozsv9BnaoH5aDo8lCYykXXS vMR6Ghf0U5oGAqoxRqccHcq58chcNBcKggpzN09uvlmxPXI0wM1DbYGGe0tDbp4Hak Nn89W8ydKfV77QTPmR2SFb17ETj285sW/CT4CG8zHzTWRI3ANSpZ2U3FQ2TdGKrCk3 6ZzJh12e0KacgYT5RFFN9Z26vSRng+6hAXlMpPWpDXMsF0i9fH3PjpdVJswveKKMSd SNGBR5NqQNyHRnWFwabESOBvhymiKnB09oe5ou53+2XqqIW5XDc7rr7t81QkDNSyGU 7vxeFl3UuegyQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 58FAE64E49 for ; Sat, 27 Dec 2025 13:44:46 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868284; bh=WiOV5NIodXa8NZ2O5cCyf8ZsGwKyrPKCVWb6D5x5C3U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=frFIxl9LTvt2F6LGkBELNxJ7F2xu5ebr+x/X73NzLwX9+w7WcC1tVRKP7rjcUJJ6l bLZ8pCGMFAIrCKs6jyXkKkundSoIHJDbQ0ATf9VC+XMQVt2ROhxbliwoQtziIdOj/o 9aHWiw2Y3yfHpttzd1MFKOyLSN+J440HWJjN9APHBBDan1pZ/UiR31yITboNeIBlTy +qyUlspjjqSn5Lth5IjAB275F/XwHIKlFRaLVZSvfOEoZFFapalrWruXep8IXWadCv Dqu4MDZN+4S6cA1GfIu4fpMOBMqRtKCJvuAaJN8+9RWR16jvavRg9kW0dHjV1X9GWg coP+00eQYxfrg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E3C4A64E1F; Sat, 27 Dec 2025 13:44:44 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id JLcfWf3WYgza; Sat, 27 Dec 2025 13:44:44 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868280; bh=OlR2JPyMJuHsZIOWpoJNXf6Ro6eQx2QZtoyprISBNhU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pWeQGC5A5QPwwfIZwLVcrbE/bG2YT0My8ItJT1ZsvihFJoqRu32BobYFdVxizGabj mSPOoShuN0P4Uh0LTZE0F/WxsxUFPSvLoTlX56Qc4o3He+XY4GFfbwuGNF4QL5RvaA ygjXePvPQyPqIdMiZ1u4Ms7hja+0bMTipDJj7Kfo/nWrL1n1Fd+1IhQLPsdD+muUH9 cumjgbHBMLWzsESdHcbeIYcC65DioqWOIcXVsBatud6/qI4rGEIgXtxgBkg8kHGUFT N3UOuvLCRbKwefTA7lD+uNRnJwoOzAh9vQNDXXXYdjigZhnFX3iUCeFGGjWfTkayGy OB0ZR3YOvhnyQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6EB6D64C0C; Sat, 27 Dec 2025 13:44:40 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 27 Dec 2025 13:43:08 -0700 Message-ID: <20251227204318.886983-14-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251227204318.886983-1-sjg@u-boot.org> References: <20251227204318.886983-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: PQBWCKQYYQG3IOCTIWIREF2F5MHAO5SF X-Message-ID-Hash: PQBWCKQYYQG3IOCTIWIREF2F5MHAO5SF X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 13/16] ext4l: Add uuid() support List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass The filesystem uuid method is not implemented. Add ext4l_uuid() which returns the filesystem UUID as a string and wire it into the filesystem operations table. Add a test. Co-developed-by: Claude Signed-off-by: Simon Glass --- fs/ext4l/interface.c | 20 ++++++++++++++++++ fs/fs_legacy.c | 2 +- include/ext4l.h | 8 ++++++++ test/fs/ext4l.c | 32 +++++++++++++++++++++++++++++ test/py/tests/test_fs/test_ext4l.py | 7 +++++++ 5 files changed, 68 insertions(+), 1 deletion(-) diff --git a/fs/ext4l/interface.c b/fs/ext4l/interface.c index 34e659cd28b..f25664369e6 100644 --- a/fs/ext4l/interface.c +++ b/fs/ext4l/interface.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -80,6 +81,25 @@ int ext4l_get_uuid(u8 *uuid) return 0; } +/** + * ext4l_uuid() - Get the filesystem UUID as a string + * + * @uuid_str: Buffer to receive the UUID string (must be at least 37 bytes) + * Return: 0 on success, -ENODEV if not mounted + */ +int ext4l_uuid(char *uuid_str) +{ + u8 uuid[16]; + int ret; + + ret = ext4l_get_uuid(uuid); + if (ret) + return ret; + uuid_bin_to_str(uuid, uuid_str, UUID_STR_FORMAT_STD); + + return 0; +} + /** * ext4l_set_blk_dev() - Set the block device for ext4l operations * diff --git a/fs/fs_legacy.c b/fs/fs_legacy.c index 27a2d7be220..71f8e56715f 100644 --- a/fs/fs_legacy.c +++ b/fs/fs_legacy.c @@ -270,7 +270,7 @@ static struct fstype_info fstypes[] = { .size = ext4l_size, .read = ext4l_read, .write = fs_write_unsupported, - .uuid = fs_uuid_unsupported, + .uuid = ext4l_uuid, .opendir = ext4l_opendir, .readdir = ext4l_readdir, .closedir = ext4l_closedir, diff --git a/include/ext4l.h b/include/ext4l.h index 643060ee44c..9d9e79b7695 100644 --- a/include/ext4l.h +++ b/include/ext4l.h @@ -76,6 +76,14 @@ int ext4l_read(const char *filename, void *buf, loff_t offset, loff_t len, */ int ext4l_get_uuid(u8 *uuid); +/** + * ext4l_uuid() - Get the filesystem UUID as a string + * + * @uuid_str: Buffer to receive the UUID string (must be at least 37 bytes) + * Return: 0 on success, -ENODEV if not mounted + */ +int ext4l_uuid(char *uuid_str); + /** * ext4l_opendir() - Open a directory for iteration * diff --git a/test/fs/ext4l.c b/test/fs/ext4l.c index 1bea9186d5a..02ad13ec71d 100644 --- a/test/fs/ext4l.c +++ b/test/fs/ext4l.c @@ -295,3 +295,35 @@ static int fs_test_ext4l_read_norun(struct unit_test_state *uts) } FS_TEST_ARGS(fs_test_ext4l_read_norun, UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL, { "fs_image", UT_ARG_STR }); + +/** + * fs_test_ext4l_uuid_norun() - Test ext4l_uuid function + * + * Verifies that ext4l can return the filesystem UUID. + * + * Arguments: + * fs_image: Path to the ext4 filesystem image + */ +static int fs_test_ext4l_uuid_norun(struct unit_test_state *uts) +{ + const char *fs_image = ut_str(EXT4L_ARG_IMAGE); + char uuid_str[UUID_STR_LEN + 1]; + + ut_assertnonnull(fs_image); + ut_assertok(run_commandf("host bind 0 %s", fs_image)); + ut_assertok(fs_set_blk_dev("host", "0", FS_TYPE_ANY)); + + /* Get the UUID string */ + ut_assertok(ext4l_uuid(uuid_str)); + + /* Verify it's a valid UUID format (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) */ + ut_asserteq(UUID_STR_LEN, strlen(uuid_str)); + ut_asserteq('-', uuid_str[8]); + ut_asserteq('-', uuid_str[13]); + ut_asserteq('-', uuid_str[18]); + ut_asserteq('-', uuid_str[23]); + + return 0; +} +FS_TEST_ARGS(fs_test_ext4l_uuid_norun, UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL, + { "fs_image", UT_ARG_STR }); diff --git a/test/py/tests/test_fs/test_ext4l.py b/test/py/tests/test_fs/test_ext4l.py index 4064a6c53ff..2bbbe766e6a 100644 --- a/test/py/tests/test_fs/test_ext4l.py +++ b/test/py/tests/test_fs/test_ext4l.py @@ -117,3 +117,10 @@ class TestExt4l: output = ubman.run_command( f'ut -f fs fs_test_ext4l_read_norun fs_image={ext4_image}') assert 'failures: 0' in output + + def test_uuid(self, ubman, ext4_image): + """Test that ext4l can return the filesystem UUID.""" + with ubman.log.section('Test ext4l uuid'): + output = ubman.run_command( + f'ut -f fs fs_test_ext4l_uuid_norun fs_image={ext4_image}') + assert 'failures: 0' in output