From patchwork Sat Dec 27 20:42:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1078 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=1766868237; bh=1IVHl1Un7YZarr/1Au+OaueNSso9sZAhklG7C2ypIPA=; 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=EF4/meCbr9w14ru6+OtIyZL5/IDDRQyFt8axV2IJIGlikdsGtWWzLvq0app00l70R LK9gL4dPWx7Dx8z3x8R5fEsJOMgM3FWPi+SOQh/W9qbyVNLOC8llnNgCjHD9MAw+F5 dcD/FXdWC0mR7I2Xme8OvrnGhKSEat3Ew8ynywPIJj5MpTxLGg4qsb69fHHtwTq3dM k9noEJJZ6QPhiplWu+cI4yqc+dIdwE2nAmzYOy8fQAhkDv4yuz6JJWM5a7bSsbjv8V A/3cs6tA80dWSHxhYQq708963UG4KJuQLb5O066FJprCRORH1Gy5Z1cMWWiaijsWbY K7cT87fVhGw3A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DC5EA65079 for ; Sat, 27 Dec 2025 13:43:57 -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 JojsY69nXqiC for ; Sat, 27 Dec 2025 13:43:57 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868237; bh=1IVHl1Un7YZarr/1Au+OaueNSso9sZAhklG7C2ypIPA=; 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=EF4/meCbr9w14ru6+OtIyZL5/IDDRQyFt8axV2IJIGlikdsGtWWzLvq0app00l70R LK9gL4dPWx7Dx8z3x8R5fEsJOMgM3FWPi+SOQh/W9qbyVNLOC8llnNgCjHD9MAw+F5 dcD/FXdWC0mR7I2Xme8OvrnGhKSEat3Ew8ynywPIJj5MpTxLGg4qsb69fHHtwTq3dM k9noEJJZ6QPhiplWu+cI4yqc+dIdwE2nAmzYOy8fQAhkDv4yuz6JJWM5a7bSsbjv8V A/3cs6tA80dWSHxhYQq708963UG4KJuQLb5O066FJprCRORH1Gy5Z1cMWWiaijsWbY K7cT87fVhGw3A== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CB74064E47 for ; Sat, 27 Dec 2025 13:43:57 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868235; bh=vQhLSH9ZSKC+o8Zo9sqJPnzuFxfDmFnu3TL69KcKpH8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=im7KZ2UYw+LoM+cvxJSf2UJM/HH+U8bhHeXcIQvEIm5d4dCmuMqrdeDNYF+sui+KO Jm+FyOJrQAo03sN2JkXeFX8Wj+xEo8gOiIhX2K7a1APbRZfAoaIwpGpndPyHBagSra BTowCILntH+q8OSMK6X9g1ID/JxDpVvY/GwicM2ZiWx23Lc4CLtxr9+tJqG7PQtYkt kYCwmyZoG5YvpTvq+DT+QoIcYOiogNvhoAiwLs477Ys6p2J9FgodMi8D9tKK+Bul5R va+anbCs4G8/CCsqjd5Kmx9fcRHXEijJneLVhkwTHMTejeiB79v1wWqBJYWGzV/Zfu EY0uCTeUo761g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 45FE464E44; Sat, 27 Dec 2025 13:43:55 -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 galM2HmmhrAk; Sat, 27 Dec 2025 13:43:55 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868231; bh=Rglfj0TbIc0H+pvzsJR9WbYy3AG/3+dOWLZzqIz2MZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fKtn4WMo1m0B9Hhaa5u2wbJpvTe3zlwSfhtptZSH+cg0YvbhPGSVJ/B8RyjTPn+xF G+B9UFCp9dQyDI5C6dWfuWu6QHvNTOgaXfYuVpT7Xue6R+TN4B8T6tOGeGIHKs8aIx uyAmdKyn2m8b3Cp6zLmxSn1mEW+3wfSOdnhjY1P2Sqi2MAodFKNaQBL0dmty1KTVCN PUt6Qonnsnb2sw4cvSZyq7pRwHabXCEjmGWHaXy6XF4nEhf9S8ZqblN1ozl7u6W69e +bTxylmIs/7eP4SLLRPJXWhqFamaZy1gLYneSucOr/6M/SyzVauApoKAEjX2nqYtNd 1miPJVHU2CY1A== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 265AF64C0C; Sat, 27 Dec 2025 13:43:51 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 27 Dec 2025 13:42:56 -0700 Message-ID: <20251227204318.886983-2-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: FA3NWZSE44AITZLNMTJY333AID4BPCQH X-Message-ID-Hash: FA3NWZSE44AITZLNMTJY333AID4BPCQH 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 Opus 4 . 5" , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 01/16] CLAUDE.md: Add note about test-declaration placement 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 Test declarations should immediately follow the closing brace of the function they declare, with no blank line in between. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- CLAUDE.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CLAUDE.md b/CLAUDE.md index ca0571ecef8..b2590b17fab 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -72,3 +72,5 @@ pyt - Keep commit messages concise - focus on the key change and essential details only - Code should be formatted to 80 columns and not have trailing spaces - Remember to use Co-developed-by instead of Co-Authored-By in commits +- Test declarations (e.g., UNIT_TEST macro) should immediately follow the + closing } of the function they declare, with no blank line in between From patchwork Sat Dec 27 20:42:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1079 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=1766868242; bh=CSKfkumU5GAN0N9vNCkFaVrYfeikNoi+k5SavLLZyX8=; 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=CxMXTa77TtvcccclA2ZJMXSuOI59dcDQtMDOO6wMhWkUhFZupEQmRrFePlyS4Khmo XxEVfAnw9BVo6OhiaqQpUMKzaUvbJDqrOhlYUbMnBfqk3jcwsCqr7agbFFGivUdr9s lApOLRbbIjG2ch71YT2IEs433uQ8yn5IdT1EMg9v/3HRL3y2FqG+43uVMuqhj6yZyd lMDrpBlSvPHY7FocKkyC9X2euUJDBMG6Vj5TmyaZYlDnerwQFYj3m6WrfMpQm4u96S yZLQJiyeBFae2tOV2w32CkwnBmB1KyvT40FJBE/p46fFCTHfOOou4FS3urAtdtjzkA YgE+dIZbtg99w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5BD6B64C0C for ; Sat, 27 Dec 2025 13:44:02 -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 ONs4KifuGNTK for ; Sat, 27 Dec 2025 13:44:02 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868242; bh=CSKfkumU5GAN0N9vNCkFaVrYfeikNoi+k5SavLLZyX8=; 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=CxMXTa77TtvcccclA2ZJMXSuOI59dcDQtMDOO6wMhWkUhFZupEQmRrFePlyS4Khmo XxEVfAnw9BVo6OhiaqQpUMKzaUvbJDqrOhlYUbMnBfqk3jcwsCqr7agbFFGivUdr9s lApOLRbbIjG2ch71YT2IEs433uQ8yn5IdT1EMg9v/3HRL3y2FqG+43uVMuqhj6yZyd lMDrpBlSvPHY7FocKkyC9X2euUJDBMG6Vj5TmyaZYlDnerwQFYj3m6WrfMpQm4u96S yZLQJiyeBFae2tOV2w32CkwnBmB1KyvT40FJBE/p46fFCTHfOOou4FS3urAtdtjzkA YgE+dIZbtg99w== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4B7CF64E47 for ; Sat, 27 Dec 2025 13:44:02 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868240; bh=/1AXbtZX4LeOvb/nB7PtUlTrV0CipWITErPt4m3/AP0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jkHa2c+CLPlv83z98S2sFfQ7FO8xAG1BsfUd77+3BHWcI6cT7zABK7QB9wZ+AL1tW Hp7r9G6kUMwzL3IsSoyseA4RVGRCaaN58IsvPIriUQ4mCcAPgdbZ68FGY7qW8Ai2GY 9ABT2BfIKANUVoq1MnavpEyUQ6T6r5DXpU2s+xmAsopVVOOyKECD045xkz4a1zs+1r URgNnGXXWgk9sGEJk5I9HxIZ7Pjm8ghAOshuv2zlvEAO1P0974sNJseKGVAOeT1g+r oCdFGg0LOS98FCwGrq7Ud6mhl98rSfYa9a1eGhHLbesNvScwK9MCDywfpyf92sc3hT go0ijLL15TU9A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4F13264E42; Sat, 27 Dec 2025 13:44:00 -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 wtJDrAcAxvTL; Sat, 27 Dec 2025 13:44:00 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868235; bh=Rm1Ws/WiDQqaNzlgCWQbbZOwNQkC/Y+ShOveJ+ga6Hg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=spu0HYegDpX7DzXljfsY91gUZ6yxFFhFhLzP1xI6ZoWkbmRKfelL/nvXCBdy3nRFS 44gq3PALs2qzIurNlCnBeH62Thg2qlnJMhNy7sw/SZF2SoSDP5v1sbgk4NeYKL+VyI 6nYZZiPFOsZ3ZCS4R0gNx3xk/Nm6PIyXw5qFsMbGTd2MafsU654bOXEWbDmgNYUeCW j9HAUyJ9S7hDCQ3LQT8gNbDtIbb+Wk7TYhg93j6nIEwaTKf8xUOG+2ihKQK4h7Tc+I YTTr6i90ThRDbuGyYrf3wufkG8jsYSvkH8HXguJC052jtNYdc589W+yOnfcVj0QlzM ow8tVvM3U/9YA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 8D4E264C0C; Sat, 27 Dec 2025 13:43:55 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 27 Dec 2025 13:42:57 -0700 Message-ID: <20251227204318.886983-3-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: DFF5R6YZNBEBUPVHTQGAVMWHWPMC6FY3 X-Message-ID-Hash: DFF5R6YZNBEBUPVHTQGAVMWHWPMC6FY3 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 Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 02/16] buildman: Fix flaky test_kconfig_change test properly 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 previous fix using -T4 is insufficient because queue-based job distribution does not guarantee one board per thread. Even with 4 threads and 4 boards, a faster thread can finish its board and grab another from the queue, causing .config to leak between boards in the same thread's work directory. Fix by using -P (per-board-out-dir) which gives each board its own output directory, completely preventing .config leakage regardless of thread scheduling. Fixes: 17618b597508 ("buildman: Fix flaky test_kconfig_change test") Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- tools/buildman/func_test.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/buildman/func_test.py b/tools/buildman/func_test.py index 31cff04a060..6167ea525e7 100644 --- a/tools/buildman/func_test.py +++ b/tools/buildman/func_test.py @@ -1285,13 +1285,13 @@ something: me config_exists[0] = True return exists - # Run buildman with kconfig checking enabled. Use -T4 to ensure each - # board gets its own thread, avoiding .config leaking between boards - # when a thread processes multiple boards (which happens with <4 CPUs) + # Run buildman with kconfig checking enabled. Use -P to give each + # board its own output directory, preventing .config from leaking + # between boards when a thread processes multiple boards sequentially. with mock.patch.object(builderthread, 'kconfig_changed_since', mock_kconfig_changed): self._RunControl('-b', TEST_BRANCH, '-c2', '-o', self._output_dir, - '-T4') + '-P') # Verify kconfig_changed_since was called self.assertGreater(call_count[0], 0) From patchwork Sat Dec 27 20:42:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1080 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=1766868246; bh=0zZCgKzX/mgcSnNy9NoHn8cMWxO2oWXWdOAFCXS8hSg=; 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=lXbRjlI2TZlwlKUB/Ta4FFGFZ1hvPhKKu+yanza0itCHaqorFObXVoKbXfGI90LoP wTTMOD4XYCnVyR3hW7a3TzvQd8K5cGvpTz/Cm/0VU6ujLGYKzW4xFJy6fqn0IdRfK6 f1kqbGTAp0+5GUyXnzE8wq7GN32QzmP5a7fu2bs5rn5/bFUCo5RbxBFkQlUtPVBY7R ZBS6OEsK2bIfeesUE6pTK6zOxNkLE8YIUJHMGx+BAZnSeYBn1UIVKBfuEe2926sri4 9ppMuD+4pUcHHhOwxnYMFZaO/qqp9AlChL4PpmAtwuPrL9QW11zNkfa+eSxcmTFgAo PzU8RvLSP60SQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3955464E47 for ; Sat, 27 Dec 2025 13:44:06 -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 tKZKQwVeFMgg for ; Sat, 27 Dec 2025 13:44:06 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868246; bh=0zZCgKzX/mgcSnNy9NoHn8cMWxO2oWXWdOAFCXS8hSg=; 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=lXbRjlI2TZlwlKUB/Ta4FFGFZ1hvPhKKu+yanza0itCHaqorFObXVoKbXfGI90LoP wTTMOD4XYCnVyR3hW7a3TzvQd8K5cGvpTz/Cm/0VU6ujLGYKzW4xFJy6fqn0IdRfK6 f1kqbGTAp0+5GUyXnzE8wq7GN32QzmP5a7fu2bs5rn5/bFUCo5RbxBFkQlUtPVBY7R ZBS6OEsK2bIfeesUE6pTK6zOxNkLE8YIUJHMGx+BAZnSeYBn1UIVKBfuEe2926sri4 9ppMuD+4pUcHHhOwxnYMFZaO/qqp9AlChL4PpmAtwuPrL9QW11zNkfa+eSxcmTFgAo PzU8RvLSP60SQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 215BF65079 for ; Sat, 27 Dec 2025 13:44:06 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868244; bh=9cCgVzsvi1W4VWGDOnks9FRzqb1P3l80dSTEkrlFJ0M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ss1CAQ0ZIo2oLBIT19699vxLz/lN/iumVuxXquguI+SXu4kDQuz9HM3YNJxdu2Iiy xwh5A2UtohaysGZnWa/la/h0q/3D3h+kpeyPE8tfTnu4DUG1C5bAMwnS83RwSRC0/h W2+A1fwUkhbnC/9WQ5Y2bcuXf9vfnEA5uGyg8AMwaZLT38jYVXA7EnMHh2YZYg/ZWy HmpqUvl+MqIGWiW5DQu4X9YOnYjlyjuaHUAh8OA4Zd00Un6eB1uGPCa633X9EPn9bq tXE2F9dGeciDV5JwIMjxb5BoeilXnAWhrfYxD97alcxAp8MvdEpygHFbal0OWIkug+ +0bG1gldYOyVA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B6CBA64E42; Sat, 27 Dec 2025 13:44:04 -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 QpwiZoDRWORg; Sat, 27 Dec 2025 13:44:04 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868240; bh=zUeTMZ6lLecDbqStPVHUvY8Nk5D8+MAnWrKw2JIW9fA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TLaxmI94tSMGTB3ZefPX6v1Ls6AQMba9zm8uCJvzbPrBmT/jTbURN6n0Fd6/oAj4X 0MPuaYSo/WlEuHCWp9X7ZVw9k4J1Rjvy8BAmAo6Q5xVNG2qtjZtHFaTzYC95hIXJ9s EmvBV1ho9pAsCAe+rgztz5JopYjLDPVmZEQcW1jGY+9C6vgIqIdMigtv48FPxcujvo yFEnYnI7S9sCh4gYqM0hxg24FuDlEqu99AfgcrSxvwoHydgZ5utC6gnFj+X9PV8iyW AjuBqp0WMO+iJ/13NLyAESH1k5gGhanLf31SGEAGR0794UCfGC/oD9wie/Tw+9Ej8z C815MZ+dFQuGA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 3D31464E1F; Sat, 27 Dec 2025 13:44:00 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 27 Dec 2025 13:42:58 -0700 Message-ID: <20251227204318.886983-4-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: QGIUIEWNT3J6RA7PHGIMAOK5DE5BDLVZ X-Message-ID-Hash: QGIUIEWNT3J6RA7PHGIMAOK5DE5BDLVZ 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 Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 03/16] linux: buffer_head: Include atomic.h directly 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 comment about atomic_t being expected from the including file is outdated. Include asm-generic/atomic.h directly to provide the atomic_t type definition. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- include/linux/buffer_head.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index 0f8f5b6caf1..5fbcc757c80 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -12,10 +12,7 @@ #include #include #include -/* - * Note: atomic_t and sector_t are expected to be defined by the including - * file (ext4_uboot.h) before including this header. - */ +#include enum bh_state_bits { BH_Uptodate, /* Contains valid data */ From patchwork Sat Dec 27 20:42:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1081 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=1766868251; bh=kVHKJnSh6QXLzQzo0Td85fUBx4tUxl0qBEkDZktYkbw=; 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=Czkb2oPItbeCwu5QoSSVa0+f4UIxaiqj2J/1YfxLYP9nmiibxSAZctXCpncseRv3+ fkBjrMK6atsy7GL6NOJp98LgEBzfWQWNw7NIMaPjs6vGEz4Id7xoOGuH+mgtICgCjh CWOkWkcVUPmprep8LBPrVXNJEZ/63rN2+Nal4wHWDC+iuYnVe13Tpz9CbHVlnAkqfG cUzEiO5lnlrun4ZXc1cgU2X+tM+dzGZhpxy+jKbAcKLUX3u2eZxNv84P43RuvslULv EXIhNfwRxoeE8MD66TIBDbLUCxPKbL0vIIq/obUlqL+FeN+950L3bjbAI3spR4uVEq UeorE/4Nk0oaA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 93AD665079 for ; Sat, 27 Dec 2025 13:44:11 -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 Asdez1j1Gh_B for ; Sat, 27 Dec 2025 13:44:11 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868251; bh=kVHKJnSh6QXLzQzo0Td85fUBx4tUxl0qBEkDZktYkbw=; 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=Czkb2oPItbeCwu5QoSSVa0+f4UIxaiqj2J/1YfxLYP9nmiibxSAZctXCpncseRv3+ fkBjrMK6atsy7GL6NOJp98LgEBzfWQWNw7NIMaPjs6vGEz4Id7xoOGuH+mgtICgCjh CWOkWkcVUPmprep8LBPrVXNJEZ/63rN2+Nal4wHWDC+iuYnVe13Tpz9CbHVlnAkqfG cUzEiO5lnlrun4ZXc1cgU2X+tM+dzGZhpxy+jKbAcKLUX3u2eZxNv84P43RuvslULv EXIhNfwRxoeE8MD66TIBDbLUCxPKbL0vIIq/obUlqL+FeN+950L3bjbAI3spR4uVEq UeorE/4Nk0oaA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8331064E49 for ; Sat, 27 Dec 2025 13:44:11 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868249; bh=58jTiyUotq5hVyAiQ5JbXRTr8i4799TZVMtAS6VvtTA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gfZbEGX1BK+i5mPXucifJzAgv11TVloozeJQZSCZSunUOAJ2l04oxPK52S7Z3/xs4 G2E5yxClusJJ4oBXnbAgKRNw/hLFMYdrmNEuGuM/XdxUOw70/vYvksSrCuqglPjSuS eCgRNnAZV3iKDFqSVlZrETLbFc2OizUn4BJnA2iG5RC1zIPGmhNZWgulfwindn45g4 a+85WVNM36El/hgn582t9mTWJC1UFFbmkYsNu7ECXcxk/7RmENJYB94KyN4yQWBE4z tvpCn3/YgKwP0udh6lY76TMQ60Eii4f0VdgykIET2ffdBho4Dr2Bkymuw0el/XdC2N ho4nOzSKpuHBg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4C48964E44; Sat, 27 Dec 2025 13:44:09 -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 S_Rlritl9Xdt; Sat, 27 Dec 2025 13:44:09 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868245; bh=4xps/UFYrR3ERCW3A/N2Kf8g5YVxHnLw0vPNiuXj8UI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=igbWKzdjWJDUYt6ONJdhV+AjT1D6nBHdtCA1lJBPh2wfoj+Zgqgd7Zuir9ML5VZEQ my6n8AHzQVtRby3NFPKYvMKvZtO5W8QSafXblt9atQU43bpND5l5/oiTQ8e8NTgW2A 3sf51OD+eLuUOiIGMwOFDg7r1JOQGKDnTx7MSRPiq8M/iJsZ/yzNyEGco3KeSMRTCW MesyzQrpKBXkl9dKEF2nrQuEwlyh/44aWXo+e8JqmnhlrOVbGY8pJNXyh6UTxXw1ci /4iEKtLa7vJlFKoMEY4l6bOSaA1uEdvgBVhlZB+x44cmNEFddLjAJ1wn9a77Ss85Ya 7nlyy4/iXwEQw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id E55AA64E1F; Sat, 27 Dec 2025 13:44:04 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 27 Dec 2025 13:42:59 -0700 Message-ID: <20251227204318.886983-5-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: PG2FA2HKJEEFXMBRSV5H3WNRW7OKSS3O X-Message-ID-Hash: PG2FA2HKJEEFXMBRSV5H3WNRW7OKSS3O 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 Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 04/16] sandbox: Convert IRQ macros to static inline functions 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 Convert the local_irq_* macros to static inline functions to avoid "unused variable 'flags'" warnings when building with the atomic operations from asm-generic/atomic.h. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- arch/sandbox/include/asm/system.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/sandbox/include/asm/system.h b/arch/sandbox/include/asm/system.h index 7933b6292e2..438e2f65dc8 100644 --- a/arch/sandbox/include/asm/system.h +++ b/arch/sandbox/include/asm/system.h @@ -7,10 +7,10 @@ #define __ASM_SANDBOX_SYSTEM_H /* Define this as nops for sandbox architecture */ -#define local_irq_save(x) -#define local_irq_enable() -#define local_irq_disable() -#define local_save_flags(x) -#define local_irq_restore(x) +#define local_irq_save(x) ((x) = 0) +#define local_irq_enable() do { } while (0) +#define local_irq_disable() do { } while (0) +#define local_save_flags(x) ((x) = 0) +#define local_irq_restore(x) do { (void)(x); } while (0) #endif From patchwork Sat Dec 27 20:43:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1082 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=1766868256; bh=3xdOSEm15Lnj9cuI0InLuICzX3JWwwnVkA5FayeVoRU=; 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=nzjvt2hFlXmwxDEmV0HDY71r60b6Un6svG+AInS6mJaE4y9tFVXjZ/x6epq88j6qE gx6PY/ynZCEkqK8n3lLEoT+6ODPIUr9fXlq+FR7q7fH2KvkGMIG+yStcnIpUz/N3o2 eLZ6pEDJLGwlnWWM8GoOdn2gp3378ZdtS4lhQpcZCocGX4Id3bufisRHw3IgCt0KRl KMAjhi3qvZirH86eUUnL5yZrFV/g0SA+Vg8lgrASKZV8ATw9en9RuNitKEoln3km1q r7mIm000k+BOSrZ4wZPZYR3SnKocob2yJaGj8rPAES1hks+CYyQdHE3diVohi47jVt 5T0AP3QTmTiaQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 046DF68BEF for ; Sat, 27 Dec 2025 13:44:16 -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 HSYK2HGv7WP7 for ; Sat, 27 Dec 2025 13:44:15 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868255; bh=3xdOSEm15Lnj9cuI0InLuICzX3JWwwnVkA5FayeVoRU=; 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=vD6luIoH4JnA1sTFdMwqICBgKE//Lqu4rA0MGBLRFVC5f3rhrGUdbaA5q3MDmgLC1 V/kDTLBKbSa5ZsL73TBP/Kr0XaR3tbCnrFT+Vsw16ezZ3RY5uHlp0H1h/POZ4bAVoK JhPAr4tAyQ+aLBjJwUFgm1GM6SZipyorND1MMzvI5p7LcyVwUTzG8JHhz34UItErCR ljXJW9mGF49561BxuM7i/c4yP1aotLZp5covRoDYzwJ6+Ppop84S0Styxtz8VHiqeN U9o5XmOD62xaKk3A/Zu9t3IaCigTY/c1aeyVxro+5hBLEDycldPf+eCu/AUb0vZyCG +TCo2yUF/PU1w== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E62AB65079 for ; Sat, 27 Dec 2025 13:44:15 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868253; bh=ypqJLizzZ712+KB0wIUTjeCQtbX5r/7hvZ6nTGpJtXs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ktZpQ2F8G2W+w8e0fGFQeFGK5obO4vsxPzQX1cRAqTuJF/Wzr2ui3gfLGaEiAnpNc lv1VgRxjWi2p8PGozHiedSpOid8QF4D5K0gCdGpHTx8P8t06b8Rk3NwPF4gIFhdBlx x+ZhYLOb9lnKGWnky9xaB33qm9P1mirQdgE3NS7rkt8C/NzUJFJLs8qrqPEB0ETt+L 23nrU7WZco07YfK+fI50GojVY6Mb+ncBTMBkmHm/vsiNgE5ferZazmGI/nX1NfGb6w 7isUH33/fHaUDM7CZUOjL4BPdbDzdsIo0oM+HNb2w9HbLVi/sxz4lzEeJub3eQIAG8 EU14qfhNLGX+Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F144264C0C; Sat, 27 Dec 2025 13:44:13 -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 DCaicj660dKb; Sat, 27 Dec 2025 13:44:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868249; bh=GKwGvJK2cNX6bmkNVa6uAKheztn0zRB0aUbqgw/rrYU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GqJWWZ3m4AidKomQogWS8OSzgHukLL94Frkc9OQ0eSDLTdM3Jasn3vtnPpA6QO8/V 9XKzOiwvaq6A9W7XAiD7s5VifO7Maz50ePEgEOPL4h8vh1m2Jbxj+/6Xgqv73MQA77 /Lb5y9PHS8mr5bsRtXKjsJOn2vzTQTaDphGm8BgtqlMolIz88fQE/w0UnBMxc+M5ZP QsNvof5Y0BBhXxOtYrHUwB4bx8TRyHXjUnT2BTD9OjlOl/imqGx8owM5AUxLPD+e7f tV+DNrfq5dWaxVaNrt835M+O8ASspsygpDtNOjAZRG07GHc2NjjcATjoqxCChYDmZP bYwbwJMsGIzIw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 9169364E1F; Sat, 27 Dec 2025 13:44:09 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 27 Dec 2025 13:43:00 -0700 Message-ID: <20251227204318.886983-6-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: R6MCWQFOM5BOOIDKHK73IM76WW7Y4CL3 X-Message-ID-Hash: R6MCWQFOM5BOOIDKHK73IM76WW7Y4CL3 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 05/16] ext4l: Fix path lookup by implementing dentry operations 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 fscrypt_match_name stub macro always returns 1, causing every directory entry to match regardless of name. Also d_splice_alias is a no-op that returns NULL, so the inode found by ext4_lookup is never associated with the dentry. Fix fscrypt_match_name to properly compare name lengths and contents. Fix d_splice_alias, d_instantiate and d_instantiate_new to set d->d_inode. Co-developed-by: Claude Signed-off-by: Simon Glass --- fs/ext4l/ext4_uboot.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 52f479e9673..a90289c8fa5 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -1426,10 +1426,10 @@ typedef unsigned int projid_t; #define d_find_any_alias(i) ({ (void)(i); (struct dentry *)NULL; }) #define dget_parent(d) ({ (void)(d); (struct dentry *)NULL; }) #define dput(d) do { (void)(d); } while (0) -#define d_splice_alias(i, d) ({ (void)(i); (void)(d); (struct dentry *)NULL; }) +#define d_splice_alias(i, d) ({ (d)->d_inode = (i); (d); }) #define d_obtain_alias(i) ({ (void)(i); (struct dentry *)NULL; }) -#define d_instantiate_new(d, i) do { (void)(d); (void)(i); } while (0) -#define d_instantiate(d, i) do { (void)(d); (void)(i); } while (0) +#define d_instantiate_new(d, i) ((void)((d)->d_inode = (i))) +#define d_instantiate(d, i) ((void)((d)->d_inode = (i))) #define d_tmpfile(f, i) do { (void)(f); (void)(i); } while (0) #define d_invalidate(d) do { (void)(d); } while (0) #define finish_open_simple(f, e) (e) @@ -1555,7 +1555,6 @@ static inline char *d_path(const struct path *path, char *buf, int buflen) #define fscrypt_limit_io_blocks(i, lb, l) (l) #define fscrypt_prepare_setattr(d, a) ({ (void)(d); (void)(a); 0; }) #define fscrypt_dio_supported(i) (1) -#define fscrypt_match_name(f, n, l) ({ (void)(f); (void)(n); (void)(l); 1; }) #define fscrypt_has_permitted_context(p, c) ({ (void)(p); (void)(c); 1; }) #define fscrypt_is_nokey_name(d) ({ (void)(d); 0; }) #define fscrypt_prepare_symlink(d, s, l, m, dl) ({ (void)(d); (void)(s); (void)(l); (void)(m); (void)(dl); 0; }) @@ -1572,6 +1571,15 @@ struct fscrypt_name { bool is_nokey_name; }; +static inline int fscrypt_match_name(const struct fscrypt_name *fname, + const u8 *de_name, u32 de_name_len) +{ + if (fname->usr_fname->len != de_name_len) + return 0; + + return !memcmp(fname->usr_fname->name, de_name, de_name_len); +} + /* fsverity stubs */ #define fsverity_prepare_setattr(d, a) ({ (void)(d); (void)(a); 0; }) #define fsverity_active(i) (0) From patchwork Sat Dec 27 20:43:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1083 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=1766868258; bh=llAb9JzLfrPAXiUl0k1wRHY+spHWye2g4Qm2dj/yZWs=; 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=r1yfWj1Zku8BENLiGBrtjDduSai4Qg71wvYfIHYtQVD5ulWG8kWz5JnrBalqN4sfy DB4ODkDtXwDY7epGoUPJdv5mrXL7X4X3ZjtSHj+ZNVwZBHeI1RcMqdZK/nbc4wBAQ1 9+DB1UX1ZJuEGTzMmQo1H/Cs5AGfXHcADAWm4mpHsr0nFcJ4d9wRyu5FrRS9lpcs+D dg6YpgzMojZdi66f/j7qp+l5iRbHI4CjYGw8cFtaawGA3dn4fvcSjN1LD2xGxGo8cI ljmOORc2Gg+BPBaSydNuieb+jx8pbntZxDSL+sWNYlKr/Qn3DAZtg0ic6zphPnzldp fxgPOWfDsGbpQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6191164E4D for ; Sat, 27 Dec 2025 13:44:18 -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 MdcQqVwGCUGZ for ; Sat, 27 Dec 2025 13:44:18 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868256; bh=llAb9JzLfrPAXiUl0k1wRHY+spHWye2g4Qm2dj/yZWs=; 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=R7CxRDIC3OKh1w8qhb+aWRnRqTbmyp+a9KEs02FpIfRUGXs3Ch4IZ1rU9nvYdwJhD iVJaV3uI1zIiQ5zQI/45j50Gsd1KryBAt0OcozAhhJ1Of2W9irnGsgBubz/+1Rb2Cp kdq0KVM82DHDbcbZ+Wjrqn4ZhdN75/3EgVBuEpiMghVtQ5qNGGzTq9HJw9EhN2OPha D3xsoJwllitvP44T04xLtirXdGsfcySl6Pc9j/QouTHbrz3ZpVMeyWn2auCNbc0nrS vRCdT9uMIat7WnexL6cG/Vuo2WDaEEP2WiaDAXjWhfHpY4fkhsLoZoKDsj/LfY77Iz 0Fj485NlMfemA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 57EC368BF3 for ; Sat, 27 Dec 2025 13:44:16 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868255; bh=ir5EMTVZ8Fmcxbf5F4UxwegGYWJE3oOQtTetkL8dE1w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gcma/6A7XdUgD9JYQAPvEdctyLy4kwu6aIGyzkQRtsJ2eKDggZKcYGI7IJ+QUX8h2 vFw65Dx+0yxPlGOBclr+UAXu8ctnOHvRZl30MYMAFXy2dKppKS4uj/fqIhEnq97bgz jG7De8B513BTVsq6dxMYTAywBgLyasaBu7URBcsQpKA1WA1w07Y12Su6Nz3TqIp4QM udTF3MM5WAuF436JatwJWOyG6TKHRP7mviWdcHLRH4B5LsAc+BhABNxVjj1S+HIp49 zoPbltKdrH0pzuQuOfa2rZvc0duPZVRkeyii00r4IK9qAc+9l5086J+zuNS8elAgvG Wrb0Pk+XTLAvQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 058FA64E4D; Sat, 27 Dec 2025 13:44:15 -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 Ru1B0_m0Oij2; Sat, 27 Dec 2025 13:44:14 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868254; bh=QP3AOrj1tgl7sVQrbJySaYwtjj+fVB7JQsIX1n08SQE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TI0hA3VwSKoHSN7x3R65hdW7VK9roBi8yDnFpSJ3T5HBt3+nba64g+Oz2obBx3+cz NG4DVOKxqzNElTB1ie61jtYOQVs6XT7JRLpJumytZEir8jinfCM53iSFr8CxbpnOLH jdSknzUWj9ehf4fyiuqUiu2FFpXUIqjzLzUVPTmhdbpc8+MCfQ+BOEv3VZgO2WEykE rmymRhWhKwVjkEWlJnaqRGqfELL6MvAmI7nge1weBzBiN8UXkUGm7fSt3hkNsfG4UD ++xNY4khOWIJRvbQ55Tx0bszv5T3W3C0Io0iMtcBL2NG/aPVgmdemzKz3Ac2pWsNJp dY9QrqPkE/s/w== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 461BC64E1F; Sat, 27 Dec 2025 13:44:14 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 27 Dec 2025 13:43:01 -0700 Message-ID: <20251227204318.886983-7-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: WRHRPCWWMCRSQK36GENR2PJB4J4N6RJZ X-Message-ID-Hash: WRHRPCWWMCRSQK36GENR2PJB4J4N6RJZ 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 06/16] cmd: Enable fsuuid command for sandbox 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 fsuuid command is useful for testing filesystem UUID support. Enable it by default for sandbox builds. Co-developed-by: Claude Signed-off-by: Simon Glass --- cmd/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/Kconfig b/cmd/Kconfig index 5dad8d7deb7..5cb34509746 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -2835,6 +2835,7 @@ config CMD_FS_GENERIC config CMD_FS_UUID bool "fsuuid command" + default y if SANDBOX help Enables fsuuid command for filesystem UUID. From patchwork Sat Dec 27 20:43:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1084 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=1766868263; bh=zSIVmfve2s8b5XUO3unAa18DGbfBYjD7P8TZqih+obw=; 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=FfjfT3FofzMvdzQb8jVR3ar3qB4ajxN61ZSxAPKKAKl+mn1O+psGwOzXVnczM0OmY 5aLbz0j+BN67BrKQToILfpFoQKFuLFcYyv4BObCq4710U4T/8zE/5OMQdFz81nQmeJ neJyX6fCzTyTm6m8+V57Y+lRXEjNBiu3dAnbRQSBBu1+9Mbqn2/tkcxC0mqDY8C43i UWNk2/6+r6FUUkgsw5OA1hj0VjUVTlclqXnOeB/dCpPZ0ePEBz63fTQDgpRXK5TWoN GOzxcErVakh8OM/V4pTyVASzbzXx2jRm+9c8lue7ElLG08Y5nr8jMmJt7zKdhj1PPL /Bm6Uab6dRQYg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3358A64E44 for ; Sat, 27 Dec 2025 13:44:23 -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 MmB_nDQ-cZPm for ; Sat, 27 Dec 2025 13:44:23 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868263; bh=zSIVmfve2s8b5XUO3unAa18DGbfBYjD7P8TZqih+obw=; 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=FfjfT3FofzMvdzQb8jVR3ar3qB4ajxN61ZSxAPKKAKl+mn1O+psGwOzXVnczM0OmY 5aLbz0j+BN67BrKQToILfpFoQKFuLFcYyv4BObCq4710U4T/8zE/5OMQdFz81nQmeJ neJyX6fCzTyTm6m8+V57Y+lRXEjNBiu3dAnbRQSBBu1+9Mbqn2/tkcxC0mqDY8C43i UWNk2/6+r6FUUkgsw5OA1hj0VjUVTlclqXnOeB/dCpPZ0ePEBz63fTQDgpRXK5TWoN GOzxcErVakh8OM/V4pTyVASzbzXx2jRm+9c8lue7ElLG08Y5nr8jMmJt7zKdhj1PPL /Bm6Uab6dRQYg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 21B7B64E61 for ; Sat, 27 Dec 2025 13:44:23 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868260; bh=rHk6jZc6jhK6Ws6Dp7fhm0emHMiiKcrQP5jbURGv9sw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rLmWo7VifkiMd4p1GDdUi7Ntz9V9BVFOzJQyqM3h93kxXR72qp17NnGNO3xgJkvlr 5++efqt+H0g9A2bEQF1c4RkGo21BltTUDfWL1rMr4rD6N9PEBgwjOwD9lwNnX849Jk 5hQR7W8PsIQXn9mlHrej62eivIvxrWwwgzrAjbd/BJzSyt6QjmMoW/PYjPMKg9vZWa Oz8NGo4/3N+VMY/DM13J4/x/g5pusO0ADF5lMqdejBHDT9gEWqEMQ19n4qUvMzqBAm 5o1kVIu8LvXZnjuicEJ+R7aKSnzLJPqLdzUejXFRJ4JxiIy9F61BzAUVfBp5a20yqM DbfbGfTDtp+cg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AAD1464E4D; Sat, 27 Dec 2025 13:44:20 -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 om-wO5bO9h4a; Sat, 27 Dec 2025 13:44:20 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868255; bh=vHpYPqE6A5QjRMJczI0EG6JkcRvlLtuceysnubCLWTs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YEgDCDBBlxeG9B0ljbSQpz7MjqXsQ12D8Y8J7jAU3u1K0HwbZ+pI6WlyXaUdNsyfa 5IPEcs71ruL1oK81u2nVVTEjihz3++8eGHyQ8f4go5xUJLGy0AQ1YIdgMvJ0M7IzW/ a/ItOeYkBpjiy5w3k4dO2oDNMXPX9VKbuIHWCATNglcbZjcuwtlBmG28W8yaPIakLk C7Qytc5Afn/8wdy8wnFhxLuSS6EhPz9ZRP5a9f4pguIMyqmRcSUbRSwLoGM4O4wioc 2FILZcUchpsaNhq0zr0uDUb4tnzmdq/jnzgH6xZHPlTa3rRBOi0tNsFRvN+Kx1l8uy EWr7HbTPhJp0A== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 5092064E1F; Sat, 27 Dec 2025 13:44:15 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 27 Dec 2025 13:43:02 -0700 Message-ID: <20251227204318.886983-8-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: 3I7ZZXABATGLCAYLZMVTULN7Z5HC5N24 X-Message-ID-Hash: 3I7ZZXABATGLCAYLZMVTULN7Z5HC5N24 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 07/16] ext4l: Fix comment formatting 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 Add blank line after function doc titles per kernel-doc style. Co-developed-by: Claude Signed-off-by: Simon Glass --- fs/ext4l/interface.c | 9 +++++++++ include/ext4l.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/fs/ext4l/interface.c b/fs/ext4l/interface.c index b897f30c223..6e146f246bd 100644 --- a/fs/ext4l/interface.c +++ b/fs/ext4l/interface.c @@ -42,6 +42,7 @@ static char ext4l_msg_data[EXT4L_MSG_BUF_SIZE]; /** * ext4l_get_blk_dev() - Get the current block device + * * Return: Block device descriptor or NULL if not mounted */ struct blk_desc *ext4l_get_blk_dev(void) @@ -53,6 +54,7 @@ struct blk_desc *ext4l_get_blk_dev(void) /** * ext4l_get_partition() - Get the current partition info + * * Return: Partition info pointer */ struct disk_partition *ext4l_get_partition(void) @@ -62,6 +64,7 @@ struct disk_partition *ext4l_get_partition(void) /** * ext4l_get_uuid() - Get the filesystem UUID + * * @uuid: Buffer to receive the 16-byte UUID * Return: 0 on success, -ENODEV if not mounted */ @@ -75,6 +78,7 @@ int ext4l_get_uuid(u8 *uuid) /** * ext4l_set_blk_dev() - Set the block device for ext4l operations + * * @blk_dev: Block device descriptor * @partition: Partition info (can be NULL for whole disk) */ @@ -110,6 +114,7 @@ static void ext4l_msg_init(void) /** * ext4l_record_msg() - Record a message in the buffer + * * @msg: Message string to record * @len: Length of message */ @@ -304,6 +309,7 @@ err_exit_es: /** * ext4l_read_symlink() - Read the target of a symlink inode + * * @inode: Symlink inode * @target: Buffer to store target * @max_len: Maximum length of target buffer @@ -350,6 +356,7 @@ static int ext4l_resolve_path_internal(const char *path, struct inode **inodep, /** * ext4l_resolve_path() - Resolve path to inode + * * @path: Path to resolve * @inodep: Output inode pointer * Return: 0 on success, negative on error @@ -361,6 +368,7 @@ static int ext4l_resolve_path(const char *path, struct inode **inodep) /** * ext4l_resolve_path_internal() - Resolve path with symlink following + * * @path: Path to resolve * @inodep: Output inode pointer * @depth: Current recursion depth (for symlink loop detection) @@ -551,6 +559,7 @@ static int ext4l_resolve_path_internal(const char *path, struct inode **inodep, /** * ext4l_dir_actor() - Directory entry callback for ext4_readdir + * * @ctx: Directory context * @name: Entry name * @namelen: Length of name diff --git a/include/ext4l.h b/include/ext4l.h index e6ca11c163a..333d9db139c 100644 --- a/include/ext4l.h +++ b/include/ext4l.h @@ -30,6 +30,7 @@ void ext4l_close(void); /** * ext4l_ls() - List directory contents + * * @dirname: Directory path to list * Return: 0 on success, negative on error */ @@ -37,6 +38,7 @@ int ext4l_ls(const char *dirname); /** * ext4l_get_uuid() - Get the filesystem UUID + * * @uuid: Buffer to receive the 16-byte UUID * Return: 0 on success, -ENODEV if not mounted */ From patchwork Sat Dec 27 20:43:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1085 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=1766868267; bh=5JjtC0Cy9gS42leZ2BFLMGCTDP1tB/Yn+J1+xrMyoVI=; 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=d5qfcXjwPOku0W44tUoIvJMbVC3O2tGDhhl1FiLmhz4FNsG01TmDT45X7qjVhUp0d xW3YJmIIc8L4dPcxsiJcjWstcOhEKkRQhoBIoqhz4W+hsMPTpq+2SO8aYPnszbfzJL Gx/MkjeUdAWlO7yk/DT0aWW6bZCIZeLSbhnRvZWRonF1ADXwJoSTTcSviXpuHA5MHI UBMPKOWerFz1uSQEuaJ7WuXwXnmKln0NPBjrPIuDg2nlMSEzRpV9E78KYOMlOiLfCC OIzhgM+4cbi/RygeHB+Swb+PYlEwL4fK6uAVdfs1PjjAIM1k8r624sL8vnwY75sfU6 KMWcfidmmeWUA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B43B165079 for ; Sat, 27 Dec 2025 13:44:27 -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 0kKDBEaQLgfK for ; Sat, 27 Dec 2025 13:44:27 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868267; bh=5JjtC0Cy9gS42leZ2BFLMGCTDP1tB/Yn+J1+xrMyoVI=; 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=d5qfcXjwPOku0W44tUoIvJMbVC3O2tGDhhl1FiLmhz4FNsG01TmDT45X7qjVhUp0d xW3YJmIIc8L4dPcxsiJcjWstcOhEKkRQhoBIoqhz4W+hsMPTpq+2SO8aYPnszbfzJL Gx/MkjeUdAWlO7yk/DT0aWW6bZCIZeLSbhnRvZWRonF1ADXwJoSTTcSviXpuHA5MHI UBMPKOWerFz1uSQEuaJ7WuXwXnmKln0NPBjrPIuDg2nlMSEzRpV9E78KYOMlOiLfCC OIzhgM+4cbi/RygeHB+Swb+PYlEwL4fK6uAVdfs1PjjAIM1k8r624sL8vnwY75sfU6 KMWcfidmmeWUA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A3FA264E49 for ; Sat, 27 Dec 2025 13:44:27 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868265; bh=+tI1FaPizd24NB55/FrxoqEyoR1RlkY9JVhZvNvzeM8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z2bqW9Dq8kGYyAY/6FaWjSzcGT/iR3Uqk5yErKRrL8YrmzByVDMmsqHHEr5DNOrJV JDnqqyQTtqKWPYstKhS9IE3m8M2dwJe+b+2o36AkBiY9pgiBNok9sVbtPYvA/x1ozD QW2tgBSDnet2xMsqOq++JD2BwxoH0y5ng0Zzi6/0WMIQwqHY8qprMjcEN8W+141iox WQxiofXZNMBMvaU65JvmGMnp3DzrGPeUWhJDwy4D+Wp2yvsWaPMif2/y/fhXEDgtnN iaMS8zwKs9sMekPakNqJEADIEeJHjRv7cEPxeCiROilkFRSpb6pbSlKX0KXSlQ7hWh 6DQbWKNa94cpA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A010F64E42; Sat, 27 Dec 2025 13:44:25 -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 18X6-CVADTXI; Sat, 27 Dec 2025 13:44:25 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868260; bh=fAZOwTR2zJJV/Z/udmDhoShoGRGMG/TpSwPDiimN1Fo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s4XTpUr2N6eRDxMMw/k8/RbFzPLBDxb0TC462GBFtEXutCffo4Z/7eKoNgfeFic/I JeLUucgRHAwF8ucYyPzOfPjwBJ1uIdIxBuMvFfwZCHzB8/R/17JK9rO/B5bNcFLWBx erlkhjuPOPmTk2HQos/g5ME71uLdBifNnRcIBQf5B3/rrLc/DADMJOuB/pfdRBmuvv LopfNjsPjKfdbVYCTRLyahyRLwLJRS6zcTipbkkH6L4vlU6WYQgUbGUpoE8hOFPqEI OK9P7SepzDLrG2yt1+SxUB6fb4mW9OmoKozivYV1qC4CAfSmGNAseHuf6at1BDJAIO 7wHWbGc0/3mTA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 0CD5A64C0C; Sat, 27 Dec 2025 13:44:19 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 27 Dec 2025 13:43:03 -0700 Message-ID: <20251227204318.886983-9-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: DACWPBAFEZLU4TMMSIUMMIUXAGWUMSLZ X-Message-ID-Hash: DACWPBAFEZLU4TMMSIUMMIUXAGWUMSLZ 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 08/16] test: ext4l: Handle variable console output in tests 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 Directory entries appear in hash order and mount messages may appear multiple times during probe operations. Update tests to skip remaining output after finding expected content. We could perhaps refine this with more powerful matching, but that is left for another day. Co-developed-by: Claude Signed-off-by: Simon Glass --- test/fs/ext4l.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/test/fs/ext4l.c b/test/fs/ext4l.c index 122b022d8d8..4c477ce3338 100644 --- a/test/fs/ext4l.c +++ b/test/fs/ext4l.c @@ -68,12 +68,14 @@ static int fs_test_ext4l_msgs_norun(struct unit_test_state *uts) /* * Check messages. The probe test runs first and doesn't unmount, - * so the journal needs recovery. Verify both messages. + * so the journal needs recovery. The filesystem may be mounted + * multiple times during probe operations. Just verify we see the + * expected mount message at least once. */ - ut_assert_nextline("EXT4-fs (ext4l_mmc0): recovery complete"); - ut_assert_nextline("EXT4-fs (ext4l_mmc0): mounted filesystem %s r/w with ordered data mode. Quota mode: disabled.", - uuid_str); - ut_assert_console_end(); + ut_assert_skip_to_line("EXT4-fs (ext4l_mmc0): mounted filesystem %s r/w" + " with ordered data mode. Quota mode: disabled.", + uuid_str); + /* Skip any remaining messages */ return 0; } @@ -100,9 +102,10 @@ static int fs_test_ext4l_ls_norun(struct unit_test_state *uts) * The Python test adds testfile.txt (12 bytes) to the image. * Directory entries appear in hash order which varies between runs. * Verify the file entry appears with correct size (12 bytes). + * Other entries like ., .., subdir, lost+found may also appear. */ ut_assert_skip_to_line(" 12 testfile.txt"); - ut_assert_console_end(); + /* Skip any remaining entries */ return 0; } From patchwork Sat Dec 27 20:43:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1086 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=1766868272; bh=I1Sdv7AmN9Yrk97qH9Otxdw+f8fqB/srONW60IjhRYI=; 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=XIUJ6UzyUQEyHOby5NDMjlFR6bKh7BYIPs7CnpaZA0ar+wZJgjXQXcLSFuangMVp7 6aEUj1xemgBbz957WYCD0cC5QIOCRGZgvWfHFctnmdabgIFjz21MctMTmQTe9V0J+7 OiyslHJCMD6etLlRBmN/3uM7dN7dZVr/F9I0HpZ8AWEoJRfxvVaGjPFBHYLfmfjt/4 +g8fbmhFK93kdPsRQMiOF7cFREZuSqEcMP+ryIgyUFPj/MEtWwfkCY33v+LXL0GfJ8 NDYr9On1Ypf7g+oFAnWzyaB1vQRHKiYgO0uTq+Z6phdYQUGw/J1whPh1SWpNar5F4g zXZ1Dua2M30NQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3828D64E49 for ; Sat, 27 Dec 2025 13:44:32 -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 OZ7yg73Nok3O for ; Sat, 27 Dec 2025 13:44:32 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868272; bh=I1Sdv7AmN9Yrk97qH9Otxdw+f8fqB/srONW60IjhRYI=; 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=XIUJ6UzyUQEyHOby5NDMjlFR6bKh7BYIPs7CnpaZA0ar+wZJgjXQXcLSFuangMVp7 6aEUj1xemgBbz957WYCD0cC5QIOCRGZgvWfHFctnmdabgIFjz21MctMTmQTe9V0J+7 OiyslHJCMD6etLlRBmN/3uM7dN7dZVr/F9I0HpZ8AWEoJRfxvVaGjPFBHYLfmfjt/4 +g8fbmhFK93kdPsRQMiOF7cFREZuSqEcMP+ryIgyUFPj/MEtWwfkCY33v+LXL0GfJ8 NDYr9On1Ypf7g+oFAnWzyaB1vQRHKiYgO0uTq+Z6phdYQUGw/J1whPh1SWpNar5F4g zXZ1Dua2M30NQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 26C3064E4D for ; Sat, 27 Dec 2025 13:44:32 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868269; bh=CjU0JtGKzFyRqKev/xMVnhuLuKcSFAsIrE3gvPO4a1M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UpBBmQAT20PBBSHVjIj916jIAztc7xWDkYU0IXaRZ+9MpzCuzQPZAjzJ4i2HmtTIY /Wt8RjmPgY30Bcoj4eepGXD7oesg8QXPeKCvgvUA1/88KqN8dRygGR93Vmb+Ypm/lc nMZhNeBPMwNmf/E9gzhZmjV6oU3TVFzDBFTh+rjBoMz2QOk4/435agS+lEJK5hXMiv LdSbzE9uBIK/LQaD0mDEek0No/TFWxDdleSnsp//cbvYmJ3CZrCY+5pZjmS/6Qcktw 0+D2OnF/kh6aeO07vuUPAtMHvE3JQJVh2J2I3LM0O6gTMzRbj8coBN9+l4OUu3pc9W GvnL1LDGjAzDA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 52B1C64E42; Sat, 27 Dec 2025 13:44:29 -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 I1VdwUaJIDpo; Sat, 27 Dec 2025 13:44:29 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868265; bh=zjqMJk+UxXGkfsjGwD8a27zTheXlbTj9IWAh9ezcvVI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gyel29xLu1r4tY4kXLyWO4FYfctxBDGX12d4E2DDCCiPFP/6w+Hx7A6uEIvvKZZVt v1MtWBWcKNMeM9/o1Vzn1dKk+hCjaJXCIB3fMfqPMiJYUzDiqrrbaUq2H/IeBt6ZMm hiN8ExDQqoHSSipDpgS4W9dwgXfE39/AIUnCfnW/3/32EKb/KgyaiIL209nwb3NpUU cMYZD7c/mn+SNJqv3DXzAiCBztX+2OWBuhULtY+ePNtm92htZ8cwFe4JjtfFp8tuqS x3wYSeUwHeMCeDcDu/euWdodT3om8h7MQhjK0wE9VYO2xZNFY9fm8NqZnmSKj0GQS5 /g24R2nrZG2oA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B1F9564E1F; Sat, 27 Dec 2025 13:44:24 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 27 Dec 2025 13:43:04 -0700 Message-ID: <20251227204318.886983-10-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: NOYYZEFR24U66EENLAYY3BXUF3Z4354M X-Message-ID-Hash: NOYYZEFR24U66EENLAYY3BXUF3Z4354M 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 Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 09/16] ext4l: Add open/read/close directory 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 Implement directory-iteration for the ext4l filesystem driver, allowing callers to iterate through directory entries one at a time. Add ext4l_opendir() which opens a directory and returns a stream handle, ext4l_readdir() which returns the next directory entry, and ext4l_closedir() which closes the stream and frees resources. The implementation uses a struct dir_context to capture single entries from ext4_readdir(), with logic to skip previously returned entries since the htree code may re-emit them. Update struct file to include a position. Wire these functions into fs_legacy.c for the ext4l filesystem type. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/interface.c | 210 ++++++++++++++++++++++++++++ fs/fs_legacy.c | 4 +- include/ext4l.h | 28 ++++ include/linux/fs.h | 1 + test/fs/ext4l.c | 85 +++++++++++ test/py/tests/test_fs/test_ext4l.py | 22 ++- 6 files changed, 348 insertions(+), 2 deletions(-) diff --git a/fs/ext4l/interface.c b/fs/ext4l/interface.c index 6e146f246bd..e7f09fd45dc 100644 --- a/fs/ext4l/interface.c +++ b/fs/ext4l/interface.c @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -33,6 +34,9 @@ static struct blk_desc *ext4l_blk_dev; static struct disk_partition ext4l_partition; static int ext4l_mounted; +/* Count of open directory streams (prevents unmount while iterating) */ +static int ext4l_open_dirs; + /* Global super_block pointer for filesystem operations */ static struct super_block *ext4l_sb; @@ -634,7 +638,213 @@ int ext4l_ls(const char *dirname) void ext4l_close(void) { + if (ext4l_open_dirs > 0) + return; + ext4l_dev_desc = NULL; ext4l_sb = NULL; ext4l_clear_blk_dev(); } + +/** + * struct ext4l_dir - ext4l directory stream state + * @parent: base fs_dir_stream structure + * @dirent: directory entry to return to caller + * @dir_inode: pointer to directory inode + * @file: file structure for ext4_readdir + * @entry_found: flag set by actor when entry is captured + * @last_ino: inode number of last returned entry (to skip on next call) + * @skip_last: true if we need to skip the last_ino entry + * + * The filesystem stays mounted while directory streams are open (ext4l_close + * checks ext4l_open_dirs), so we can keep direct pointers to inodes. + */ +struct ext4l_dir { + struct fs_dir_stream parent; + struct fs_dirent dirent; + struct inode *dir_inode; + struct file file; + bool entry_found; + u64 last_ino; + bool skip_last; +}; + +/** + * struct ext4l_readdir_ctx - Extended dir_context with back-pointer + * @ctx: base dir_context structure (must be first) + * @dir: pointer to ext4l_dir for state updates + */ +struct ext4l_readdir_ctx { + struct dir_context ctx; + struct ext4l_dir *dir; +}; + +/** + * ext4l_opendir_actor() - dir_context actor that captures single entry + * + * This actor is called by ext4_readdir for each directory entry. It captures + * the first entry found (skipping the previously returned entry if needed) + * and returns non-zero to stop iteration. + */ +static int ext4l_opendir_actor(struct dir_context *ctx, const char *name, + int namelen, loff_t offset, u64 ino, + unsigned int d_type) +{ + struct ext4l_readdir_ctx *rctx; + struct ext4l_dir *dir; + struct fs_dirent *dent; + struct inode *inode; + + rctx = container_of(ctx, struct ext4l_readdir_ctx, ctx); + dir = rctx->dir; + + /* + * Skip the entry we returned last time. The htree code may call us + * with the same entry again due to its extra_fname handling. + */ + if (dir->skip_last && ino == dir->last_ino) { + dir->skip_last = false; + return 0; /* Continue to next entry */ + } + + dent = &dir->dirent; + + /* Copy name */ + if (namelen >= FS_DIRENT_NAME_LEN) + namelen = FS_DIRENT_NAME_LEN - 1; + memcpy(dent->name, name, namelen); + dent->name[namelen] = '\0'; + + /* Set type based on d_type hint */ + switch (d_type) { + case DT_DIR: + dent->type = FS_DT_DIR; + break; + case DT_LNK: + dent->type = FS_DT_LNK; + break; + default: + dent->type = FS_DT_REG; + break; + } + + /* Look up inode to get size and other attributes */ + inode = ext4_iget(ext4l_sb, ino, 0); + if (!IS_ERR(inode)) { + dent->size = inode->i_size; + /* Refine type from inode mode if needed */ + if (S_ISDIR(inode->i_mode)) + dent->type = FS_DT_DIR; + else if (S_ISLNK(inode->i_mode)) + dent->type = FS_DT_LNK; + else + dent->type = FS_DT_REG; + } else { + dent->size = 0; + } + + dir->entry_found = true; + dir->last_ino = ino; + + /* + * Return non-zero to stop iteration after one entry. + * dir_emit() returns (actor(...) == 0), so: + * actor returns 0 -> dir_emit returns 1 (continue) + * actor returns non-zero -> dir_emit returns 0 (stop) + */ + return 1; +} + +int ext4l_opendir(const char *filename, struct fs_dir_stream **dirsp) +{ + struct ext4l_dir *dir; + struct inode *inode; + int ret; + + if (!ext4l_mounted) + return -ENODEV; + + ret = ext4l_resolve_path(filename, &inode); + if (ret) + return ret; + + if (!S_ISDIR(inode->i_mode)) + return -ENOTDIR; + + dir = calloc(1, sizeof(*dir)); + if (!dir) + return -ENOMEM; + + dir->dir_inode = inode; + dir->entry_found = false; + + /* Set up file structure for ext4_readdir */ + dir->file.f_inode = inode; + dir->file.f_mapping = inode->i_mapping; + dir->file.private_data = kzalloc(sizeof(struct dir_private_info), + GFP_KERNEL); + if (!dir->file.private_data) { + free(dir); + return -ENOMEM; + } + + /* Increment open dir count to prevent unmount */ + ext4l_open_dirs++; + + *dirsp = (struct fs_dir_stream *)dir; + + return 0; +} + +int ext4l_readdir(struct fs_dir_stream *dirs, struct fs_dirent **dentp) +{ + struct ext4l_dir *dir = (struct ext4l_dir *)dirs; + struct ext4l_readdir_ctx ctx; + int ret; + + if (!ext4l_mounted) + return -ENODEV; + + memset(&dir->dirent, '\0', sizeof(dir->dirent)); + dir->entry_found = false; + + /* Skip the entry we returned last time (htree may re-emit it) */ + if (dir->last_ino) + dir->skip_last = true; + + /* Set up extended dir_context for this iteration */ + memset(&ctx, '\0', sizeof(ctx)); + ctx.ctx.actor = ext4l_opendir_actor; + ctx.ctx.pos = dir->file.f_pos; + ctx.dir = dir; + + ret = ext4_readdir(&dir->file, &ctx.ctx); + + /* Update file position for next call */ + dir->file.f_pos = ctx.ctx.pos; + + if (ret < 0) + return ret; + + if (!dir->entry_found) + return -ENOENT; + + *dentp = &dir->dirent; + + return 0; +} + +void ext4l_closedir(struct fs_dir_stream *dirs) +{ + struct ext4l_dir *dir = (struct ext4l_dir *)dirs; + + if (dir) { + if (dir->file.private_data) + ext4_htree_free_dir_info(dir->file.private_data); + free(dir); + } + + /* Decrement open dir count */ + if (ext4l_open_dirs > 0) + ext4l_open_dirs--; +} diff --git a/fs/fs_legacy.c b/fs/fs_legacy.c index 6ca9d6e647a..7d293468ea8 100644 --- a/fs/fs_legacy.c +++ b/fs/fs_legacy.c @@ -271,7 +271,9 @@ static struct fstype_info fstypes[] = { .read = fs_read_unsupported, .write = fs_write_unsupported, .uuid = fs_uuid_unsupported, - .opendir = fs_opendir_unsupported, + .opendir = ext4l_opendir, + .readdir = ext4l_readdir, + .closedir = ext4l_closedir, .unlink = fs_unlink_unsupported, .mkdir = fs_mkdir_unsupported, .ln = fs_ln_unsupported, diff --git a/include/ext4l.h b/include/ext4l.h index 333d9db139c..6d8eba84f4e 100644 --- a/include/ext4l.h +++ b/include/ext4l.h @@ -11,6 +11,8 @@ struct blk_desc; struct disk_partition; +struct fs_dir_stream; +struct fs_dirent; /** * ext4l_probe() - Probe a block device for an ext4 filesystem @@ -44,4 +46,30 @@ int ext4l_ls(const char *dirname); */ int ext4l_get_uuid(u8 *uuid); +/** + * ext4l_opendir() - Open a directory for iteration + * + * @filename: Directory path + * @dirsp: Returns directory stream pointer + * Return: 0 on success, -ENODEV if not mounted, -ENOTDIR if not a directory, + * -ENOMEM on allocation failure + */ +int ext4l_opendir(const char *filename, struct fs_dir_stream **dirsp); + +/** + * ext4l_readdir() - Read the next directory entry + * + * @dirs: Directory stream from ext4l_opendir + * @dentp: Returns pointer to directory entry + * Return: 0 on success, -ENODEV if not mounted, -ENOENT at end of directory + */ +int ext4l_readdir(struct fs_dir_stream *dirs, struct fs_dirent **dentp); + +/** + * ext4l_closedir() - Close a directory stream + * + * @dirs: Directory stream to close + */ +void ext4l_closedir(struct fs_dir_stream *dirs); + #endif /* __EXT4L_H__ */ diff --git a/include/linux/fs.h b/include/linux/fs.h index ef28c12c022..090ee192061 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -98,6 +98,7 @@ struct file { void *private_data; struct file_ra_state f_ra; struct path f_path; + loff_t f_pos; }; /* Get inode from file */ diff --git a/test/fs/ext4l.c b/test/fs/ext4l.c index 4c477ce3338..d9ed21407e7 100644 --- a/test/fs/ext4l.c +++ b/test/fs/ext4l.c @@ -111,3 +111,88 @@ static int fs_test_ext4l_ls_norun(struct unit_test_state *uts) } FS_TEST_ARGS(fs_test_ext4l_ls_norun, UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL, { "fs_image", UT_ARG_STR }); + +/** + * fs_test_ext4l_opendir_norun() - Test ext4l opendir/readdir/closedir + * + * Verifies that the ext4l driver can iterate through directory entries using + * the opendir/readdir/closedir interface. It checks: + * - Regular files (testfile.txt) + * - Subdirectories (subdir) + * - Symlinks (link.txt) + * - Files in subdirectories (subdir/nested.txt) + * + * Arguments: + * fs_image: Path to the ext4 filesystem image + */ +static int fs_test_ext4l_opendir_norun(struct unit_test_state *uts) +{ + const char *fs_image = ut_str(EXT4L_ARG_IMAGE); + struct fs_dir_stream *dirs; + struct fs_dirent *dent; + bool found_testfile = false; + bool found_subdir = false; + bool found_symlink = false; + bool found_nested = false; + int count = 0; + + 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)); + + /* Open root directory */ + ut_assertok(ext4l_opendir("/", &dirs)); + ut_assertnonnull(dirs); + + /* Iterate through entries */ + while (!ext4l_readdir(dirs, &dent)) { + ut_assertnonnull(dent); + count++; + if (!strcmp(dent->name, "testfile.txt")) { + found_testfile = true; + ut_asserteq(FS_DT_REG, dent->type); + ut_asserteq(12, dent->size); + } else if (!strcmp(dent->name, "subdir")) { + found_subdir = true; + ut_asserteq(FS_DT_DIR, dent->type); + } else if (!strcmp(dent->name, "link.txt")) { + found_symlink = true; + ut_asserteq(FS_DT_LNK, dent->type); + } + } + + ext4l_closedir(dirs); + + /* Verify we found expected entries */ + ut_assert(found_testfile); + ut_assert(found_subdir); + ut_assert(found_symlink); + /* At least ., .., testfile.txt, subdir, link.txt */ + ut_assert(count >= 5); + + /* Now test reading the subdirectory */ + ut_assertok(fs_set_blk_dev("host", "0", FS_TYPE_ANY)); + ut_assertok(ext4l_opendir("/subdir", &dirs)); + ut_assertnonnull(dirs); + + count = 0; + while (!ext4l_readdir(dirs, &dent)) { + ut_assertnonnull(dent); + count++; + if (!strcmp(dent->name, "nested.txt")) { + found_nested = true; + ut_asserteq(FS_DT_REG, dent->type); + ut_asserteq(12, dent->size); + } + } + + ext4l_closedir(dirs); + + ut_assert(found_nested); + /* At least ., .., nested.txt */ + ut_assert(count >= 3); + + return 0; +} +FS_TEST_ARGS(fs_test_ext4l_opendir_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 93b6d4d34e8..073b02a80ce 100644 --- a/test/py/tests/test_fs/test_ext4l.py +++ b/test/py/tests/test_fs/test_ext4l.py @@ -37,14 +37,27 @@ class TestExt4l: shell=True) check_call(f'mkfs.ext4 -q {image_path}', shell=True) - # Add a test file using debugfs (no mount required) + # Add test files using debugfs (no mount required) with NamedTemporaryFile(mode='w', delete=False) as tmp: tmp.write('hello world\n') tmp_path = tmp.name try: + # Add a regular file check_call(f'debugfs -w {image_path} ' f'-R "write {tmp_path} testfile.txt" 2>/dev/null', shell=True) + # Add a subdirectory + check_call(f'debugfs -w {image_path} ' + f'-R "mkdir subdir" 2>/dev/null', + shell=True) + # Add a file in the subdirectory + check_call(f'debugfs -w {image_path} ' + f'-R "write {tmp_path} subdir/nested.txt" 2>/dev/null', + shell=True) + # Add a symlink + check_call(f'debugfs -w {image_path} ' + f'-R "symlink link.txt testfile.txt" 2>/dev/null', + shell=True) finally: os.unlink(tmp_path) except CalledProcessError: @@ -76,3 +89,10 @@ class TestExt4l: output = ubman.run_command( f'ut -f fs fs_test_ext4l_ls_norun fs_image={ext4_image}') assert 'failures: 0' in output + + def test_opendir(self, ubman, ext4_image): + """Test that ext4l can iterate directory entries.""" + with ubman.log.section('Test ext4l opendir'): + output = ubman.run_command( + f'ut -f fs fs_test_ext4l_opendir_norun fs_image={ext4_image}') + assert 'failures: 0' in output From patchwork Sat Dec 27 20:43:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1087 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=1766868274; bh=GB++VOqv8kbzOUU+UeBEkdUf9TdjXzw4TqrBetVbW5w=; 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=IWvlB+hnhIEWY9eHjsmCt3muCapwZCK0LgzbL69yQuBWQs4U5peuOQ5phdLPg9DwZ 0432BUNERcC912JWKOZzmujcvr/1rY10fuApSb1Dvq4WVWRTBBtKWtRhMr1rifx5yK SgI1c+EwblfFpgVL2Ag9ef7sdkgiJ33VdcmMhn3xmb1/Oam9cZJjC1qnyutlpFrmWi L9p3YNYlV1ySXbjCduoBPlF4ihyYLr/ytMqacTkj6wrALCvS5cuf/36ycdNKAU5OnZ qnvee4Ior3FeoKPv8NsWiZoSDSYO4MwjAlISb54F4HB6m1/OjycYVuTEO2UzBUrY+k fykT97nlIzsJw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 98A3764E4D for ; Sat, 27 Dec 2025 13:44:34 -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 0tN_LmKzxkwu for ; Sat, 27 Dec 2025 13:44:34 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868273; bh=GB++VOqv8kbzOUU+UeBEkdUf9TdjXzw4TqrBetVbW5w=; 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=j4LvaACI7sRGQr7Efecw+9WgNMs6XAOuFX1ki+AGLjeXWVHaafK65FmCGAdxeGpIb A7AC/gD1bE7tgxXs75cdc2D8zdjQpVb65NnUPyUfLwOZFOEMJ/pnde65ISRdZ850DF irGUEEvowGZMKAVc5jFhn52zevUCpwjrxPAUiyKhD0GSd1qv8C1NINgBlAsnKiKYif P1p/58r3/KvFqcEcn6v8eiLeNs+A2mmoC+Aiut+D97/87wJ7aloNeMNWX15yFbH54E TG4BUYBcElqSyNYsU5YSpZi1OYPJx/Xx44f0LtP1qUSlo79mDUab8mBhQKX9BmOcCL 6LgSD2++eMdsQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1FB2468BF3 for ; Sat, 27 Dec 2025 13:44:33 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868270; bh=kCDXp7+5WhiNBM8AiHTMaC/iBItq3+6NrEc15H9kL5U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mwfTEVhWSyYIlwQ5lzWTm9aU3zvKJnuKq7L0l7TtPdekWf8OnvGM55yuRKLyH0v9l s8FweI5aKQRDnP8ipGVD2TBx4r05iY8kZINm2W0CHVVj0uDqa/qyKRHfWKKgbO/QUS xQEwiRViF7XZBzET90X4aIrXFhdKpGlB5yzlCncsFAPPc9JLvhtrbiqTbzACeva7yC GrcDE71d0RqstWV6+WVCpLf0LjgQ8yJGyEIdqPU7tTJSMFSa2XCy6zQIoYfMvagIb+ /3fCBljc1g6vdHwfxYvCW8/CPRjBOrQGvISzMRcQX+5Mm/JU/GTZnRTcdzrjgY0UtN 4UXMho+YYAdnw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 49AC764E49; Sat, 27 Dec 2025 13:44:30 -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 9WYjzFj-qVOc; Sat, 27 Dec 2025 13:44:30 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868270; bh=U4mzSx0vZs+c9vMMDrMUHVgahRQa7NvpTYl4XikxuL8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iGl3Xsb8XadvXSRFvNov3KDdn3yEnC+85oJ8QV1a41ch0mqyx/dXAJT7TIK+97nwS ERkSRPBtFBKNpsANgbZjfP4AI2zY4FkMvIxlpPxzP+gUMGF3fw3jy5K93HydcEwG2P lj+pmE2E7jZyc0ts4habmLOyVjXJqDgdqR9z66rJ/0dhoMQrw/akEByXD20/FYzPCl s/6YbRTfRiQqXMSlzVLRs96Pu2/t8baZa6u/AZW10OWc3oWbG8aVglY3uRKmURCB1k Sosxn+HV+aGs+xdAwx6Bm1DPBVQLY4c32W28hrRvElSTvqpjDy2m8TJk3nUvUJjjSl wVrRtw9Mvzydw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 9B99264E1F; Sat, 27 Dec 2025 13:44:29 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 27 Dec 2025 13:43:05 -0700 Message-ID: <20251227204318.886983-11-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: 2NEUICWQFMY677MZBNCCQGVXU2UMC7W4 X-Message-ID-Hash: 2NEUICWQFMY677MZBNCCQGVXU2UMC7W4 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 Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 10/16] ext4l: Add exists() 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 Implement ext4l_exists() to check if a file or directory exists on the filesystem. This uses ext4l_resolve_path() to look up the path and returns 1 if found, 0 otherwise. Wire the function into fs_legacy.c and add a basic test. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/interface.c | 13 +++++++++++++ fs/fs_legacy.c | 2 +- include/ext4l.h | 8 ++++++++ test/fs/ext4l.c | 27 +++++++++++++++++++++++++++ test/py/tests/test_fs/test_ext4l.py | 7 +++++++ 5 files changed, 56 insertions(+), 1 deletion(-) diff --git a/fs/ext4l/interface.c b/fs/ext4l/interface.c index e7f09fd45dc..409a3ff7edc 100644 --- a/fs/ext4l/interface.c +++ b/fs/ext4l/interface.c @@ -636,6 +636,19 @@ int ext4l_ls(const char *dirname) return ret; } +int ext4l_exists(const char *filename) +{ + struct inode *inode; + + if (!filename) + return 0; + + if (ext4l_resolve_path(filename, &inode)) + return 0; + + return 1; +} + void ext4l_close(void) { if (ext4l_open_dirs > 0) diff --git a/fs/fs_legacy.c b/fs/fs_legacy.c index 7d293468ea8..849c0304668 100644 --- a/fs/fs_legacy.c +++ b/fs/fs_legacy.c @@ -266,7 +266,7 @@ static struct fstype_info fstypes[] = { .probe = ext4l_probe, .close = ext4l_close, .ls = ext4l_ls, - .exists = fs_exists_unsupported, + .exists = ext4l_exists, .size = fs_size_unsupported, .read = fs_read_unsupported, .write = fs_write_unsupported, diff --git a/include/ext4l.h b/include/ext4l.h index 6d8eba84f4e..23d53b30d9e 100644 --- a/include/ext4l.h +++ b/include/ext4l.h @@ -38,6 +38,14 @@ void ext4l_close(void); */ int ext4l_ls(const char *dirname); +/** + * ext4l_exists() - Check if a file or directory exists + * + * @filename: Path to check + * Return: 1 if exists, 0 if not + */ +int ext4l_exists(const char *filename); + /** * ext4l_get_uuid() - Get the filesystem UUID * diff --git a/test/fs/ext4l.c b/test/fs/ext4l.c index d9ed21407e7..79813375ff1 100644 --- a/test/fs/ext4l.c +++ b/test/fs/ext4l.c @@ -196,3 +196,30 @@ static int fs_test_ext4l_opendir_norun(struct unit_test_state *uts) } FS_TEST_ARGS(fs_test_ext4l_opendir_norun, UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL, { "fs_image", UT_ARG_STR }); + +/** + * fs_test_ext4l_exists_norun() - Test ext4l_exists function + * + * Verifies that ext4l_exists correctly reports file existence. + * + * Arguments: + * fs_image: Path to the ext4 filesystem image + */ +static int fs_test_ext4l_exists_norun(struct unit_test_state *uts) +{ + const char *fs_image = ut_str(EXT4L_ARG_IMAGE); + + 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)); + + /* Test existing directory */ + ut_asserteq(1, ext4l_exists("/")); + + /* Test non-existent paths */ + ut_asserteq(0, ext4l_exists("/no/such/path")); + + return 0; +} +FS_TEST_ARGS(fs_test_ext4l_exists_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 073b02a80ce..890b6aeaef1 100644 --- a/test/py/tests/test_fs/test_ext4l.py +++ b/test/py/tests/test_fs/test_ext4l.py @@ -96,3 +96,10 @@ class TestExt4l: output = ubman.run_command( f'ut -f fs fs_test_ext4l_opendir_norun fs_image={ext4_image}') assert 'failures: 0' in output + + def test_exists(self, ubman, ext4_image): + """Test that ext4l_exists reports file existence correctly.""" + with ubman.log.section('Test ext4l exists'): + output = ubman.run_command( + f'ut -f fs fs_test_ext4l_exists_norun fs_image={ext4_image}') + assert 'failures: 0' in output From patchwork Sat Dec 27 20:43:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1088 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=1766868278; bh=QvEaVXnlXNcJFkuHsROglpYl4LWDSJb4ErR6QQ2rT+o=; 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=f7Au1YDKDSzdK6onj9vTVAVDn50OBxIYdWsBMY+clIY226P5+0nk+34MgYUlQ6TkO PtRyw0d4Mtx2tpf6SQKv4k3io+y/mtGZGN9xADoB27cIneiFWSO0JpxFURYjvWmar0 Jm9czLXvaOFcxVtnMbGGsS9wObfPUNIpYIJ7XHe34umGwTxBk4Ib8G51wKTiQBkGjG a2gTJvyDQtAZ/Bb/0X6A9+YU9gEiSo3LaRxPORojzy+u2iDJy1pmjA0/mQSpil9NUb 3d86Zf0yNXl2NsomvC3djHOvXOOtCR7UXh/Y0RfUSP4a5QlHLsqieWLbrQLXv6doOe po4tQIrzpY+xw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9A8CC64E4D for ; Sat, 27 Dec 2025 13:44:38 -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 WEpSeSoHqLxi for ; Sat, 27 Dec 2025 13:44:38 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868278; bh=QvEaVXnlXNcJFkuHsROglpYl4LWDSJb4ErR6QQ2rT+o=; 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=f7Au1YDKDSzdK6onj9vTVAVDn50OBxIYdWsBMY+clIY226P5+0nk+34MgYUlQ6TkO PtRyw0d4Mtx2tpf6SQKv4k3io+y/mtGZGN9xADoB27cIneiFWSO0JpxFURYjvWmar0 Jm9czLXvaOFcxVtnMbGGsS9wObfPUNIpYIJ7XHe34umGwTxBk4Ib8G51wKTiQBkGjG a2gTJvyDQtAZ/Bb/0X6A9+YU9gEiSo3LaRxPORojzy+u2iDJy1pmjA0/mQSpil9NUb 3d86Zf0yNXl2NsomvC3djHOvXOOtCR7UXh/Y0RfUSP4a5QlHLsqieWLbrQLXv6doOe po4tQIrzpY+xw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8A1D068BF3 for ; Sat, 27 Dec 2025 13:44:38 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868276; bh=pFE2tFbMHfXA48D9P7YYatTNlfZMtbyrVMQBvnisVKg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d0tf9ADomZEDYxfSL/vZjNSPEsAk+Qgxkj9vdj0wLy+N9SXU0sDzrENLv0Q+zZhz+ PV9SxHWmzYDfZhNFwDMFouJlW/ZevWK5PqcwsWoTAJvtb+Uq6MlVzktpK1yUzU376V hXcD1gZYc2QjmX3XfYHe0wdMinM42isO12ESPD27XSGd+Xn/btvUcuEBk5OhTcIVkM KW+HdbH0jucSHF6RCIgMVHh8/XwL0gnecnDDex7PSe8zDelbxHiPGtYloXB6wmZU5r 4l0KWxJs9sAhcaj2utH2QrOb8vhs9fX/GgJh7pPm/6VDEDbUB4Z3bz/1MEVdV4o+Iw rVcFOwB3luD5Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D663464E4D; Sat, 27 Dec 2025 13:44:36 -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 G2GqNPTPf99I; Sat, 27 Dec 2025 13:44:36 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868271; bh=3LvVHyUUNWi0guv0wQgFubqJidkmfxlIyjqon3GobsI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m6TY+e5qf5j0MrWc1fLjt5oqy0Y/dWI0dcrUEMLib381ez8pt2iKw/eDxIGs4FaD9 zT3ya0CGBNiFesFpWZmkGih/h7n4jjlbbbflR8Zm88eOeRA2PONa2YsypNMa3kDLBz jHMBlYCV/fMLink/FXE7umePqwK0EeggQeVUnUutnXsde7DvV4LATjGc4AhShHGCUS GTHzD12LidvPxU7AgKP4d/NtgT8GYAXaRkmCD3PQ048Yhl7oJY4fufnOxkPL7cqICW u5+0JfWCHqy0M8Z4tkp9j05/mW28ASobpYaksQxigjq7kay3NQINqPHIddxZCuOxDv BfjBmmFk7+jqA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 9066364E1F; Sat, 27 Dec 2025 13:44:30 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 27 Dec 2025 13:43:06 -0700 Message-ID: <20251227204318.886983-12-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: MHNW2OGZB6OSQWTSZD2LLS5NXYGCWDWW X-Message-ID-Hash: MHNW2OGZB6OSQWTSZD2LLS5NXYGCWDWW 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 , Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 11/16] ext4l: Add size() 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 Add ext4l_size() function to retrieve the size of a file or directory. Wire it into the filesystem operations table in fs_legacy.c. Signed-off-by: Simon Glass Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/interface.c | 14 ++++++++++++ fs/fs_legacy.c | 2 +- include/ext4l.h | 9 ++++++++ test/fs/ext4l.c | 34 +++++++++++++++++++++++++++++ test/py/tests/test_fs/test_ext4l.py | 7 ++++++ 5 files changed, 65 insertions(+), 1 deletion(-) diff --git a/fs/ext4l/interface.c b/fs/ext4l/interface.c index 409a3ff7edc..17648a59077 100644 --- a/fs/ext4l/interface.c +++ b/fs/ext4l/interface.c @@ -649,6 +649,20 @@ int ext4l_exists(const char *filename) return 1; } +int ext4l_size(const char *filename, loff_t *sizep) +{ + struct inode *inode; + int ret; + + ret = ext4l_resolve_path(filename, &inode); + if (ret) + return ret; + + *sizep = inode->i_size; + + return 0; +} + void ext4l_close(void) { if (ext4l_open_dirs > 0) diff --git a/fs/fs_legacy.c b/fs/fs_legacy.c index 849c0304668..5edc35c4cdb 100644 --- a/fs/fs_legacy.c +++ b/fs/fs_legacy.c @@ -267,7 +267,7 @@ static struct fstype_info fstypes[] = { .close = ext4l_close, .ls = ext4l_ls, .exists = ext4l_exists, - .size = fs_size_unsupported, + .size = ext4l_size, .read = fs_read_unsupported, .write = fs_write_unsupported, .uuid = fs_uuid_unsupported, diff --git a/include/ext4l.h b/include/ext4l.h index 23d53b30d9e..6fee701f335 100644 --- a/include/ext4l.h +++ b/include/ext4l.h @@ -46,6 +46,15 @@ int ext4l_ls(const char *dirname); */ int ext4l_exists(const char *filename); +/** + * ext4l_size() - Get the size of a file + * + * @filename: Path to file + * @sizep: Returns the file size + * Return: 0 on success, negative on error + */ +int ext4l_size(const char *filename, loff_t *sizep); + /** * ext4l_get_uuid() - Get the filesystem UUID * diff --git a/test/fs/ext4l.c b/test/fs/ext4l.c index 79813375ff1..f58a91893cc 100644 --- a/test/fs/ext4l.c +++ b/test/fs/ext4l.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -223,3 +224,36 @@ static int fs_test_ext4l_exists_norun(struct unit_test_state *uts) } FS_TEST_ARGS(fs_test_ext4l_exists_norun, UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL, { "fs_image", UT_ARG_STR }); + +/** + * fs_test_ext4l_size_norun() - Test ext4l_size function + * + * Verifies that ext4l_size correctly reports file size. + * + * Arguments: + * fs_image: Path to the ext4 filesystem image + */ +static int fs_test_ext4l_size_norun(struct unit_test_state *uts) +{ + const char *fs_image = ut_str(EXT4L_ARG_IMAGE); + loff_t size; + + 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)); + + /* Test root directory size - one block on a 4K block filesystem */ + ut_assertok(ext4l_size("/", &size)); + ut_asserteq(SZ_4K, size); + + /* Test file size - testfile.txt contains "hello world\n" */ + ut_assertok(ext4l_size("/testfile.txt", &size)); + ut_asserteq(12, size); + + /* Test non-existent path returns -ENOENT */ + ut_asserteq(-ENOENT, ext4l_size("/no/such/path", &size)); + + return 0; +} +FS_TEST_ARGS(fs_test_ext4l_size_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 890b6aeaef1..922fa37a7d8 100644 --- a/test/py/tests/test_fs/test_ext4l.py +++ b/test/py/tests/test_fs/test_ext4l.py @@ -103,3 +103,10 @@ class TestExt4l: output = ubman.run_command( f'ut -f fs fs_test_ext4l_exists_norun fs_image={ext4_image}') assert 'failures: 0' in output + + def test_size(self, ubman, ext4_image): + """Test that ext4l_size reports file size correctly.""" + with ubman.log.section('Test ext4l size'): + output = ubman.run_command( + f'ut -f fs fs_test_ext4l_size_norun fs_image={ext4_image}') + assert 'failures: 0' in output From patchwork Sat Dec 27 20:43:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1089 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=1766868282; bh=7EVVz5F6VrM/5Yd5DQj+1cqQkVvYsVpYJcgjbUwHyKo=; 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=wA8V5qzZdUv+BeRM418MKW9fm0aXGp1tpuSjGHOR6k/LcE8ZCpd76Yrj4WfX2lHNq +UNBx0pRyhm8fBD0bZKhwLwGFqVODta8wAXCzn/o7wqYjOfdbfwXpfVb1fBw2Dai+4 6hgncwF3itP06x0b/WDNSFMjvfzAcLskNVnOxOSPx07UM79JRiIiwZwmYCCiqYwHy3 CjnErGjA8ctcygXcNp2Efy/f9PQ5+XtaDakrUHuktmS2Pv+rq47dG0dd4/M0xr+ffF aBUvHIHyBDTmBOAoxKMLEKRXjkRUzg7tHsPjyuv3K2fW7g2cREhNrxhiEx3uUSubfe et8gOxf9zkuAQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0535B68BF3 for ; Sat, 27 Dec 2025 13:44:42 -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 WgFPFUy2PA-r for ; Sat, 27 Dec 2025 13:44:41 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868281; bh=7EVVz5F6VrM/5Yd5DQj+1cqQkVvYsVpYJcgjbUwHyKo=; 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=VxX52S+SxIxryhITfjV+YEtHPt+9ILWIYsvxoWQCmA52d/gitrqQ97oMDlul1s1mY 5oI070fN1Oh//FIIFv8b5NUu/Py3I/CAOWzQd4sGjOJTBAb9pc0lgTrbz3P5ouRrSS XJhQZsfPoCKZnbHPWo/7VcDF1qRz82VL6wYRmcRgnFG8UkvDmTRQ+kX9Gq1fH/jE+8 RSh2ADSazZol2USlJAqt1OK1gYio5oQQPdB8XRhT7sijCe5dGI/ScSJyivw8ULb3KL FcZzl5AVUeXHyA5okbQ3S8HfQxIeo9LkmcoefyQEogkxtljFfzH7cc94JSYvY1QciE KzVmZITsLVTHA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E976F64E4D for ; Sat, 27 Dec 2025 13:44:41 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868280; bh=PQKJKkVwzxIBH673tO5BbNZgvz/yVbJfFcs+DKkYigU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uqGRq5DrR87t4NMeprCV7XNt/xNR3fexd2rYNMkBoLxklx9bnNWfA/pvppTNktaoP M/DQf1rhi/ukoehZPLTBwcSHRJvvL6j09ESsEfOkl30CGl/k5lBUyIrLpOdI9pLTx/ KzmIjrYo7FqTY1sgtWgF3k5su4zXHQ124yBNaaa+IOzEaDDub+ZOOLv6Dy0MJEsGMP K+vQZNuzd3OXL5jxkOpqWJe2VLJQJO7biN1bkhmx+iuXAFKOpSjPieepJw/2yVFlOw g7u+umt+d3qPzYgxAF4rhBPDIFBNLNNrc2ksQHw8HRhDTmiQyIcHryiGfJmk9xKTpq MWD/m3QLmzpiA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id ED24964E49; Sat, 27 Dec 2025 13:44:40 -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 BmUDRNtTdqvC; Sat, 27 Dec 2025 13:44:40 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868276; bh=iYned3bvF4UHyQ/kvVEQeSJppe2yO/NswFvI1ZJ235o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tcIsbrH3q4xSjlegsR4IWUHAQRcMka51EEwTQPhRlMF+4p8H32Rdmx+Tq+hsGhCt9 A6g9IK5BRW8qi0Hhf6iXTp1/2GxrluDpICza7O3VmXjkk7l236jNo3hB1ow4DQeXvZ ABV/P9mvSVfYxD4N7He/TiRL09CyGmVcJKpy70Hb/Kr9XXp5MTcLiRm4aFZznr5E16 4QDo7mQFgKPSzE2aZ1MNuHoEyPdehANCJDV4N3c+raLPBh+9/eLdGpFVXqJ6jwF9ap hP/GRl982WQ5r9PdhABW650cA+MyiU0ySE0fnOWCuMmBYEtN8IEQUd0KD4ZDjkKrCo njz3dcMRxdDmA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 5F31E64E42; Sat, 27 Dec 2025 13:44:35 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 27 Dec 2025 13:43:07 -0700 Message-ID: <20251227204318.886983-13-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: PZWEZDOYLED57M44INXLNQ2P4KCQSCHU X-Message-ID-Hash: PZWEZDOYLED57M44INXLNQ2P4KCQSCHU 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 , Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 12/16] ext4l: Add read() 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 Add ext4l_read() function to read file contents. The function resolves the path to an inode, then reads the file block by block using ext4_bread() and copies the data to the output buffer. Signed-off-by: Simon Glass Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/interface.c | 64 +++++++++++++++++++++++++++++ fs/fs_legacy.c | 2 +- include/ext4l.h | 13 ++++++ test/fs/ext4l.c | 38 +++++++++++++++++ test/py/tests/test_fs/test_ext4l.py | 7 ++++ 5 files changed, 123 insertions(+), 1 deletion(-) diff --git a/fs/ext4l/interface.c b/fs/ext4l/interface.c index 17648a59077..34e659cd28b 100644 --- a/fs/ext4l/interface.c +++ b/fs/ext4l/interface.c @@ -663,6 +663,70 @@ int ext4l_size(const char *filename, loff_t *sizep) return 0; } +int ext4l_read(const char *filename, void *buf, loff_t offset, loff_t len, + loff_t *actread) +{ + uint copy_len, blk_off, blksize; + loff_t bytes_left, file_size; + struct buffer_head *bh; + struct inode *inode; + ext4_lblk_t block; + char *dst; + int ret; + + *actread = 0; + + ret = ext4l_resolve_path(filename, &inode); + if (ret) { + printf("** File not found %s **\n", filename); + return ret; + } + + file_size = inode->i_size; + if (offset >= file_size) + return 0; + + /* If len is 0, read the whole file from offset */ + if (!len) + len = file_size - offset; + + /* Clamp to file size */ + if (offset + len > file_size) + len = file_size - offset; + + blksize = inode->i_sb->s_blocksize; + bytes_left = len; + dst = buf; + + while (bytes_left > 0) { + /* Calculate logical block number and offset within block */ + block = offset / blksize; + blk_off = offset % blksize; + + /* Read the block */ + bh = ext4_bread(NULL, inode, block, 0); + if (IS_ERR(bh)) + return PTR_ERR(bh); + if (!bh) + return -EIO; + + /* Calculate how much to copy from this block */ + copy_len = blksize - blk_off; + if (copy_len > bytes_left) + copy_len = bytes_left; + + memcpy(dst, bh->b_data + blk_off, copy_len); + brelse(bh); + + dst += copy_len; + offset += copy_len; + bytes_left -= copy_len; + *actread += copy_len; + } + + return 0; +} + void ext4l_close(void) { if (ext4l_open_dirs > 0) diff --git a/fs/fs_legacy.c b/fs/fs_legacy.c index 5edc35c4cdb..27a2d7be220 100644 --- a/fs/fs_legacy.c +++ b/fs/fs_legacy.c @@ -268,7 +268,7 @@ static struct fstype_info fstypes[] = { .ls = ext4l_ls, .exists = ext4l_exists, .size = ext4l_size, - .read = fs_read_unsupported, + .read = ext4l_read, .write = fs_write_unsupported, .uuid = fs_uuid_unsupported, .opendir = ext4l_opendir, diff --git a/include/ext4l.h b/include/ext4l.h index 6fee701f335..643060ee44c 100644 --- a/include/ext4l.h +++ b/include/ext4l.h @@ -55,6 +55,19 @@ int ext4l_exists(const char *filename); */ int ext4l_size(const char *filename, loff_t *sizep); +/** + * ext4l_read() - Read data from a file + * + * @filename: Path to file + * @buf: Buffer to read data into + * @offset: Byte offset to start reading from + * @len: Number of bytes to read (0 = read entire file from offset) + * @actread: Returns actual bytes read + * Return: 0 on success, negative on error + */ +int ext4l_read(const char *filename, void *buf, loff_t offset, loff_t len, + loff_t *actread); + /** * ext4l_get_uuid() - Get the filesystem UUID * diff --git a/test/fs/ext4l.c b/test/fs/ext4l.c index f58a91893cc..1bea9186d5a 100644 --- a/test/fs/ext4l.c +++ b/test/fs/ext4l.c @@ -257,3 +257,41 @@ static int fs_test_ext4l_size_norun(struct unit_test_state *uts) } FS_TEST_ARGS(fs_test_ext4l_size_norun, UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL, { "fs_image", UT_ARG_STR }); + +/** + * fs_test_ext4l_read_norun() - Test ext4l_read function + * + * Verifies that ext4l can read file contents. + * + * Arguments: + * fs_image: Path to the ext4 filesystem image + */ +static int fs_test_ext4l_read_norun(struct unit_test_state *uts) +{ + const char *fs_image = ut_str(EXT4L_ARG_IMAGE); + loff_t actread; + char buf[32]; + + 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)); + + /* Read the test file - contains "hello world\n" (12 bytes) */ + memset(buf, '\0', sizeof(buf)); + ut_assertok(ext4l_read("/testfile.txt", buf, 0, 0, &actread)); + ut_asserteq(12, actread); + ut_asserteq_str("hello world\n", buf); + + /* Test partial read with offset */ + memset(buf, '\0', sizeof(buf)); + ut_assertok(ext4l_read("/testfile.txt", buf, 6, 5, &actread)); + ut_asserteq(5, actread); + ut_asserteq_str("world", buf); + + /* Verify read returns error for non-existent path */ + ut_asserteq(-ENOENT, ext4l_read("/no/such/file", buf, 0, 10, &actread)); + + return 0; +} +FS_TEST_ARGS(fs_test_ext4l_read_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 922fa37a7d8..4064a6c53ff 100644 --- a/test/py/tests/test_fs/test_ext4l.py +++ b/test/py/tests/test_fs/test_ext4l.py @@ -110,3 +110,10 @@ class TestExt4l: output = ubman.run_command( f'ut -f fs fs_test_ext4l_size_norun fs_image={ext4_image}') assert 'failures: 0' in output + + def test_read(self, ubman, ext4_image): + """Test that ext4l can read file contents.""" + with ubman.log.section('Test ext4l read'): + output = ubman.run_command( + f'ut -f fs fs_test_ext4l_read_norun fs_image={ext4_image}') + assert 'failures: 0' in output 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 From patchwork Sat Dec 27 20:43:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1091 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=1766868291; bh=qNSQJw0JNK7lEWGlRDJ3jQgTQUMZKw0hrPnD0o/cZXI=; 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=rPsYG3TiiMQeNXI6H6dnDFWJ5e5jsWEezwEAo55OtQIZggJ5qrrHb6ZMd71SxF5Ye YoI7RKoPNRHkpXmZ1tirwwjthve40kc9CZ7eV66bsloj28RBL1t92zevhhtei4gWAB 6iV1SNB1LUv9lizk/SVXjKa3OxwTgLIvUKpZI0My3iBJyiDSdcZ15hC9kAxRH6bR5J iBprwA8kt5cqUDUM6mXOxRKXFlFPQqOGrpJ2rNRH3iCV8rjXhD83NCewExzka+ONTF As8j8gshKBA5C+Lz1ocFx5ciJNzJshgs42C6kxW4nqnlDOF1Gj/zrJXCcRJi0h5myB imLNQauwq0qEg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1F20E68C3F for ; Sat, 27 Dec 2025 13:44:51 -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 V_wTObKBppJa for ; Sat, 27 Dec 2025 13:44:51 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868291; bh=qNSQJw0JNK7lEWGlRDJ3jQgTQUMZKw0hrPnD0o/cZXI=; 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=rPsYG3TiiMQeNXI6H6dnDFWJ5e5jsWEezwEAo55OtQIZggJ5qrrHb6ZMd71SxF5Ye YoI7RKoPNRHkpXmZ1tirwwjthve40kc9CZ7eV66bsloj28RBL1t92zevhhtei4gWAB 6iV1SNB1LUv9lizk/SVXjKa3OxwTgLIvUKpZI0My3iBJyiDSdcZ15hC9kAxRH6bR5J iBprwA8kt5cqUDUM6mXOxRKXFlFPQqOGrpJ2rNRH3iCV8rjXhD83NCewExzka+ONTF As8j8gshKBA5C+Lz1ocFx5ciJNzJshgs42C6kxW4nqnlDOF1Gj/zrJXCcRJi0h5myB imLNQauwq0qEg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0E72164E4D for ; Sat, 27 Dec 2025 13:44:51 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868289; bh=fNQOeu1i7uPtDJPh7QioG6tteHaVihVrKOFrVjOH0Bg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q/byhpBXZ8KieHR+PXq2BKspTIO+6DNuIiCoI0YKm2UOd+tO9VGyz2qTsl97WP96b jP+yGa8dDE238Gwby61yM8RZnx0XodDnj2k+/CqsVSzB4gHSXofTXBNnnU4wMk9Q7K DwQLGFUZZJ29uFDMrTGPu3E1nEgDNBVMsjBulW0/J2WsxGBPlpVp/k5kBuG18lelPk v9YrtAiIw57l4MNiVXKpeL1GToSxBFjhG4JVEIeCh4kt+tb4UDrx5lEEEMC6wdwJ/l 6PG9hBLy1X5OYOC33JfErDuelcf9LQsQvw8PV+IsIqK6ILCsx5JGHJxDF55BMJZmxP DCwAiq3KSN/vQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id ACE5064E1F; Sat, 27 Dec 2025 13:44:49 -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 Gb4oK-tKdSBQ; Sat, 27 Dec 2025 13:44:49 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868285; bh=5+UDK4uT2g0xoX4etoPaHgAClGbuzWzb7eUSKIsKP+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=blBtcuSOnO7bql3bQXeyydVLT+woU5f/AkaSnH2lu//IxkPWl/3oqczv7fOBWhfVM ammchPvoF7sFcZkNtfF3yB/fhxS5fl1wl33dQBYoOsSrDNuiFEhK8EHAxZs8dEqnla 3RPdduIHCMa2zciCRGNyDbeIc8BtObddpYTVhc4/4hzRmosQ6nRDfg49Wub1Pj0AA9 2TCzPMEQ3G1SUvTwmItjw+3JUa+Ktm3IcAUWRlRFy6WFC0+iJtIVzyWPsqlfNDaoPf rgTS7N/rNc28HUjy6hEDyOBTY/Dike3g2ikDW5AGKwrTeiXroLwWMeZ5RTxa3ExulR Hfl22/zG+F5FQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 3B2AB64C0C; Sat, 27 Dec 2025 13:44:45 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 27 Dec 2025 13:43:09 -0700 Message-ID: <20251227204318.886983-15-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: SV7DVW3GE2NUDKHWZFZ4DQB5B62I4Q34 X-Message-ID-Hash: SV7DVW3GE2NUDKHWZFZ4DQB5B62I4Q34 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 Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 14/16] fs: Add statfs method to the filesystem interface 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 Add infrastructure for obtaining filesystem statistics. This includes: - struct fs_statfs to hold block size, total blocks, and free blocks - statfs method in struct fstype_info - fs_statfs() wrapper function - fs_statfs_unsupported() stub for filesystems without support Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/fs_legacy.c | 37 +++++++++++++++++++++++++++++++++++++ include/fs_legacy.h | 21 +++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/fs/fs_legacy.c b/fs/fs_legacy.c index 71f8e56715f..e8a5f8d9672 100644 --- a/fs/fs_legacy.c +++ b/fs/fs_legacy.c @@ -154,6 +154,11 @@ static inline int fs_rename_unsupported(const char *old_path, return -1; } +static inline int fs_statfs_unsupported(struct fs_statfs *stats) +{ + return -1; +} + struct fstype_info { int fstype; char *name; @@ -195,6 +200,13 @@ struct fstype_info { int (*mkdir)(const char *dirname); int (*ln)(const char *filename, const char *target); int (*rename)(const char *old_path, const char *new_path); + + /* + * Get filesystem statistics. On success return 0 and fill stats + * with block size, total blocks, and free blocks. On error + * return -errno. See fs_statfs(). + */ + int (*statfs)(struct fs_statfs *stats); }; static struct fstype_info fstypes[] = { @@ -228,6 +240,7 @@ static struct fstype_info fstypes[] = { #else .rename = fs_rename_unsupported, #endif + .statfs = fs_statfs_unsupported, }, #endif @@ -256,6 +269,7 @@ static struct fstype_info fstypes[] = { .unlink = fs_unlink_unsupported, .mkdir = fs_mkdir_unsupported, .rename = fs_rename_unsupported, + .statfs = fs_statfs_unsupported, }, #endif #if CONFIG_IS_ENABLED(FS_EXT4L) @@ -278,6 +292,7 @@ static struct fstype_info fstypes[] = { .mkdir = fs_mkdir_unsupported, .ln = fs_ln_unsupported, .rename = fs_rename_unsupported, + .statfs = fs_statfs_unsupported, }, #endif #if IS_ENABLED(CONFIG_SANDBOX) && !IS_ENABLED(CONFIG_XPL_BUILD) @@ -298,6 +313,7 @@ static struct fstype_info fstypes[] = { .mkdir = fs_mkdir_unsupported, .ln = fs_ln_unsupported, .rename = fs_rename_unsupported, + .statfs = fs_statfs_unsupported, }, #endif #if CONFIG_IS_ENABLED(SEMIHOSTING) @@ -318,6 +334,7 @@ static struct fstype_info fstypes[] = { .mkdir = fs_mkdir_unsupported, .ln = fs_ln_unsupported, .rename = fs_rename_unsupported, + .statfs = fs_statfs_unsupported, }, #endif #ifndef CONFIG_XPL_BUILD @@ -339,6 +356,7 @@ static struct fstype_info fstypes[] = { .mkdir = fs_mkdir_unsupported, .ln = fs_ln_unsupported, .rename = fs_rename_unsupported, + .statfs = fs_statfs_unsupported, }, #endif #endif @@ -361,6 +379,7 @@ static struct fstype_info fstypes[] = { .mkdir = fs_mkdir_unsupported, .ln = fs_ln_unsupported, .rename = fs_rename_unsupported, + .statfs = fs_statfs_unsupported, }, #endif #endif @@ -384,6 +403,7 @@ static struct fstype_info fstypes[] = { .unlink = fs_unlink_unsupported, .mkdir = fs_mkdir_unsupported, .rename = fs_rename_unsupported, + .statfs = fs_statfs_unsupported, }, #endif #if IS_ENABLED(CONFIG_FS_EROFS) @@ -406,6 +426,7 @@ static struct fstype_info fstypes[] = { .unlink = fs_unlink_unsupported, .mkdir = fs_mkdir_unsupported, .rename = fs_rename_unsupported, + .statfs = fs_statfs_unsupported, }, #endif #if IS_ENABLED(CONFIG_FS_EXFAT) @@ -428,6 +449,7 @@ static struct fstype_info fstypes[] = { .unlink = exfat_fs_unlink, .mkdir = exfat_fs_mkdir, .rename = exfat_fs_rename, + .statfs = fs_statfs_unsupported, }, #endif #if CONFIG_IS_ENABLED(VIRTIO_FS) @@ -450,6 +472,7 @@ static struct fstype_info fstypes[] = { .unlink = fs_unlink_unsupported, .mkdir = fs_mkdir_unsupported, .rename = fs_rename_unsupported, + .statfs = fs_statfs_unsupported, }, #endif { @@ -469,6 +492,7 @@ static struct fstype_info fstypes[] = { .mkdir = fs_mkdir_unsupported, .ln = fs_ln_unsupported, .rename = fs_rename_unsupported, + .statfs = fs_statfs_unsupported, }, }; @@ -624,6 +648,19 @@ int fs_size(const char *filename, loff_t *size) return ret; } +int fs_statfs(struct fs_statfs *stats) +{ + int ret; + + struct fstype_info *info = fs_get_info(fs_type); + + ret = info->statfs(stats); + + fs_close(); + + return ret; +} + #if CONFIG_IS_ENABLED(LMB) /* Check if a file may be read to the given address */ static int fs_read_lmb_check(const char *filename, ulong addr, loff_t offset, diff --git a/include/fs_legacy.h b/include/fs_legacy.h index f1be6fbdc13..331a15cf7bd 100644 --- a/include/fs_legacy.h +++ b/include/fs_legacy.h @@ -172,6 +172,27 @@ struct fs_dirent *fs_readdir(struct fs_dir_stream *dirs); */ void fs_closedir(struct fs_dir_stream *dirs); +/** + * struct fs_statfs - filesystem statistics + * + * @bsize: block size + * @blocks: total blocks + * @bfree: free blocks + */ +struct fs_statfs { + ulong bsize; + u64 blocks; + u64 bfree; +}; + +/** + * fs_statfs - Get filesystem statistics + * + * @stats: pointer to struct fs_statfs to fill + * Return: 0 on success, -1 on error + */ +int fs_statfs(struct fs_statfs *stats); + /** * fs_unlink - delete a file or directory * From patchwork Sat Dec 27 20:43:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1092 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=1766868293; bh=cPyPZcBTQJFssAXUqtmcZ+UV9aOi2IkPF4W3UaRwGtQ=; 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=CgstXc28cWyYx/a09r60+SxVJlH6aQS6zfz3+hpLdcTpSeyCVYgW81hkjWJFEYQpU Uh+XQ2ZZaxvGlJkfFtW8SGDWiX9sGT2/VgtkBTFI+MO6ZaWioCFoKgjqRmfppWxU8h TdIpfMhQAy5LvI+X8m8uzDzjqJ633C09/HEsg2h37srjmUj1jWBEk61aFu/EQJH2iS BfTae2HwzcJ0TknahJ89sGMbkB86Q13/fhvG0CwLX/i5XfKyu4yYMpAZj5XEX5EzqC /U160Q+wzdf47T9tnTSvLRyu/x9XIHtGixRnN2xPsI/iDlqVKdIpDei7vLFBR72nCI xUMA0GQQlBFhg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7ADA268BEF for ; Sat, 27 Dec 2025 13:44:53 -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 EFLjFwL1J-x0 for ; Sat, 27 Dec 2025 13:44:53 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868292; bh=cPyPZcBTQJFssAXUqtmcZ+UV9aOi2IkPF4W3UaRwGtQ=; 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=r9/3RTb88WG81cfPj02duvKzqJ8pqe4Dyg6EaWvNBZMp2ShOO0MBbhSfXc8iH0cPz lhRsnoMuNqH0OoMxQlOEVgyPdeWANClW6vo2ppGbJFeEn+xZoLZiqp5gnhr5lL6NI0 CUArlyCMBBb00cXlozxxFaLcANavsgXJ/+6X+237aydcMtlfAemrjyKSbyNUo3DH06 CR08y8HZzaLUObLzWTfLhuZ6frYCIM8EafWqYWq+qbRn9K21353peIpgpsl1LbnBfq 5pAHYcyCgbNJ8GmBOWuBiy8gySxmfhSrmUy/ebOoXLgX+DJXgRiwUVCFEfPXvzaqjr RB+DU3Zh5utzw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7823264E4D for ; Sat, 27 Dec 2025 13:44:52 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868290; bh=jNvhJrpOUrg1Jz/w6BOx4erbOgrKo71H+6nPx1Gr1jY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YOJa2hnFw5U41zuOgiXjeLnBV6EWB10ch/geMqgoDJq1yyHI6EbWJAxDwjTCwTwxH gcck9oniP3O3zDRUW7fKrWSYqs9TlDpw6k/xqqU5MTw3PyTxw4HsffiJe5cVBINTzm y7iyz1sQte2qtUiS+5v/9Yt+KwbT1Xv4nWe2T8bihHzSe82gD5ytrgmHwV9zEpFQQf rgBTpYb3X8M+y86Bneg//Kcn4Eg6yBpJANfFSwMMGG5j8KoPCwLWDMh/9KNnoFpAS9 T/ZFC1Lq9iquO5Hkm9uezgIPc3ykwihc/XbTDG6nFj0z5QotoLsQzcA4aMtQdVCvzV BavZwgMtcbNsw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C6C1F64E44; Sat, 27 Dec 2025 13:44:50 -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 0b5VQrcFL0NY; Sat, 27 Dec 2025 13:44:50 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868290; bh=6KZKz+F78cDnrtuCAr4ZNOUeuCIaCRrMPL9sv/aZxXY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vLc7CtX9MUoxzM42dbd18i9V0dyxEj0/QBQWToMYJe4OZchouJte8jUYUoouLQEnx fQ2jaKRKCI/n2nHJgTcC4kGqe/Aob+dPXGyFBWPvqRc9M6WM68bEDMnG6NMyFCE6dB 0h4nrhTAf4sXwDF+uU0KuQfoiD7jQtsB4PWqG90zB96ZK9l8jGyrcgtfX0pav8QT5R Vh+0up5nU9rW1UeN6ySnmmU7lCgN18kfXevKgZZlTy+HeebjYdFu1c2NITy6yZvT/x nSDWFi03p93SK7L/gTHAwU6QRHv3ztInz/m1vJyLtvR8TJW3lf06V5QFyVuZTprZv/ LHYWoNWkccibQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id F1CFE64C0C; Sat, 27 Dec 2025 13:44:49 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 27 Dec 2025 13:43:10 -0700 Message-ID: <20251227204318.886983-16-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: 63J76PRGUWENAMWVCQOPIMJ7HSM2JU2V X-Message-ID-Hash: 63J76PRGUWENAMWVCQOPIMJ7HSM2JU2V 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 Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 15/16] cmd: Add fsinfo command 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 Add the fsinfo command to display filesystem statistics including block size, total blocks, used blocks, and free blocks. Both raw byte counts and human-readable sizes are shown. Example output: => fsinfo mmc 0:1 Block size: 4096 bytes Total blocks: 16384 (67108864 bytes, 64 MiB) Used blocks: 2065 (8458240 bytes, 8.1 MiB) Free blocks: 14319 (58650624 bytes, 55.9 MiB) Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- cmd/Kconfig | 10 ++++++ cmd/fs.c | 14 ++++++++ doc/usage/cmd/fsinfo.rst | 53 +++++++++++++++++++++++++++++ doc/usage/index.rst | 1 + fs/fs_legacy.c | 32 +++++++++++++++++ include/fs_cmd.h | 11 ++++++ test/fs/ext4l.c | 27 +++++++++++++++ test/py/tests/test_fs/test_ext4l.py | 7 ++++ 8 files changed, 155 insertions(+) create mode 100644 doc/usage/cmd/fsinfo.rst diff --git a/cmd/Kconfig b/cmd/Kconfig index 5cb34509746..d602f430ab6 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -2839,6 +2839,16 @@ config CMD_FS_UUID help Enables fsuuid command for filesystem UUID. +config CMD_FSINFO + bool "fsinfo command" + depends on !CMD_JFFS2 + default y if SANDBOX + help + Enables the fsinfo command which prints filesystem statistics + such as block size, total blocks, used blocks and free blocks. + This command conflicts with the JFFS2 fsinfo command, so it + cannot be enabled when JFFS2 support is enabled. + config CMD_LUKS bool "luks command" depends on BLK_LUKS diff --git a/cmd/fs.c b/cmd/fs.c index 7058f17b24f..960fd024c75 100644 --- a/cmd/fs.c +++ b/cmd/fs.c @@ -152,3 +152,17 @@ U_BOOT_CMD( " - renames/moves a file/directory in 'dev' on 'interface' from\n" " 'old_path' to 'new_path'" ); + +#ifdef CONFIG_CMD_FSINFO +static int do_fsinfo_wrapper(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + return do_fs_statfs(cmdtp, flag, argc, argv); +} + +U_BOOT_CMD(fsinfo, 3, 1, do_fsinfo_wrapper, + "Print filesystem information", + " \n" + " - Print filesystem statistics (block size, total/used/free blocks)" +); +#endif diff --git a/doc/usage/cmd/fsinfo.rst b/doc/usage/cmd/fsinfo.rst new file mode 100644 index 00000000000..5129a9a29b9 --- /dev/null +++ b/doc/usage/cmd/fsinfo.rst @@ -0,0 +1,53 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +.. index:: + single: fsinfo (command) + +fsinfo command +============== + +Synopsis +-------- + +:: + + fsinfo + +Description +----------- + +The fsinfo command displays filesystem statistics for a partition including +block size, total blocks, used blocks, and free blocks. Both raw byte counts +and human-readable sizes are shown. + +interface + interface for accessing the block device (mmc, sata, scsi, usb, ....) + +dev + device number + +part + partition number, defaults to 1 + +Example +------- + +:: + + => fsinfo mmc 0:1 + Block size: 4096 bytes + Total blocks: 16384 (67108864 bytes, 64 MiB) + Used blocks: 2065 (8458240 bytes, 8.1 MiB) + Free blocks: 14319 (58650624 bytes, 55.9 MiB) + +Configuration +------------- + +The fsinfo command is only available if CONFIG_CMD_FS_GENERIC=y. + +Return value +------------ + +The return value $? is set to 0 (true) if the command succeeded and to 1 +(false) otherwise. If the filesystem does not support statfs, an error +message is displayed. diff --git a/doc/usage/index.rst b/doc/usage/index.rst index bbea78a17b2..6c1414a0b84 100644 --- a/doc/usage/index.rst +++ b/doc/usage/index.rst @@ -81,6 +81,7 @@ Shell commands cmd/fdt cmd/font cmd/for + cmd/fsinfo cmd/fwu_mdata cmd/gpio cmd/gpt diff --git a/fs/fs_legacy.c b/fs/fs_legacy.c index e8a5f8d9672..efb5ab669ff 100644 --- a/fs/fs_legacy.c +++ b/fs/fs_legacy.c @@ -1105,6 +1105,38 @@ int do_fs_type(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return CMD_RET_SUCCESS; } +int do_fs_statfs(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) +{ + struct fs_statfs st; + u64 used; + int ret; + + if (argc != 3) + return CMD_RET_USAGE; + + if (fs_set_blk_dev(argv[1], argv[2], FS_TYPE_ANY)) + return 1; + + ret = fs_statfs(&st); + if (ret) { + printf("** Filesystem info not supported **\n"); + return CMD_RET_FAILURE; + } + + used = st.blocks - st.bfree; + printf("Block size: %lu bytes\n", st.bsize); + printf("Total blocks: %llu (%llu bytes, ", st.blocks, + st.blocks * st.bsize); + print_size(st.blocks * st.bsize, ")\n"); + printf("Used blocks: %llu (%llu bytes, ", used, used * st.bsize); + print_size(used * st.bsize, ")\n"); + printf("Free blocks: %llu (%llu bytes, ", st.bfree, + st.bfree * st.bsize); + print_size(st.bfree * st.bsize, ")\n"); + + return 0; +} + int do_rm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], int fstype) { diff --git a/include/fs_cmd.h b/include/fs_cmd.h index 3b58ad516e7..b28799d5ae4 100644 --- a/include/fs_cmd.h +++ b/include/fs_cmd.h @@ -80,4 +80,15 @@ int do_fs_type(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); */ int do_fs_types(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]); +/** + * do_fs_statfs - Get filesystem statistics. + * + * @cmdtp: Command information for fsinfo + * @flag: Command flags (CMD_FLAG\_...) + * @argc: Number of arguments + * @argv: List of arguments + * Return: result (see enum command_ret_t) + */ +int do_fs_statfs(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); + #endif diff --git a/test/fs/ext4l.c b/test/fs/ext4l.c index 02ad13ec71d..2641ac3678c 100644 --- a/test/fs/ext4l.c +++ b/test/fs/ext4l.c @@ -327,3 +327,30 @@ static int fs_test_ext4l_uuid_norun(struct unit_test_state *uts) } FS_TEST_ARGS(fs_test_ext4l_uuid_norun, UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL, { "fs_image", UT_ARG_STR }); + +/** + * fs_test_ext4l_fsinfo_norun() - Test fsinfo command + * + * This test verifies that the fsinfo command displays filesystem statistics. + * + * Arguments: + * fs_image: Path to the ext4 filesystem image + */ +static int fs_test_ext4l_fsinfo_norun(struct unit_test_state *uts) +{ + const char *fs_image = ut_str(EXT4L_ARG_IMAGE); + + ut_assertnonnull(fs_image); + ut_assertok(run_commandf("host bind 0 %s", fs_image)); + console_record_reset_enable(); + ut_assertok(run_commandf("fsinfo host 0")); + ut_assert_nextlinen("Block size:"); + ut_assert_nextlinen("Total blocks:"); + ut_assert_nextlinen("Used blocks:"); + ut_assert_nextlinen("Free blocks:"); + ut_assert_console_end(); + + return 0; +} +FS_TEST_ARGS(fs_test_ext4l_fsinfo_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 2bbbe766e6a..0a9da40f358 100644 --- a/test/py/tests/test_fs/test_ext4l.py +++ b/test/py/tests/test_fs/test_ext4l.py @@ -124,3 +124,10 @@ class TestExt4l: output = ubman.run_command( f'ut -f fs fs_test_ext4l_uuid_norun fs_image={ext4_image}') assert 'failures: 0' in output + + def test_fsinfo(self, ubman, ext4_image): + """Test that fsinfo command displays filesystem statistics.""" + with ubman.log.section('Test ext4l fsinfo'): + output = ubman.run_command( + f'ut -f fs fs_test_ext4l_fsinfo_norun fs_image={ext4_image}') + assert 'failures: 0' in output From patchwork Sat Dec 27 20:43:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1093 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=1766868297; bh=0oL/31OAUv0u1mnTlRa/hjpMBldR56yw9EM3E8q5dIU=; 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=HCvjtfj+ucvsIYqlvs2m8zeLwmcNfcCatNnoD+Yhvso2gv/eM/X+ZMLV9iSmihCDB muOf+AfVJO4QYbxahQYJS0gzSYu68wyJzNbFAUrd2SB18dJKgj7VfFxalOv2y8ss3F 1b/byE8O5rjurB4TkkKSNBokqDgNKx9Rdgfv+gFBE+E5Q/q4pWLTMqQwUvPL5ERVDB cebgK1H1MNz37qXJIU2olNKnZ69joUUpJps/MKrkMTL7ez5V7/EwVMKNUsaBxB72T1 KAzHv1BGqHykSdN/NWc9ISj1YVVrD1DB5aE3fz4nJvYRh7e9GyAveHYVO8bIUPuxaW bgWCO1fHMlDKg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EF8F164E55 for ; Sat, 27 Dec 2025 13:44:57 -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 Wegu6b82TuEx for ; Sat, 27 Dec 2025 13:44:57 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868297; bh=0oL/31OAUv0u1mnTlRa/hjpMBldR56yw9EM3E8q5dIU=; 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=HCvjtfj+ucvsIYqlvs2m8zeLwmcNfcCatNnoD+Yhvso2gv/eM/X+ZMLV9iSmihCDB muOf+AfVJO4QYbxahQYJS0gzSYu68wyJzNbFAUrd2SB18dJKgj7VfFxalOv2y8ss3F 1b/byE8O5rjurB4TkkKSNBokqDgNKx9Rdgfv+gFBE+E5Q/q4pWLTMqQwUvPL5ERVDB cebgK1H1MNz37qXJIU2olNKnZ69joUUpJps/MKrkMTL7ez5V7/EwVMKNUsaBxB72T1 KAzHv1BGqHykSdN/NWc9ISj1YVVrD1DB5aE3fz4nJvYRh7e9GyAveHYVO8bIUPuxaW bgWCO1fHMlDKg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DF0BE64E4E for ; Sat, 27 Dec 2025 13:44:57 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868295; bh=Eh0J5vousLyzGrGAins1x2GOrHEIBBlm69y+wPZmz3U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aesRhqC3oSklfvg7A3ihy9OoiYYbOX6OYmcPLZgYtrJIZlR056mb3m921O9kfHzhk D1JogBcjNTKJID+gmUdpdJZv/qlSDjb2WNHTmOcgs9Mjw3JvTI6O2vnjVpMPfKUfBP NFvsUJITCkWo7Kt3RuHn1T7ixziBnmnaEpkxRcLxb8ICU2Ytzn3pMc3Ig4r6ZPuJXD T7Vj6kpn+B3ebQV6km85uIZkxAS7gc72pzAGdk2qaM8ovrrH0NQixDlheH8tOqao5S aqROqmH1e1GMU31w5w6TT/Y3v7sM11TvVxYZMIgGhICrbT4ZRhGexSJ8cviqGYVnyL PhkoA02fZOxOQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C64EE64E1F; Sat, 27 Dec 2025 13:44:55 -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 ZM2qrDbChyN6; Sat, 27 Dec 2025 13:44:55 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766868291; bh=sPrYb+gZiN12gUu0VBHMC2gxGVIsqS9NNwxoc7aOSdE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ujFmhs48qGCuVYKvj+2mpFfod2wN321qxmroscryoBgkwE+6w6mae/pjZoHexrh78 kCGzCkY2N4Cd8JdYaIiKr3Oi8OZHmqeq1//3RE9J+f5odc3oeFfFv1lZePxt6TAE6P 7z6A5IfHfjyRbwK81Di3mcM26uY7YEfi8CPKNFc1K/rzrQ8rmFayzs6kLjoKZ/8CVq DjQ9KkBigR0vy6lwbPUwwqWeyRqRLfU9AFkhssu1FrEEXZacT0mh+T0WqHSxYE3w93 l4KrMzELwnucq1SRb8LJ5TZ6Asgefi3o3sS555pUhaDoXzrnWeEXSfIpGq2WIx9M01 abWky80YQPZqg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 1B68564C0C; Sat, 27 Dec 2025 13:44:51 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 27 Dec 2025 13:43:11 -0700 Message-ID: <20251227204318.886983-17-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: SHX7LPDBJDOZQCTSC4S3JG4WU4WMJNS7 X-Message-ID-Hash: SHX7LPDBJDOZQCTSC4S3JG4WU4WMJNS7 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 Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 16/16] fs: ext4l: Add statfs 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 Implement ext4l_statfs() to return filesystem statistics using the ext4 superblock. The function returns block size, total block count, and free block count. Add unit test to verify the statfs implementation returns valid data. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/interface.c | 22 ++++++++++++ fs/fs_legacy.c | 2 +- include/ext4l.h | 9 +++++ test/fs/ext4l.c | 52 ++++++++++++++++++++++++++--- test/py/tests/test_fs/test_ext4l.py | 7 ++++ 5 files changed, 86 insertions(+), 6 deletions(-) diff --git a/fs/ext4l/interface.c b/fs/ext4l/interface.c index f25664369e6..7c37c99488a 100644 --- a/fs/ext4l/interface.c +++ b/fs/ext4l/interface.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -100,6 +101,27 @@ int ext4l_uuid(char *uuid_str) return 0; } +/** + * ext4l_statfs() - Get filesystem statistics + * + * @stats: Pointer to fs_statfs structure to fill + * Return: 0 on success, -ENODEV if not mounted + */ +int ext4l_statfs(struct fs_statfs *stats) +{ + struct ext4_super_block *es; + + if (!ext4l_sb) + return -ENODEV; + + es = EXT4_SB(ext4l_sb)->s_es; + stats->bsize = ext4l_sb->s_blocksize; + stats->blocks = ext4_blocks_count(es); + stats->bfree = ext4_free_blocks_count(es); + + 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 efb5ab669ff..155092519dd 100644 --- a/fs/fs_legacy.c +++ b/fs/fs_legacy.c @@ -292,7 +292,7 @@ static struct fstype_info fstypes[] = { .mkdir = fs_mkdir_unsupported, .ln = fs_ln_unsupported, .rename = fs_rename_unsupported, - .statfs = fs_statfs_unsupported, + .statfs = ext4l_statfs, }, #endif #if IS_ENABLED(CONFIG_SANDBOX) && !IS_ENABLED(CONFIG_XPL_BUILD) diff --git a/include/ext4l.h b/include/ext4l.h index 9d9e79b7695..9cfe4867ffa 100644 --- a/include/ext4l.h +++ b/include/ext4l.h @@ -13,6 +13,7 @@ struct blk_desc; struct disk_partition; struct fs_dir_stream; struct fs_dirent; +struct fs_statfs; /** * ext4l_probe() - Probe a block device for an ext4 filesystem @@ -84,6 +85,14 @@ int ext4l_get_uuid(u8 *uuid); */ int ext4l_uuid(char *uuid_str); +/** + * ext4l_statfs() - Get filesystem statistics + * + * @stats: Pointer to fs_statfs structure to fill + * Return: 0 on success, -ENODEV if not mounted + */ +int ext4l_statfs(struct fs_statfs *stats); + /** * ext4l_opendir() - Open a directory for iteration * diff --git a/test/fs/ext4l.c b/test/fs/ext4l.c index 2641ac3678c..43801f252f7 100644 --- a/test/fs/ext4l.c +++ b/test/fs/ext4l.c @@ -331,7 +331,7 @@ FS_TEST_ARGS(fs_test_ext4l_uuid_norun, UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL, /** * fs_test_ext4l_fsinfo_norun() - Test fsinfo command * - * This test verifies that the fsinfo command displays filesystem statistics. + * Verifies that the fsinfo command displays filesystem statistics. * * Arguments: * fs_image: Path to the ext4 filesystem image @@ -339,18 +339,60 @@ FS_TEST_ARGS(fs_test_ext4l_uuid_norun, UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL, static int fs_test_ext4l_fsinfo_norun(struct unit_test_state *uts) { const char *fs_image = ut_str(EXT4L_ARG_IMAGE); + struct fs_statfs stats; + u64 used; 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)); + ut_assertok(ext4l_statfs(&stats)); + used = stats.blocks - stats.bfree; + console_record_reset_enable(); ut_assertok(run_commandf("fsinfo host 0")); - ut_assert_nextlinen("Block size:"); - ut_assert_nextlinen("Total blocks:"); - ut_assert_nextlinen("Used blocks:"); - ut_assert_nextlinen("Free blocks:"); + + /* Skip any EXT4-fs mount messages, check output format */ + ut_assert_skip_to_line("Block size: %lu bytes", stats.bsize); + ut_assert_nextlinen("Total blocks: %llu (%llu bytes,", + stats.blocks, stats.blocks * stats.bsize); + ut_assert_nextlinen("Used blocks: %llu (%llu bytes,", + used, used * stats.bsize); + ut_assert_nextlinen("Free blocks: %llu (%llu bytes,", + stats.bfree, stats.bfree * stats.bsize); ut_assert_console_end(); return 0; } FS_TEST_ARGS(fs_test_ext4l_fsinfo_norun, UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL, { "fs_image", UT_ARG_STR }); + +/** + * fs_test_ext4l_statfs_norun() - Test ext4l_statfs function + * + * Verifies that ext4l can return filesystem statistics. + * + * Arguments: + * fs_image: Path to the ext4 filesystem image + */ +static int fs_test_ext4l_statfs_norun(struct unit_test_state *uts) +{ + const char *fs_image = ut_str(EXT4L_ARG_IMAGE); + struct fs_statfs stats; + + 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 filesystem statistics */ + ut_assertok(ext4l_statfs(&stats)); + + /* Verify reasonable values for a 64MB filesystem */ + ut_asserteq(SZ_4K, stats.bsize); + ut_assert(stats.blocks > 0); + ut_assert(stats.bfree > 0); + ut_assert(stats.bfree <= stats.blocks); + + return 0; +} +FS_TEST_ARGS(fs_test_ext4l_statfs_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 0a9da40f358..754c2cc69c4 100644 --- a/test/py/tests/test_fs/test_ext4l.py +++ b/test/py/tests/test_fs/test_ext4l.py @@ -125,6 +125,13 @@ class TestExt4l: f'ut -f fs fs_test_ext4l_uuid_norun fs_image={ext4_image}') assert 'failures: 0' in output + def test_statfs(self, ubman, ext4_image): + """Test that ext4l can return filesystem statistics.""" + with ubman.log.section('Test ext4l statfs'): + output = ubman.run_command( + f'ut -f fs fs_test_ext4l_statfs_norun fs_image={ext4_image}') + assert 'failures: 0' in output + def test_fsinfo(self, ubman, ext4_image): """Test that fsinfo command displays filesystem statistics.""" with ubman.log.section('Test ext4l fsinfo'):