From patchwork Tue Dec 23 01:16:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1060 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=1766452608; bh=prWElSXKeaRTn4X6imPLZ8cPa1cy/SbbxO3PiwyyqGE=; 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=jq5MtE8QFqRJN3P+5sZIdg0rou7xfeQMrAV0z8yW1WpOrQneWelyfEqFp3yo4bpCj ErxaIZE32mcEF4NhBeYDnocer2pSMwU6gWG/H+qQkiUldxolfDB9jIas42uJOFzOZf XvvgmQaGE28VOAe44dahqdpy4gnROd4r31jJsehHMRw1lqRWpEIPtNULh3KdJVhJud sh35joLk62Ezs8tL88homzIUXm05kc7IneRNhRbFmwxFczVqWnOEUWkQ0UJCTCFCKC B1HapWqORceI5vQ2fJ/FlrcEoDfhH+XBDCxX8VmqPB/ZwbO0+kYllb2WqH8PsJ8QFP 6ItXwDPq+lYPA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 71F0864D70 for ; Mon, 22 Dec 2025 18:16:48 -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 Vk2wc-B4c7B5 for ; Mon, 22 Dec 2025 18:16:48 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452607; bh=prWElSXKeaRTn4X6imPLZ8cPa1cy/SbbxO3PiwyyqGE=; 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=KP/GeY4n+2pXTRtEsv8wCw18XYX/LSlGKCnPP+aHnLPd3R9qUZREeRQzdp/fEvT1Z 56Y6s2tFTox2v0vldJcQZyW2jS7Wab0o2yVB/Ze3qT67oqGDnavT8RwLA5+WKhSJEa Lf4Qt6ZnCc3a0BpqYhnQT0Km//JvnOOid8dSeaLXAimjMRQLEGNx9EEiBa7vLuz45h pMhaJiTeBgS5iZj6Xifm1dOgQF7Rb1Bll/o6JEwnoz+PYi3+3/cpwEiscbyI8Bd9to 2O50RoxNiXvqRzZuLQ7kwaYaTGMFip8Y7NnWfiD3rVo+FnoDqn2gYc0f1U2W3i4lK2 gatNUykdyjnbw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7E9C464DA7 for ; Mon, 22 Dec 2025 18:16:47 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452606; bh=enFV8DLDegbAjU96mMV44iSwY/tYLt+AiAgf0/yqKxM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kcpxb0kkD3Qn9B+UjjaC0ltBRdNO3epJFdfdmZR6hY5LUgvJqPWc30Qj5YHBo1XIB ERNW2rQbM9f+uXXm8P9k+cPyGs5iN4y+wK9XXS5wWzz6ZnwB5649pobqu/jjxN8K7x LxkFHennBKnEhWQQuvNB1lVUSPSGeQTJ+hIbvA54/4IxvL3WHG8OXRXr1OIIeSAsa+ Bw6vJ+z90s6EyI+sQTU9fbsqZ7GrRr38ENFUODr+x2NyXSKeaXhr1ME/tNH7CXE0zB rILoTDA1S7OXQMxnVkhromxiqUYWdMw9HD99S1LtLhduHnDoF0cbidzbEqqkM9mECc mjEJBG6jehaMQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 14B2864DAB; Mon, 22 Dec 2025 18:16: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 10026) with ESMTP id 4hvLmQF2Vpym; Mon, 22 Dec 2025 18:16:46 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452605; bh=yOHqucPO8k8Pu+EJs3dPafyYP2FfvwftN3h/XK+G0jg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bYD1aHZU8xM1YCQvSRO7ABQaskV+Wf1Y7nxWTd/24hmj+KwIdR6rXb0QykYjUWTgF VaQIHnWVCZoySrlXn1ewDyIlwawh9NdlwXrUedJt5UQzdiYTOF8lnJKGIvP5NxNI3v jEFyrMIEspqRtdg0vSvsmyACDI3ZFDAy3IkrvUBVP7xam6F37Mlt7mNQbVunUkJn6R kzvpm5nXedxfzvz47sz+ad1C5NLuzuxeEm/JnUzAVBYgFgMflwDd76N0bk3iszemb4 Q2rwoweElKy30PgCdnH5IyDVsLiu+h4yN2o6BgHGFjBR9Mbs79KUOYJ09fcF+QgAqo shSgEV4QI15UQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id CE20F64D95; Mon, 22 Dec 2025 18:16:44 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 22 Dec 2025 18:16:16 -0700 Message-ID: <20251223011632.380026-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251223011632.380026-1-sjg@u-boot.org> References: <20251223011632.380026-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: DMNYB6QDRGXXCYHDIYCYAH4YJLENBD37 X-Message-ID-Hash: DMNYB6QDRGXXCYHDIYCYAH4YJLENBD37 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: Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 01/12] ext4l: Fix format warning in mballoc.c 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 Fix format warning: atomic64_t.counter is 'long' on 32-bit systems, so cast to 'long long' for %lld format. Co-developed-by: Claude Signed-off-by: Simon Glass --- fs/ext4l/mballoc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/ext4l/mballoc.c b/fs/ext4l/mballoc.c index b58d72dfd26..6b0926a597b 100644 --- a/fs/ext4l/mballoc.c +++ b/fs/ext4l/mballoc.c @@ -3907,9 +3907,9 @@ void ext4_mb_release(struct super_block *sb) atomic_read(&sbi->s_bal_breaks), atomic_read(&sbi->s_mb_lost_chunks)); ext4_msg(sb, KERN_INFO, - "mballoc: %u generated and it took %llu", + "mballoc: %u generated and it took %lld", atomic_read(&sbi->s_mb_buddies_generated), - atomic64_read(&sbi->s_mb_generation_time)); + (long long)atomic64_read(&sbi->s_mb_generation_time)); ext4_msg(sb, KERN_INFO, "mballoc: %u preallocated, %u discarded", atomic_read(&sbi->s_mb_preallocated), From patchwork Tue Dec 23 01:16:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1061 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=1766452608; bh=g2zOTJhWsEQV6qhHYe5JG1iaoR+MkR/PIFNXZAbSc9I=; 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=uZuA4Ln+jjJ84hzeQqMk7AMnkkdk+WJVxhOVs0Z4WyJ+EYxEaTlOwT4y8dkwfnIiA KDWdpGfQy+d6pFMla3o8RtiCUdFWJ+NHls2UE/N6H0d4uohPJIEh4Td+jxEEWHv548 lLcbgrjJO8dyFlqECDUjfWhaBpuisIFeoR69MeE1+l5Dc67vHNcLotLuaZ5ZvtmdKI 73cylqY/zcFBcbflAAHkTZYAm6hz+GGmCTv4Rvv3NrfxWUcdOgKJ/yrvUDuBCGbefS C2AV0J/RR7d3G7ewVTeDqVUkcsqMbGYCKavyLQEFnaNt06b8jtJkDMUElN34/33m4t JYS6igHem2hDg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B820564DAC for ; Mon, 22 Dec 2025 18:16:48 -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 lSMD3GA49cUD for ; Mon, 22 Dec 2025 18:16:48 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452607; bh=g2zOTJhWsEQV6qhHYe5JG1iaoR+MkR/PIFNXZAbSc9I=; 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=dafl3454kLLF5rMV7FjwiH55ZV+NXWJH7Oq+xZSI1JwPFgWYgMabXbOyrsFZYe6NU UO6YnGTlmDJXvxq//z0McmFli5a7OtvOL6QeNHl+5YnKelMFnkBEPTcCRefy2q3cUQ CdPsKeL2scTsNkgLTghU5XrYIpSFvvYQi2K7x8j2QlMBriWlqHaawmOX+7Ch064cc9 83/9KWBE5unV9LA2UWNZDzrz+F2vslZIJE0bE5H89hWgEsEj4McgWCv+Z9eEgyFOyN z2hIZ/6y4p/87DMxBJfIwS5cpE3tKHLLN5ot4u1yeRiVd4JoEwCis/ThTUzaJPZeHZ Psq8MzWdiItuA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E46C764DB4 for ; Mon, 22 Dec 2025 18:16:47 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452606; bh=oR/2NKE7Xtt1H0P0ELs/G+MzVj3VMSi9IDRb0v0C5t0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hn1pVKn5gAYsK0+WX5ciI+Z6uUPKWBNiSQP+ixsQXzjWuBvCf3hg6BmW1MgDc0F7Q 2ForMF8bZpVsvROCQCR0C04hX4YXUaWHooGs9s8xA2XgQGpe6Updezv+fx8HPtpYT8 Q23fTJL0gtAn7+in1JCwQX22MtsnHxQpR6yZRyvBGyNESYFx6E2gGKU2CoOsKb6IZU mRQyOck2zS51LL/rCwBRWRQI8xm0kW8DIvIP1yWEhRJarRIl9epPnKr/3oApx2Xucb tkHtxOmOiB5+ddVc+KKnvTSjJ1xX2OU4WezK6LGpkRtXuRx1WLBnjYZkITunTPSuiP xcBJPdJ1Q9CBw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4950564DA7; Mon, 22 Dec 2025 18:16: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 10026) with ESMTP id N4nUwlW1YMl7; Mon, 22 Dec 2025 18:16:46 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452605; bh=3GyaWxH2MHCjoPlHc7+csPhHbmHC86xgw1z3TpXRuaw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jV9F78yswDN1xrQRqIVcvj7IAhVjDjHcX7wohUp0Wri8cMfOMLFWrp0XYjzkveENL ZG/04ucs2N0LMQqgO1UjZNIY0kK1JAjxi3gkfOfGrovwbuI/UZxijEFr3w23e2KOQO T3bng+q1sebHTY1I4ql5T37jQZxJbYwr2GRQ5Iy7TBDRTOa7S8Hp1//Ovk0vtzfPSy nZLpkONgdenvR1+zn1JU3X+Eig6JMHvCwKV3IajA4keff7dkX42G2i5AKM1VV3RgP3 nu9jqfronbvTYoqOMK0odrGax4VAslXV31HwYYJUkG2DLRI9E3g9Pj0VXjk+7ikXbT nateMGV7D+jXw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id A7BBE64DA9; Mon, 22 Dec 2025 18:16:45 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 22 Dec 2025 18:16:17 -0700 Message-ID: <20251223011632.380026-3-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251223011632.380026-1-sjg@u-boot.org> References: <20251223011632.380026-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 3YWWBKOR4ZPLKCSOWCTBSY3FLFVJRTYA X-Message-ID-Hash: 3YWWBKOR4ZPLKCSOWCTBSY3FLFVJRTYA 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: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 02/12] fs: ext4l: Mount filesystems read-write 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 Change sb_rdonly() to return 0 to allow read-write mounting. This enables the filesystem to be mounted without the read-only restriction. Signed-off-by: Simon Glass --- fs/ext4l/ext4_uboot.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 209f288f281..4dd03494586 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -289,8 +289,8 @@ extern struct user_namespace init_user_ns; /* might_sleep - stub */ #define might_sleep() do { } while (0) -/* sb_rdonly - for now U-Boot mounts filesystems read-only */ -#define sb_rdonly(sb) 1 +/* sb_rdonly - U-Boot mounts filesystems read-write */ +#define sb_rdonly(sb) 0 /* Trace stubs */ #define trace_ext4_journal_start_inode(...) do { } while (0) From patchwork Tue Dec 23 01:16:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1062 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=1766452611; bh=fv0WcbVAYZ4ZiJsmNNPFPUKS9rbqTLoqDaobvKC+Aow=; 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=JdJmdNuL4vmXmSuBVrjTnd/ohpiq8N35mcLMv5IZamCgoPjCljAlD0rYtAc7G+SyY cpLKoN99KGgG1YVkXxkM5hDQGniErphVYeN4JQScMBONkvcDaSkObcv+UBGQUgqLF0 5gJRnZR1Kp15jJZiAZUnRaUfc6BT5s+u+LdR9ddVqy02BdVUewi5XxsK0Se3YoO/7P gRPHx0+oBZK+qtuG3vaSkf8BnUSmwn5tiQdl6EitrOse389k+G93SME+SQ2LfK06+W /e4JqWQDdKfrah3nYXXdxie1HfxquvR6EqeU8HsEZockGpyI94pv6Z5WhqR/+6r/gq 8FSA18YmffmSw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6431664C17 for ; Mon, 22 Dec 2025 18:16: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 B9NO3Dd0oV1s for ; Mon, 22 Dec 2025 18:16:51 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452610; bh=fv0WcbVAYZ4ZiJsmNNPFPUKS9rbqTLoqDaobvKC+Aow=; 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=PWM0NKIc0+A59+0uobfBn+nOiSTjdHKs0M+vJsP+z6D4mEdTjZbFlxQx8gnFAetsp t4uCiJocBQDDVu5M6xzsXn4JknMFL4hJ4zVESnZNOB8MUKEix+oGucMbhRo4RGYYuv xsKw4JZVVv/r1kUtEGcdbyi60t1QPe597kjOw3kXyNKenlXhmRBIz2dbBe125+vvMJ ARjsNjccEHJBUdtWjX4wgcrSqQDT+S1Uf1zUREMm1BaTapcm1F6Hx1jsRv7n3vG5LA xdSopTU1KFzYV1X+aa2CdeUOcagXstwJ9xH/uBXpKIXTzMwQIBCC9g+VADKbMj0/qK SZCFu96GF+1Uw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5DC4264DA8 for ; Mon, 22 Dec 2025 18:16:50 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452608; bh=YG+Khfr4T7OmnAmzcJrVxGQQnhSn9GesK5o6/BIhsyc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s+oefkc4nmbvu0fIByMj4uwnGfB6m3+I32ZpIOKUe1OD/fZsboO4Dytlu1PG4Nhx8 lD1RRiHF4usP9B4Pgb8Z5ivG6WdDmQCpLb66i9W82QrZSh6xRqd9P/WS3elaLHU6Ax p62i4AVk2bWLu/GWrjd3IhtAqaIKxnG54iiZ2OywII/tmgnHId5jKb9qoMb7nmeVGq 1OQtnOpzPu3CM2QuG4pZNcgOCx7wMRQ/Hnm7G7j0HturcTUVnrkvGPDMJ8/NFmiSm5 Wq7l7l4zGxuzN6rASSbdx9d2WQvuMGH9r7wfUcFczHyzcPpmwN3V8Jt5eny8Qlx3ON gdQYrKw7s26fw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6038964DBC; Mon, 22 Dec 2025 18:16:48 -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 o64XWwBsgrZA; Mon, 22 Dec 2025 18:16:48 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452606; bh=ZDWs5zeSfL97vavAvRkxqjEOzSHk4J0uL8nsbtoXt34=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lrfd1xibjrJ4L+xw7bGPurIC0SfEguaiP67CZwZwU3mp0ofH75nfOE9QDne42O3nx 594gm8TPmUmWYxkampje3PUsrZe2o+uhyqron4AaPBSIwcZx1OwBFZyU9R6DCDQzew G3fviNiVr4vBwQEX28hwsXFWvHoH5CvgsCBryPZYtMYycno5gRNpTchVvwkP0CeBEW XtOk3YdaP3NZ8gXPCedTFUe4vhKoPvpx3SGtADNx2iXhB91wqFa/2mOkdfD88yh199 T2wHdDLA2KaGBIIRGm8L50dRRR02O2YvNwLQw871cpswsfw5D/HpM8Npp/GxVgd3JW 6qaAYcD+E/8PQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 61DC164DA9; Mon, 22 Dec 2025 18:16:46 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 22 Dec 2025 18:16:18 -0700 Message-ID: <20251223011632.380026-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251223011632.380026-1-sjg@u-boot.org> References: <20251223011632.380026-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: HOPFH3KSJGXXBA7Z6V45XIZT7Y7D2IUN X-Message-ID-Hash: HOPFH3KSJGXXBA7Z6V45XIZT7Y7D2IUN 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: Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 03/12] ext4l: Add write support and buffer mapping for mount 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_write_block() to enable writing blocks to disk, which is needed for ext4_commit_super() during read-write mounts. Also update submit_bh() to call the write function and return proper error codes. Set the BH_Mapped flag in sb_getblk() and bdev_getblk() since ext4 checks this flag in ext4_commit_super() to verify the buffer is valid. Co-developed-by: Claude Signed-off-by: Simon Glass --- fs/ext4l/ext4_uboot.h | 2 +- fs/ext4l/support.c | 55 +++++++++++++++++++++++++++++++++++++++---- 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 4dd03494586..6dd498c8f52 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -2150,7 +2150,7 @@ struct blockgroup_lock { }; /* Buffer submission stubs - declarations for stub.c implementations */ -void submit_bh(int op_flags, struct buffer_head *bh); +int submit_bh(int op_flags, struct buffer_head *bh); struct buffer_head *bdev_getblk(struct block_device *bdev, sector_t block, unsigned int size, gfp_t gfp); int trylock_buffer(struct buffer_head *bh); diff --git a/fs/ext4l/support.c b/fs/ext4l/support.c index 9e93426b565..05efa8d067c 100644 --- a/fs/ext4l/support.c +++ b/fs/ext4l/support.c @@ -352,6 +352,40 @@ int ext4l_read_block(sector_t block, size_t size, void *buffer) return 0; } +/** + * ext4l_write_block() - Write a block to the block device + * @block: Block number (filesystem block, not sector) + * @size: Block size in bytes + * @buffer: Source buffer + * Return: 0 on success, negative on error + */ +int ext4l_write_block(sector_t block, size_t size, void *buffer) +{ + struct blk_desc *blk_dev; + struct disk_partition *part; + lbaint_t sector; + lbaint_t sector_count; + unsigned long n; + + blk_dev = ext4l_get_blk_dev(); + part = ext4l_get_partition(); + if (!blk_dev) + return -EIO; + + /* Convert block to sector */ + sector = (block * size) / blk_dev->blksz + part->start; + sector_count = size / blk_dev->blksz; + + if (sector_count == 0) + sector_count = 1; + + n = blk_dwrite(blk_dev, sector, sector_count, buffer); + if (n != sector_count) + return -EIO; + + return 0; +} + /** * sb_getblk() - Get a buffer, using cache if available * @sb: Super block @@ -379,6 +413,9 @@ struct buffer_head *sb_getblk(struct super_block *sb, sector_t block) bh->b_bdev = sb->s_bdev; bh->b_size = sb->s_blocksize; + /* Mark buffer as having a valid disk mapping */ + set_buffer_mapped(bh); + /* Don't read - just allocate with zeroed data */ memset(bh->b_data, '\0', bh->b_size); @@ -474,6 +511,9 @@ struct buffer_head *bdev_getblk(struct block_device *bdev, sector_t block, bh->b_bdev = bdev; bh->b_size = size; + /* Mark buffer as having a valid disk mapping */ + set_buffer_mapped(bh); + /* Don't read - just allocate with zeroed data */ memset(bh->b_data, 0, bh->b_size); @@ -520,8 +560,9 @@ struct buffer_head *__bread(struct block_device *bdev, sector_t block, * submit_bh() - Submit a buffer_head for I/O * @op: Operation (REQ_OP_READ, REQ_OP_WRITE, etc.) * @bh: Buffer head to submit + * Return: 0 on success, negative on error */ -void submit_bh(int op, struct buffer_head *bh) +int submit_bh(int op, struct buffer_head *bh) { int ret; int op_type = op & 0xff; /* Mask out flags, keep operation type */ @@ -530,13 +571,19 @@ void submit_bh(int op, struct buffer_head *bh) ret = ext4l_read_block(bh->b_blocknr, bh->b_size, bh->b_data); if (ret) { clear_buffer_uptodate(bh); - return; + return ret; } set_buffer_uptodate(bh); } else if (op_type == REQ_OP_WRITE) { - /* Write support not implemented yet */ - clear_buffer_uptodate(bh); + ret = ext4l_write_block(bh->b_blocknr, bh->b_size, bh->b_data); + if (ret) { + clear_buffer_uptodate(bh); + return ret; + } + /* Mark buffer as clean (not dirty) after write */ } + + return 0; } /** From patchwork Tue Dec 23 01:16:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1063 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=1766452613; bh=6BurHZGWY2wP/vDuQGkvYL8xg8xaA6EAIZVVLf1wy3E=; 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=vped/mRG43r1CEGA2vQwoHMyPDefwh7cmNk/ThupvPVZUOccJi3J/5l26yiKhiW3h +Ba9dn61JpRR5sOgKxgo6+HIdXtBHskvbhF47PqfSdN7diiAn5YIDR4H77fsZL5iRK R0lT8eKDIJYei4YcWJ3D1X5zqciTZAVHEBH7QhBB36ZUTboSJBoS2nKQ4KRMA7GV0b IUD2cCGVu/yTV2OAewDuc+k7dSMDp6GGkQ1CzU5GSRaprJFcx6k7jpDg+x7PlNQdeI k9kz3hZikt1zHtiBnSDBr6RkVcprlrNk+Bym7KOPoDr7kTWvMxu4FvZ+TYpGquk2qD U+1JbNyFRDcRg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DBFE664D95 for ; Mon, 22 Dec 2025 18:16: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 xZvS_0rccG4s for ; Mon, 22 Dec 2025 18:16:53 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452612; bh=6BurHZGWY2wP/vDuQGkvYL8xg8xaA6EAIZVVLf1wy3E=; 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=C8EJtNv2Xn+UTyber2ZGUcTfRvRVCF5CypNc0/G3f/WzWSrnc1sgNLNn6IdB/XW8N wYY8CDsDPFoUDopG4qSg6yH+SVFK/2l6JRW7EZHTq22y661XnmTq8JZp+IfVxA/m9K gQoOFi5Qklhq6Pd/u2eA0fcvkif6mfzWy2NeNzZjH6BYqoXEFS7Lrd0q5mubC9//93 6HkFVKRDwfulyzDveB+4SqpfKrz1TIlC3M1ou//MYiZagP2B1ewBBCtJ/odvvukuRR JNymIxrUysQFBJ9lbg3etCu23QuHoolO4ZdGgkcuYKk6lE2D/c4r2HfjgSIE4uE2wk RkX3FfQn2OlLg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id ECA2564DA7 for ; Mon, 22 Dec 2025 18:16:52 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452611; bh=XWHAa+05OrpuVphynoUIilL1DbiorK0kELPfpWClsxo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HY2Qe+5ECOeiRsUYmzPiDqLsznVZprCPaD5AEkYfKKHCUP9JUU6R1B60s++BGb1ZN b7w9kWa4B4F2vnJ9U+S3qDLPgXxVc1RV+02HM1Jji3COVH40AfwtR7ilPzzU6lyFmt qYqTfYjP0hlcKMh3j11Fu5Gj4+bFV+t5GcKanTCtD8gmjKZxLj0jAgi0f2rkGQH3lL 8Pajmy56LYtxjVoeqnfEWtOzz/f0CgYRlf8zg6/p2kpCx0lFvz50Khb19FzIPsA2LH jtmISrSrr8mO6i0x9PtUMjOcGgYWFpwDvHTSKtwLnUNKc5G84lmWium97QfB0TdCp4 AQ/nXqPSJKxvw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4C42964DA7; Mon, 22 Dec 2025 18:16: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 10026) with ESMTP id 0RYwqjzL8SlD; Mon, 22 Dec 2025 18:16:51 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452607; bh=h2c9LXaRitX7FFAS1scNadc1/XEB7PUCxYlUy6Qpx5c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BhKupmwm8lXZyqna8zuI9dlATChygYNVbXPZhwP5UIQKPI7KnsyCGKMYD/rnWKczP aOD3kCAgHn5Z75h+Ff0cHbypiHOFHCkrE4WPe717nngzT9OF2XEgtbwKpNiGDvo+JR yAaZL+onxFkZPvda42CqUYtvvgS3mQIeLZ3HI4AgCRIyI/6t3QSReNn/nVYFfSLmZQ ZdcP9rB4D6qE1yS6FvMDGAhjn0BXdEekP3k/tLq5DMVJLVqdVZdKSpfx3XJ9T/tOPB W9obL4yFpWVEYeLdBEWRzTZqGwZG51XdUnusTxKbnCun5SX+jSGRRG6EwwC8MyYXoq MqFHPvQZXSrEA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 700A264C17; Mon, 22 Dec 2025 18:16:47 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 22 Dec 2025 18:16:19 -0700 Message-ID: <20251223011632.380026-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251223011632.380026-1-sjg@u-boot.org> References: <20251223011632.380026-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: CDD2VCT7ZFAJML4FFENLTWRY7NLWTEL7 X-Message-ID-Hash: CDD2VCT7ZFAJML4FFENLTWRY7NLWTEL7 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: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 04/12] ext4l: Use EXT4L_PRINTF to enable ext4 diagnostic messages 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 Enable EXT4L_PRINTF when CONFIG_EXT4L_DEBUG is set so that ext4_msg() and other diagnostic macros print full messages instead of empty strings. Use EXT4L_PRINTF instead of CONFIG_PRINTK since U-Boot requires CONFIG_ options to be defined in Kconfig. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/ext4.h | 2 +- fs/ext4l/ext4_uboot.h | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/fs/ext4l/ext4.h b/fs/ext4l/ext4.h index 5c37fcd76f9..b2f75437bbc 100644 --- a/fs/ext4l/ext4.h +++ b/fs/ext4l/ext4.h @@ -3237,7 +3237,7 @@ void __ext4_grp_locked_error(const char *, unsigned int, #define ext4_abort(sb, err, fmt, a...) \ __ext4_error((sb), __func__, __LINE__, true, (err), 0, (fmt), ## a) -#ifdef CONFIG_PRINTK +#ifdef EXT4L_PRINTF #define ext4_error_inode(inode, func, line, block, fmt, ...) \ __ext4_error_inode(inode, func, line, block, 0, fmt, ##__VA_ARGS__) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 6dd498c8f52..5c6e65b6e76 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -37,6 +37,17 @@ #include /* Real rbtree implementation */ #include /* For crc32() used by crc32_be */ +/* + * Enable ext4_msg() and other diagnostic macros to print full messages. + * This is needed for CONFIG_EXT4L_DEBUG to show useful error messages. + * + * Use EXT4L_PRINTF instead of CONFIG_PRINTK since U-Boot requires CONFIG_ + * options to be defined in Kconfig. + */ +#ifdef CONFIG_EXT4L_DEBUG +#define EXT4L_PRINTF 1 +#endif + /* * Override no_printk to avoid format warnings in disabled debug prints. * The Linux kernel uses sector_t as u64, but U-Boot uses unsigned long. From patchwork Tue Dec 23 01:16:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1064 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=1766452616; bh=K4W74nOznzmbyCzWPXEXjLi/vmRllYmcXfqZVqkh9LY=; 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=ukUN5a6mr4lnxItlPBUEbf4YK8dJ9lww+Az62GaurQmwiI2nld89VlP6vxE7YYv4u 2Op/5Ca11HwDLP0DZLTh4mCz4YOS5Rev78BbTUU9XmC6g9oIPmAw4/6VXjWOvHlmxd UgBib54F5pQK3l/iL+aRsCXlHW6T0L0HvBFtcTkETDb5xuWvTO/AQJHRM/gFtiyzZB qAgenvCUL0N3yJ6dQchFG0o9SoAb46KiaCEB6ez3PfdO6VQX7IZMdNsHhj90yMoDOi dswjGHtj4DNtRwLHNPBfG91D2pYJGaLdtQj35suj1EXASyjWyShJmQjb4BRmFijY0j fYFt3N0nwh/JA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8A0E864D8D for ; Mon, 22 Dec 2025 18:16:56 -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 rEnLTWA67yL7 for ; Mon, 22 Dec 2025 18:16:56 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452616; bh=K4W74nOznzmbyCzWPXEXjLi/vmRllYmcXfqZVqkh9LY=; 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=ukUN5a6mr4lnxItlPBUEbf4YK8dJ9lww+Az62GaurQmwiI2nld89VlP6vxE7YYv4u 2Op/5Ca11HwDLP0DZLTh4mCz4YOS5Rev78BbTUU9XmC6g9oIPmAw4/6VXjWOvHlmxd UgBib54F5pQK3l/iL+aRsCXlHW6T0L0HvBFtcTkETDb5xuWvTO/AQJHRM/gFtiyzZB qAgenvCUL0N3yJ6dQchFG0o9SoAb46KiaCEB6ez3PfdO6VQX7IZMdNsHhj90yMoDOi dswjGHtj4DNtRwLHNPBfG91D2pYJGaLdtQj35suj1EXASyjWyShJmQjb4BRmFijY0j fYFt3N0nwh/JA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 716B264D46 for ; Mon, 22 Dec 2025 18:16:56 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452613; bh=ADlK4B9YGfUBaJvrqWQLM25F8Nr2dPRmYqVPGGdSReQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bIkr9jrG1b0B1/h8riPtO8yve+dgZh8PMwFiu4VuXOHR/dcrX7bElGOXzzRFRmjLv xeXp1HWIvGnMlJS5UHw0rA79cjgiK/Cq5LTEHs6C83OrJBGyBDxUsvHI8VWCxnXelY tDsjDeJV5DotuwFGFJY+29r6WAaLIehBZx0FduXyGWvYVvqoetpckmkppOb+Yn6Lb3 waoU0+S9nr7srwO+Wu0ovDNakdMC/WarlToVL/k5KP7uI4AjM1tn/UKVS5daNvZ2OX IIOFhMixEbSZh2VA6DiKJNyV/tnUEyBI/NbBni2CtoXMhkTQaD09PRXGRIl8L7A8Uo n+wyPwpdlcteA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C2CAC64DAB; Mon, 22 Dec 2025 18:16: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 10026) with ESMTP id OYsFVmeEQtlj; Mon, 22 Dec 2025 18:16:53 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452608; bh=TlCxr3ICwi2Z0mOOHGwOGT1n4BbiktiKFJu5Ltku5ZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P1TdKYxBe/I7h6tbiNS60hsrtJk9MzBZMgP4ndHPl0ZTMWXMrmj1kA3zNInhrt2Z0 j7e/4inGWbJ7JDg0U2Ip+Ej0DxMAleQExQ3PmJtFcyDbMyKNnyDK7nBla+PjI0gtJJ 8y695h9y15LgO2BIc/5dmJ3zKkZvat8zF4HiVvUZnuUBkfQ1q1VvLKHEMt7xht8OK9 zsTSToIxwIbcl/woC1ZpyWQ3RDY3FKDcqhyE2Ym/+2hWrWwg+lr7JF6qbEsOAJr2pf 6P+admKiblrTkZqb0/iBaNktq4Va5b3kYYc+cznsgViL/iSO3Fe9CNciX2ug9w8Seu fcE2ifHXCcr/w== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 4540D64DBA; Mon, 22 Dec 2025 18:16:48 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 22 Dec 2025 18:16:20 -0700 Message-ID: <20251223011632.380026-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251223011632.380026-1-sjg@u-boot.org> References: <20251223011632.380026-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: UB6ASFU6ZMV3I2BHLIIYFWEJKQMQTGTD X-Message-ID-Hash: UB6ASFU6ZMV3I2BHLIIYFWEJKQMQTGTD 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: Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 05/12] ext4l: Document __CHAR_UNSIGNED__ behavior for directory hashing 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 documentation explaining how ext4's directory hash algorithm selection works based on the platform's char signedness. GCC automatically defines __CHAR_UNSIGNED__ on platforms where char is unsigned (e.g., ARM), which affects the hash algorithm used. The filesystem stores the hash variant in the superblock flags, ensuring correct operation regardless of the mounting platform. Co-developed-by: Claude Signed-off-by: Simon Glass --- fs/ext4l/ext4_uboot.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 5c6e65b6e76..4b7b5d02c82 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -48,6 +48,22 @@ #define EXT4L_PRINTF 1 #endif +/* + * __CHAR_UNSIGNED__ - directory hash algorithm selection + * + * The ext4 filesystem uses different hash algorithms for directory indexing + * depending on whether the platform's 'char' type is signed or unsigned. + * GCC automatically defines __CHAR_UNSIGNED__ on platforms where char is + * unsigned (e.g., ARM), and leaves it undefined where char is signed + * (e.g., x86/sandbox). + * + * The filesystem stores EXT2_FLAGS_UNSIGNED_HASH or EXT2_FLAGS_SIGNED_HASH + * in the superblock to record which hash variant was used when the filesystem + * was created, ensuring correct behavior regardless of the mounting platform. + * + * See super.c:5123 and ioctl.c:1489 for the hash algorithm selection code. + */ + /* * Override no_printk to avoid format warnings in disabled debug prints. * The Linux kernel uses sector_t as u64, but U-Boot uses unsigned long. From patchwork Tue Dec 23 01:16:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1065 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=1766452618; bh=FCRWYd2LiQw/qRCym0ufUWvBI7O0fnrGB9dYECp4ass=; 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=Qu+NFELRBjhpCdok2w9s6kdU2bWjHrSG0HBkOkWPNHXwees3r0dpnM1M3x5W0D6q0 4S6sM+CrNqGGJ9Xay0vAB2lQun+XE3R/Ku+79sxrsTCVNR8AqRj+LGC2MF9/zTWqhT PgJphliLWdiR2zeFLeabl7MtptjT6YbFPJYwePL12neoo8wSqLPHbXXyTzGXVW+qKQ 0S/mKJDvw/D4ewShplLtOBRMtlVt3OV3TFYwFaGkdKSnBoRqntkvf0ENhVGtITEq1P GSfRPkPuB38AdOGzTg3/szgIpwzr0j18+S5cz7nepVaniTJD9jPx4Ek4yad/hcR+1b K1lbOq7K0wS1g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4450464DB3 for ; Mon, 22 Dec 2025 18:16:58 -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 rBsPL2tKfwnH for ; Mon, 22 Dec 2025 18:16:58 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452618; bh=FCRWYd2LiQw/qRCym0ufUWvBI7O0fnrGB9dYECp4ass=; 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=Qu+NFELRBjhpCdok2w9s6kdU2bWjHrSG0HBkOkWPNHXwees3r0dpnM1M3x5W0D6q0 4S6sM+CrNqGGJ9Xay0vAB2lQun+XE3R/Ku+79sxrsTCVNR8AqRj+LGC2MF9/zTWqhT PgJphliLWdiR2zeFLeabl7MtptjT6YbFPJYwePL12neoo8wSqLPHbXXyTzGXVW+qKQ 0S/mKJDvw/D4ewShplLtOBRMtlVt3OV3TFYwFaGkdKSnBoRqntkvf0ENhVGtITEq1P GSfRPkPuB38AdOGzTg3/szgIpwzr0j18+S5cz7nepVaniTJD9jPx4Ek4yad/hcR+1b K1lbOq7K0wS1g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 19A2E64D45 for ; Mon, 22 Dec 2025 18:16:58 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452616; bh=ilSdrzho/2RfD3h5iCaybHEi2rvFYx4YN3thjQrVpe4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tm/gSLG3tUjRo/2fWL5x8DIWU+miRn0wWc4GEni1eEN6NPCW6rfq4cj3OfPT7eqdW rigQsUL/SI/gYODwEalFjvjXC3vN6ikpk8W6Wkx0cREq+sYsNSHUeSNEFKbAIeYeA/ 0+AKb/UzKiUYnOfrOpYTTZh8n7PbtNVwSUc7tgweOUAtwk0QiNbpbz5mSdLWxsKEiE oD39ceHxMY49GzZk+th4ffJa/DYI9h7HawF7WZSxkg4M/P2u8z/27upzfM6ncnscWb UAU8HoArSYlEHKBE5ho2JYPT+afxxCdrjzCvXTKwmyolC5fP2dUjJ42nG4fj7xFscw Z1+QRmAKnL+xQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2CC7C64D43; Mon, 22 Dec 2025 18:16:56 -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 ogf_myFak7qP; Mon, 22 Dec 2025 18:16:56 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452613; bh=7GsFbui91VG0KahIHgRRKSMcoxx3as8ge6t3y67/GBo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wma5jzbTnlrx833B1s9V+se0HHUyCb7/+Aw6foVM9NTSx8X08HZyjHeD8wCVe2UO3 h/jYARwtYms0CLjfL92SAXNuLUqUGUaGMpf9u8vfX6adlmYEhrC4VjBDefyr6I9muE Wd58sQImtjqJZMZPTug2iMT9A9vE9dIDMa57V8II/1kEMdCB6i23td9rp6s5dkvnZU AKgErQymq9RI+1BLa+ZvDMU12Qvsbzx6x4Q+GWgXDiZ/8p5e0fUaFVSza1Q5x3dqr0 H6mCyx/0kd4/KOs83qzDU86C0vcJ6DZBF8+4fxbjynOccyeyO9oybiN7zZJgTjXHkT reydB2nvkM0Tg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D5A7D64C17; Mon, 22 Dec 2025 18:16:52 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 22 Dec 2025 18:16:21 -0700 Message-ID: <20251223011632.380026-7-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251223011632.380026-1-sjg@u-boot.org> References: <20251223011632.380026-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: TZFF3SG2SD7MPDNC3U2QXPGAB75AOL3U X-Message-ID-Hash: TZFF3SG2SD7MPDNC3U2QXPGAB75AOL3U 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: Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 06/12] ext4l: Implement super_set_uuid() to display filesystem UUID 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 super_set_uuid() function was stubbed as a no-op, causing the filesystem UUID to display as all zeros during mount. Implement it to copy the UUID from the ext4 superblock to the VFS super_block structure. Before: mounted filesystem 00000000-0000-0000-0000-000000000000 r/w After: mounted filesystem d4ddb235-df85-4963-a923-7cddc5ad9355 r/w Add a way to read from tests as well. Co-developed-by: Claude Signed-off-by: Simon Glass --- fs/ext4l/ext4_uboot.h | 11 +++++++++-- fs/ext4l/interface.c | 13 +++++++++++++ include/ext4l.h | 7 +++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 4b7b5d02c82..4b019b77d27 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -2324,8 +2324,15 @@ unsigned int bdev_max_discard_sectors(struct block_device *bdev); /* Task I/O priority - declaration for stub.c */ void set_task_ioprio(void *task, int ioprio); -/* Superblock identity stubs */ -#define super_set_uuid(sb, uuid, len) do { } while (0) +/* Superblock identity functions */ +static inline void super_set_uuid(struct super_block *sb, const u8 *uuid, + unsigned len) +{ + if (len > sizeof(sb->s_uuid.b)) + len = sizeof(sb->s_uuid.b); + memcpy(sb->s_uuid.b, uuid, len); +} + #define super_set_sysfs_name_bdev(sb) do { } while (0) /* diff --git a/fs/ext4l/interface.c b/fs/ext4l/interface.c index 7360f44c92b..2ea3915c637 100644 --- a/fs/ext4l/interface.c +++ b/fs/ext4l/interface.c @@ -51,6 +51,19 @@ struct disk_partition *ext4l_get_partition(void) return &ext4l_partition; } +/** + * ext4l_get_uuid() - Get the filesystem UUID + * @uuid: Buffer to receive the 16-byte UUID + * Return: 0 on success, -ENODEV if not mounted + */ +int ext4l_get_uuid(u8 *uuid) +{ + if (!ext4l_sb) + return -ENODEV; + memcpy(uuid, ext4l_sb->s_uuid.b, 16); + return 0; +} + /** * ext4l_set_blk_dev() - Set the block device for ext4l operations * @blk_dev: Block device descriptor diff --git a/include/ext4l.h b/include/ext4l.h index 5a300fd6559..dead8ba8e6f 100644 --- a/include/ext4l.h +++ b/include/ext4l.h @@ -28,4 +28,11 @@ int ext4l_probe(struct blk_desc *fs_dev_desc, */ void ext4l_close(void); +/** + * ext4l_get_uuid() - Get the filesystem UUID + * @uuid: Buffer to receive the 16-byte UUID + * Return: 0 on success, -ENODEV if not mounted + */ +int ext4l_get_uuid(u8 *uuid); + #endif /* __EXT4L_H__ */ From patchwork Tue Dec 23 01:16:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1066 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=1766452622; bh=JFFkko+uh1XIIDZefPq3KMUR5J8TUeT1pK81kFUN1R4=; 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=KcqOY6IbDfN7hk5S7l0Gxjzc77ejUM36CfPXmYBLS5YBZocdByQ9FCWE31oHxCuTJ awwix1jIFW3wvo/1GQ9OZgnIdrP8C8dEOLn20yj47WLfGoWPk+2VgihCnzTgdkcIlK 3qytEz3a0p+nsjJ6tHXZKchcPdDJOfiA9oF+hM/z2EzgOj7ZzY9DLxqwBPjDGB3GcC /X5LSO0VLNxll6xKQByg4nStVovYOuJ4GZ5nMpy/JXJVGpYSAN1B811s0EzN1XQwBN DGVC3pe3dD2wBkZiLc4lYx1rqycOjfrcCD8VxRtrGnBBD84doeU8zWVaNNbBT8P+a0 6TZ/lRdJOaVYg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A007A64D95 for ; Mon, 22 Dec 2025 18:17: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 e679qq0JKelP for ; Mon, 22 Dec 2025 18:17:02 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452622; bh=JFFkko+uh1XIIDZefPq3KMUR5J8TUeT1pK81kFUN1R4=; 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=KcqOY6IbDfN7hk5S7l0Gxjzc77ejUM36CfPXmYBLS5YBZocdByQ9FCWE31oHxCuTJ awwix1jIFW3wvo/1GQ9OZgnIdrP8C8dEOLn20yj47WLfGoWPk+2VgihCnzTgdkcIlK 3qytEz3a0p+nsjJ6tHXZKchcPdDJOfiA9oF+hM/z2EzgOj7ZzY9DLxqwBPjDGB3GcC /X5LSO0VLNxll6xKQByg4nStVovYOuJ4GZ5nMpy/JXJVGpYSAN1B811s0EzN1XQwBN DGVC3pe3dD2wBkZiLc4lYx1rqycOjfrcCD8VxRtrGnBBD84doeU8zWVaNNbBT8P+a0 6TZ/lRdJOaVYg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8750B64D8D for ; Mon, 22 Dec 2025 18:17:02 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452620; bh=DDwGymGwBGzi9R0ONaWdZhhKa57NQwRwB1e1tkAsyQs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sPU5UqFUcXTDgUv+xLzrGz/4Bm2dE/ZD7/0/UotUJfKNxkOSTcYjMf1wIfJrO+Foy Xku4/h4GgOKO2f/yHqD0CtDHaiwCE6gaLvSH+R6y+KhnqlC3Q4RpHIRFN68Z1OE+HI qXleA3QVYXW+YObTcnF7718HUQq2WLpK9FnFJx78HQdxE8ICW/PSSsSh3btCHLHv+F OYMvXnGGFU7zHSjG8VSfnq49JoiJvIr0rGChlj8qRgFdhyrKppbTsNsZvsgKC4aOFJ PyYdVsEZvFBC0Nxb7/ciuYLDhJpozKR52K/HiHvJcdXDqfAv/MXuNoCdWi/PWY7X+3 VcCkmmv5BgulQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AED3A64D8D; Mon, 22 Dec 2025 18:17: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 5TYI6EikDwAo; Mon, 22 Dec 2025 18:17:00 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452614; bh=JTzDsWGEfKa/0zTFBnjNtuaLxBVQi+NIxI/bfRpf8X8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=feUrOFM270sGhhKbTbNNrMTd6V6ctmRJZfNuiv+wiH+4Jf15yIJlnLdKSVNBlc07R 1qTEhP0MZeNJJYY6mt5kxMjCUa6xfWOYjAKP1z2YDSHARBIhu4ShtgLeRt3mhhjWxT x3UuUiAuNuNnP+61Z7qzX4SRXFq6zky53CKD5l+bDy5PlzTqbdnp6Ueb1sAKeKHtLZ 8VYrMT/s4TDTZCTo8/k6hsQU8pnTR/h8CrwyLauGU0Ir9OCzLZKIBaH3qOMllLIc8A Uk45nZ2WUFLnSvhQ9lWh/I3LN+4A8oQFOVWejKRHeAs4kDFsKGbe3u5OCZvxw/gOg4 Pe3kgqqVhaHCQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id AE1DA64DB4; Mon, 22 Dec 2025 18:16:53 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 22 Dec 2025 18:16:22 -0700 Message-ID: <20251223011632.380026-8-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251223011632.380026-1-sjg@u-boot.org> References: <20251223011632.380026-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 35MI6MHT4T3GNKD4YRAX5666XJKL3O5R X-Message-ID-Hash: 35MI6MHT4T3GNKD4YRAX5666XJKL3O5R 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: Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 07/12] ext4l: Add message buffer to record ext4 messages 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 a 4KB membuf to record ext4 messages for later retrieval. This allows programmatic access to filesystem messages without requiring CONFIG_EXT4L_DEBUG to be enabled. - Add ext4l_msg_buf and ext4l_msg_data in interface.c - Add ext4l_record_msg() to record messages - Add ext4l_get_msg_buf() to access the buffer - Modify __ext4_msg() to always record messages, print only if debug Note that this increases the number of strings in the ext4l implementation. For production it might be useful to make this an option, although the messages can be quite important. Co-developed-by: Claude Signed-off-by: Simon Glass --- fs/ext4l/ext4_uboot.h | 9 +++++---- fs/ext4l/interface.c | 39 +++++++++++++++++++++++++++++++++++++++ fs/ext4l/super.c | 28 ++++++++++++++++++++-------- 3 files changed, 64 insertions(+), 12 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 4b019b77d27..116f0475217 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -38,15 +38,14 @@ #include /* For crc32() used by crc32_be */ /* - * Enable ext4_msg() and other diagnostic macros to print full messages. - * This is needed for CONFIG_EXT4L_DEBUG to show useful error messages. + * Enable ext4_msg() and other diagnostic macros to pass full messages. + * This is required for message recording to work. Without this, the + * ext4_msg macro passes empty strings to __ext4_msg(). * * Use EXT4L_PRINTF instead of CONFIG_PRINTK since U-Boot requires CONFIG_ * options to be defined in Kconfig. */ -#ifdef CONFIG_EXT4L_DEBUG #define EXT4L_PRINTF 1 -#endif /* * __CHAR_UNSIGNED__ - directory hash algorithm selection @@ -2864,6 +2863,8 @@ int ext4l_read_block(sector_t block, size_t size, void *buffer); /* ext4l interface functions (interface.c) */ struct blk_desc *ext4l_get_blk_dev(void); struct disk_partition *ext4l_get_partition(void); +void ext4l_record_msg(const char *msg, int len); +struct membuf *ext4l_get_msg_buf(void); #define sb_is_blkdev_sb(sb) ({ (void)(sb); 0; }) diff --git a/fs/ext4l/interface.c b/fs/ext4l/interface.c index 2ea3915c637..9b6f4c0b02b 100644 --- a/fs/ext4l/interface.c +++ b/fs/ext4l/interface.c @@ -10,6 +10,7 @@ */ #include +#include #include #include #include @@ -19,6 +20,9 @@ #include "ext4_uboot.h" #include "ext4.h" +/* Message buffer size */ +#define EXT4L_MSG_BUF_SIZE 4096 + /* Global state */ static struct blk_desc *ext4l_dev_desc; static struct disk_partition ext4l_part; @@ -31,6 +35,10 @@ static int ext4l_mounted; /* Global super_block pointer for filesystem operations */ static struct super_block *ext4l_sb; +/* Message recording buffer */ +static struct membuf ext4l_msg_buf; +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 @@ -91,6 +99,34 @@ void ext4l_clear_blk_dev(void) ext4l_mounted = 0; } +/** + * ext4l_msg_init() - Initialize the message buffer + */ +static void ext4l_msg_init(void) +{ + membuf_init(&ext4l_msg_buf, ext4l_msg_data, EXT4L_MSG_BUF_SIZE); +} + +/** + * ext4l_record_msg() - Record a message in the buffer + * @msg: Message string to record + * @len: Length of message + */ +void ext4l_record_msg(const char *msg, int len) +{ + membuf_put(&ext4l_msg_buf, msg, len); +} + +/** + * ext4l_get_msg_buf() - Get the message buffer + * + * Return: Pointer to the message buffer + */ +struct membuf *ext4l_get_msg_buf(void) +{ + return &ext4l_msg_buf; +} + int ext4l_probe(struct blk_desc *fs_dev_desc, struct disk_partition *fs_partition) { @@ -105,6 +141,9 @@ int ext4l_probe(struct blk_desc *fs_dev_desc, if (!fs_dev_desc) return -EINVAL; + /* Initialise message buffer for recording ext4 messages */ + ext4l_msg_init(); + /* Initialise CRC32C table for checksum verification */ ext4l_crc32c_init(); diff --git a/fs/ext4l/super.c b/fs/ext4l/super.c index 47e0b2c92e8..57653c8acb7 100644 --- a/fs/ext4l/super.c +++ b/fs/ext4l/super.c @@ -943,11 +943,9 @@ void __ext4_std_error(struct super_block *sb, const char *function, void __ext4_msg(struct super_block *sb, const char *prefix, const char *fmt, ...) { - struct va_format vaf; + char buf[256]; va_list args; - - if (!IS_ENABLED(CONFIG_EXT4L_DEBUG)) - return; + int len; if (sb) { atomic_inc(&EXT4_SB(sb)->s_msg_count); @@ -956,14 +954,28 @@ void __ext4_msg(struct super_block *sb, return; } + /* Format the message into a buffer */ va_start(args, fmt); - vaf.fmt = fmt; - vaf.va = &args; if (sb) - printk("%sEXT4-fs (%s): %pV\n", prefix, sb->s_id, &vaf); + len = snprintf(buf, sizeof(buf), "%sEXT4-fs (%s): ", + prefix, sb->s_id); else - printk("%sEXT4-fs: %pV\n", prefix, &vaf); + len = snprintf(buf, sizeof(buf), "%sEXT4-fs: ", prefix); + len += vsnprintf(buf + len, sizeof(buf) - len, fmt, args); va_end(args); + + /* Add newline if there's space */ + if (len < sizeof(buf) - 1) { + buf[len++] = '\n'; + buf[len] = '\0'; + } + + /* Record in message buffer */ + ext4l_record_msg(buf, len); + + /* Also print if debug is enabled */ + if (IS_ENABLED(CONFIG_EXT4L_DEBUG)) + printf("%s", buf); } static int ext4_warning_ratelimit(struct super_block *sb) From patchwork Tue Dec 23 01:16:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1067 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=1766452625; bh=N8n5IePwPHqKD/52Y4hVQ25rUUsvB4byhLs28zcdaY8=; 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=qmKoP258vm1bb8Mlpxwj/h9LiOwMhRo6XT9wBbC9yOo8boGbMV776bLThpn6nZBSa NFvNc9p3IsWIP2GvuPfAbECpnuJcbWNIikcnqA0nN0E9xfGE+Hb905B5mD4UOLN5o7 cuE3au+d1SWAARWXgEi10ywuONCFyzopaGrxjLlwc9DkTAGCN8QzTE8o+6BQ6wtnjq ddrYGWcERFAAz2W9zphjVqwWyVdbZ1umy1liD9JYlYG7tplUFzCY11GUzYVMJNl73X dGzCSXzY/HzTeon8KRpVvXh03mxzgmkCw0oQW8YjzLYm59NXr0aDy/GtywvLH9Asox xNECINvqH0R/A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 11FFD64DB3 for ; Mon, 22 Dec 2025 18:17:05 -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 T8t7deMNwKyF for ; Mon, 22 Dec 2025 18:17:05 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452623; bh=N8n5IePwPHqKD/52Y4hVQ25rUUsvB4byhLs28zcdaY8=; 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=qGg8pdkPddK9QqjGdOYBWNsVF7GycQ3mIiGKhGHOeoaJkRVT/REjQqB2nClnpdd/x 3A1y7WIkcUK3V9rVLOIGMzD4xgJ0a8yAUtsoeJH7GaZQU99k9iNkLMUOQoZ6OcVhZM de58YunyOS86gM1ofHxDlHzMHwDb9EzkgHlNUwi8vdxwLHcZyRoFi76/Nj8LHDvcQP hyplNRbvZvwJ60MbH2k8Wu65qBCSHblytLMtVSNQ9OB+eRsJ/Kxzyv0gyWr220Kxgv Gh4B41ZHUhsPBDTKXmYDYMvbefavxcnKAwTyZLAX12PWJ2mGKiJwuzR0IsI36m15BW MSuKeBFAe5mqw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0C51E64D46 for ; Mon, 22 Dec 2025 18:17:03 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452620; bh=BKMXKbV78/6Rwny5xDfZs42l3n9rWrQsegBU66Pn3VI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WQglS1I4Iozue8hzRSrKSlGqbvNgV21qxdrOuSVh1TjYrwiO8vHZmrZZelyha/A5J fQhvXQg5iWFGsOfExq5L5qDHgzFkgWHCqWX0ZpQNDAMfTRMwQheTi1ABxxKHhts/fG yrkktIyOMuVEgGFQtSwwrwr6BXcn2x+Vm6EQUZ/UVbDmrThhK/emJwDKjqbgv1MXGl nbHjHOWFjWIIHvBjjwreC2sDJcPxx+cFEzxc2Htnx81IDXDUsb0UR1YFN16DvGpqPf sizMNC79MEJ/w9NyY7Dm4QAvTP3RkXmqV6yOBUkXapA2IrJUaYxO2gDNdM7GRK8ME5 fTptOp/gDooRw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AED2D64D43; Mon, 22 Dec 2025 18:17: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 oyD0swT0Uxdq; Mon, 22 Dec 2025 18:17:00 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452618; bh=Y1xs808AGC6Ou99XXXYBzZHvfw3DHnHLsg/5C3RXdKY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z/tudUH9UJNnaYB0yiLuHC0dzXdZvl8sjrmzUzkjTlecRlZFjaSwHiu+WcymwwEnN YYAvFNs8v9YmN0UN4tORRcecWBraZPdntbkxPWNRYwib4oRiuCpjPzTLR1WdwvRBaH UYlGNqTKxmJ7hyR9KLOy0cNZGhtmSBmIZF/vsWeZXL/iLK3IVDFPu92/wupgVcDdbV tCEj95GnQLuckroL8BxDoIdJ0MqqY5V1yn7qW3ks2i7Bb4PT/ZPcJkQmDJMTiHKr2A AxRdiZklpPW5dFX8svyDRjxzReVnJL2GJwUKBULq+L7Y4JkxH6uOj/Ou216FasEGwR tLWFQXIJfTH1Q== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 2FB0264DA8; Mon, 22 Dec 2025 18:16:58 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 22 Dec 2025 18:16:23 -0700 Message-ID: <20251223011632.380026-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251223011632.380026-1-sjg@u-boot.org> References: <20251223011632.380026-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 7YGOPAGFDOC5LTVDRF3EHSQJELMDXUNR X-Message-ID-Hash: 7YGOPAGFDOC5LTVDRF3EHSQJELMDXUNR 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: Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 08/12] ext4l: Add ext4l_msgs env var to print messages on mount 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 runtime control for printing ext4 messages via the ext4l_msgs environment variable. When set to 'y' or '1', the recorded message buffer is printed after a successful mount. This provides a runtime alternative to the compile-time CONFIG_EXT4L_DEBUG option. Usage: setenv ext4l_msgs y Co-developed-by: Claude Signed-off-by: Simon Glass --- fs/ext4l/interface.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/fs/ext4l/interface.c b/fs/ext4l/interface.c index 9b6f4c0b02b..638f51d8c64 100644 --- a/fs/ext4l/interface.c +++ b/fs/ext4l/interface.c @@ -10,6 +10,7 @@ */ #include +#include #include #include #include @@ -127,6 +128,20 @@ struct membuf *ext4l_get_msg_buf(void) return &ext4l_msg_buf; } +/** + * ext4l_print_msgs() - Print all recorded messages + * + * Prints the contents of the message buffer to the console. + */ +static void ext4l_print_msgs(void) +{ + char *data; + int len; + + while ((len = membuf_getraw(&ext4l_msg_buf, 80, true, &data)) > 0) + printf("%.*s", len, data); +} + int ext4l_probe(struct blk_desc *fs_dev_desc, struct disk_partition *fs_partition) { @@ -263,6 +278,11 @@ int ext4l_probe(struct blk_desc *fs_dev_desc, /* Store super_block for later operations */ ext4l_sb = sb; + + /* Print messages if ext4l_msgs environment variable is set */ + if (env_get_yesno("ext4l_msgs") == 1) + ext4l_print_msgs(); + return 0; err_free_buf: From patchwork Tue Dec 23 01:16:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1068 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=1766452628; bh=fI8PC3r5CabF0DBzMTOwKRptHTHUmmSUlBNtlwk/QQI=; 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=OwwQpdCrmFKti639HvJLDlanAaHW4jrdx/f3YijmD3A21M2tzoP/gu5A0xRDGRbnZ YpFg6UTz1TMWjYCGDW27xxPLDQ3XY0mlw6o0QYaxYbL0oYIsaWbPBQXZJZXkk9dxmv oKNkYLDpLSK7dfZ8zYd3apb7SL7pYvoE+uBejMM03prD9ac+gdYMiHuNsXowupRSqC QjU5H5bLo2Omvsa6/MG4++MfktGOPsJhyH/0iyK7hhX9o3Y+6bCUm051nxgjxp8Lse BHUahFzI/M+nh+HGF6sSQU75opKAkMjoX5QjhsIeYmCuHBXbyDUFXfwYbZ6kr1xkTh 2uVbtMVLxQwKA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EBB4B64DA8 for ; Mon, 22 Dec 2025 18:17:08 -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 NRp50NwbaTyc for ; Mon, 22 Dec 2025 18:17:08 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452628; bh=fI8PC3r5CabF0DBzMTOwKRptHTHUmmSUlBNtlwk/QQI=; 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=OwwQpdCrmFKti639HvJLDlanAaHW4jrdx/f3YijmD3A21M2tzoP/gu5A0xRDGRbnZ YpFg6UTz1TMWjYCGDW27xxPLDQ3XY0mlw6o0QYaxYbL0oYIsaWbPBQXZJZXkk9dxmv oKNkYLDpLSK7dfZ8zYd3apb7SL7pYvoE+uBejMM03prD9ac+gdYMiHuNsXowupRSqC QjU5H5bLo2Omvsa6/MG4++MfktGOPsJhyH/0iyK7hhX9o3Y+6bCUm051nxgjxp8Lse BHUahFzI/M+nh+HGF6sSQU75opKAkMjoX5QjhsIeYmCuHBXbyDUFXfwYbZ6kr1xkTh 2uVbtMVLxQwKA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D9FB064D45 for ; Mon, 22 Dec 2025 18:17:08 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452627; bh=pCamRCFj57vR/hslN2+mtp4k/YCCFyFDSm9EqQiBAfU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eKuCA/Xas79I7NVjBv6NJKZPiLU1Y+IvTDDiA6e1eDohyxVe6cTK5xSrjx+a+qXH+ HR5uukS/PAZbcfVXep8Nb1dNj1+vFSto+GU9TBhB1jk3nu+AKmA4mj1IrPyYKKpmFm XKPoGpr2MkZerIzEUuhw4JSNNjs6iAoalvRp1/9J9/n0vqNtxxU4RiBEd7cAkOTkNp 6QrqqldPEAw/Yo+EcR5k82tt53Zm/WB5fV3coyaT5ENsIJGIgUs4LMXbMpy19OTPM0 TWxxrnN78fnna95TAEROOWqhgWPqzpfS0lQ7GqjC/5rin+hVFbWedYVEfkW6dQB+/L mIyqMAYWYBnnA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 737EA64D43; Mon, 22 Dec 2025 18:17:07 -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 0TrwdFecyfo6; Mon, 22 Dec 2025 18:17:07 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452619; bh=F/vMemnDjpfcrLRppGVo+CCMCDysI6A9bW9lqwZid6M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WHHVlzOXb5GizTSviECHPAVXidcM3K/qPfTHyvl9NEi2Dj/w4cHi0Ihl9q1i34pzi M4Y/GyM7ryqw8wDqWAK5MVEMv5PNKA4bYwWzy2njzjl+6keI/hzOyGS0K9V+DlHySC lsr+YxnrPb8GXBy9HYFrD7ZCSkzG/ax2UZr0DxVqoUr3M3aERrtPky3l1/3AwtyIvG lkTYsffnM4KvjEbRR/XUhxcIG2P3al7VP+SZAayLIkishq3oMHiG7/jYZA/taDKfTs 1dsUC+NFs3la/RA+Vtvfb4OWoD4EZVuQaOolxf4UG0irdcsP3vRcrwasnYD0dRInRA jlEyKM+1yQuCw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id F1F4D64D45; Mon, 22 Dec 2025 18:16:58 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 22 Dec 2025 18:16:24 -0700 Message-ID: <20251223011632.380026-10-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251223011632.380026-1-sjg@u-boot.org> References: <20251223011632.380026-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: VVTQRRT2LDK2ZGJTGPLU6TGZE3WEOQFG X-Message-ID-Hash: VVTQRRT2LDK2ZGJTGPLU6TGZE3WEOQFG 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: Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 09/12] test: fs: Add ext4l filesystem 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 Add initial tests for the ext4l filesystem driver: - fs_test_ext4l_probe_norun: verifies the driver can probe and mount an ext4 filesystem - fs_test_ext4l_msgs_norun: verifies the ext4l_msgs env var causes mount messages to be printed The C tests use UTF_MANUAL flag and accept fs_image argument, following the pattern established by fs_basic.c. The Python wrapper creates an ext4 image and calls the C tests. Co-developed-by: Claude Signed-off-by: Simon Glass --- test/fs/Makefile | 1 + test/fs/ext4l.c | 81 +++++++++++++++++++++++++++++ test/py/tests/test_fs/test_ext4l.py | 59 +++++++++++++++++++++ 3 files changed, 141 insertions(+) create mode 100644 test/fs/ext4l.c create mode 100644 test/py/tests/test_fs/test_ext4l.py diff --git a/test/fs/Makefile b/test/fs/Makefile index 5899be8e667..a8fd1227a1d 100644 --- a/test/fs/Makefile +++ b/test/fs/Makefile @@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0+ obj-y += fs_basic.o +obj-$(CONFIG_FS_EXT4L) += ext4l.o diff --git a/test/fs/ext4l.c b/test/fs/ext4l.c new file mode 100644 index 00000000000..e566c9e97b0 --- /dev/null +++ b/test/fs/ext4l.c @@ -0,0 +1,81 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Tests for ext4l filesystem (Linux ext4 port) + * + * Copyright 2025 Canonical Ltd + * Written by Simon Glass + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define EXT4L_ARG_IMAGE 0 /* fs_image: path to filesystem image */ + +/** + * fs_test_ext4l_probe_norun() - Test probing an ext4l filesystem + * + * This test verifies that the ext4l driver can successfully probe and + * mount an ext4 filesystem image. + * + * Arguments: + * fs_image: Path to the ext4 filesystem image + */ +static int fs_test_ext4l_probe_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)); + + return 0; +} +FS_TEST_ARGS(fs_test_ext4l_probe_norun, UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL, + { "fs_image", UT_ARG_STR }); + +/** + * fs_test_ext4l_msgs_norun() - Test ext4l_msgs env var output + * + * This test verifies that setting ext4l_msgs=y causes mount messages + * to be printed when probing an ext4 filesystem. + * + * Arguments: + * fs_image: Path to the ext4 filesystem image + */ +static int fs_test_ext4l_msgs_norun(struct unit_test_state *uts) +{ + const char *fs_image = ut_str(EXT4L_ARG_IMAGE); + char uuid_str[UUID_STR_LEN + 1]; + u8 uuid[16]; + + ut_assertnonnull(fs_image); + ut_assertok(env_set("ext4l_msgs", "y")); + console_record_reset_enable(); + ut_assertok(run_commandf("host bind 0 %s", fs_image)); + ut_assertok(fs_set_blk_dev("host", "0", FS_TYPE_ANY)); + + /* Get the UUID and clear the env var now we have the output */ + ut_assertok(ext4l_get_uuid(uuid)); + uuid_bin_to_str(uuid, uuid_str, UUID_STR_FORMAT_STD); + ut_assertok(env_set("ext4l_msgs", NULL)); + + /* + * Check messages. The probe test runs first and doesn't unmount, + * so the journal needs recovery. Verify both messages. + */ + 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(); + + return 0; +} +FS_TEST_ARGS(fs_test_ext4l_msgs_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 new file mode 100644 index 00000000000..3b206293cbc --- /dev/null +++ b/test/py/tests/test_fs/test_ext4l.py @@ -0,0 +1,59 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright 2025 Canonical Ltd +# Written by Simon Glass +# +# Test for ext4l filesystem driver + +""" +Test ext4l filesystem probing via C unit test. +""" + +import os +from subprocess import CalledProcessError, check_call + +import pytest + + +@pytest.mark.boardspec('sandbox') +class TestExt4l: + """Test ext4l filesystem operations.""" + + @pytest.fixture(scope='class') + def ext4_image(self, u_boot_config): + """Create an ext4 filesystem image for testing. + + Args: + u_boot_config (u_boot_config): U-Boot configuration. + + Yields: + str: Path to the ext4 image file. + """ + image_path = os.path.join(u_boot_config.persistent_data_dir, + 'ext4l_test.img') + try: + # Create a 64MB ext4 image + check_call(f'dd if=/dev/zero of={image_path} bs=1M count=64 2>/dev/null', + shell=True) + check_call(f'mkfs.ext4 -q {image_path}', shell=True) + except CalledProcessError: + pytest.skip('Failed to create ext4 image') + + yield image_path + + # Cleanup + if os.path.exists(image_path): + os.remove(image_path) + + def test_probe(self, ubman, ext4_image): + """Test that ext4l can probe an ext4 filesystem.""" + with ubman.log.section('Test ext4l probe'): + output = ubman.run_command( + f'ut -f fs fs_test_ext4l_probe_norun fs_image={ext4_image}') + assert 'failures: 0' in output + + def test_msgs(self, ubman, ext4_image): + """Test that ext4l_msgs env var produces mount messages.""" + with ubman.log.section('Test ext4l msgs'): + output = ubman.run_command( + f'ut -f fs fs_test_ext4l_msgs_norun fs_image={ext4_image}') + assert 'failures: 0' in output From patchwork Tue Dec 23 01:16:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1069 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=1766452631; bh=zI8PbI2YNBqPc7lPU4oKirYL2PBk4PZeV2IGvZDmP9Y=; 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=M8+P9iUaCdyUyI6RjjCsacoOT9BpP5sXSgXSkbLcfhmQ7PP0kzgZdGtpnc2SunURo FaBnhJTnujfYl4Erv62WYW0wkiXnDgLjxbZ0SXhUJlsAsh+25Nhm3r4fAfk2VE1N4k M8RzbytwHGrKL75RL9UP1RpGkSABHAz7ruBedQAtNIezhU7tmXD7ljRbvW8hkDgENT zWLhhGl7VONlIxPb7oPQioh7EUE86rbF2Le+pPpQjClY5gZV1IGRLCprTEFZ3OSIrS 8C6cpRgZy8/FUuK0H/1gh0iszRg9PollfLbViWQgvHew/zzN2CXYBLXF1t8riXHMJj XXsQ58pIoJbqg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 57CB064DC2 for ; Mon, 22 Dec 2025 18:17: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 W6eoM24NB-mW for ; Mon, 22 Dec 2025 18:17:11 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452630; bh=zI8PbI2YNBqPc7lPU4oKirYL2PBk4PZeV2IGvZDmP9Y=; 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=rA3Hi062orpqWCbKIyppLLpCLHP//l/2sB4YaDLhRWbYdYD8QLfFoHRNowhM8JoqJ zCvPSmK//uEEtm10czWvA6NY/GjUOGqIbrMSEaMOJEK1FrP8E4I5sOj/E8Wdws7IMB T1+oXVqKztz74laIgcf49XuXt6+ssQfgfkGdJaHimoBA6Ncgz3pUq46SkKLViKsMWf LAu8r0P88KNnP1vMr50YthooY9sFoQlLUdRbQyTaIvSo3ivP3MqjQSmw9HGOI3z6zL rb+oMMIoY/smW+Q3lYcwnCo8zwLFkul7OYRUFA4KCBwairwkqq73yPurJaA2dqDodd cCJp/ilC8tlSg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6F9C864D45 for ; Mon, 22 Dec 2025 18:17:10 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452627; bh=dRzzOI/Peepc7AWp25rUD8e8Ujni8sYznojtOtcLuIQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I0dVc8VffpmkfH1JjFDdNKaWOCRYIbNlWRpxofFgpE5WILNXklxLacOmRzU6fmKFF LWg/Y7CnWA6b66eZvnUwMuwnA5ybsqL6cIuKDYt4kU9jCfaxh4dMbdjf1cyXTzG8jI 8CmSlTQCZDcSKzEback3qqjpVW6BB93nbi777pC1vf7lBIBxdCctltlwapnPWo07kq rtIhOQAaK1wQcFZGtsgG4RidhSfz5C4zArMz+noEe8JVGqB0DN9LFqEyDCiaontB2V ivYCBr5mbtLf2kt6ZMk4mM9GS2haN9JGjf8vyDzCuYrDFZB3IpqXIVZn9oU5vIpsh2 EuaUHsIoMzi4w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F125564D45; Mon, 22 Dec 2025 18:17:07 -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 hkYm4JWhmG3r; Mon, 22 Dec 2025 18:17:07 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452623; bh=Jh6C3hC6lKDl1lgmRdnJFKhW+bKw0srCH8BeU/2W4OA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pTqSxhBQxKCCIdpEdUpX7BnScgsXxLipfQCf/gvjoVO8Uc+qeZHNaENBhN6I5V5yC mPSJTXwoJStjxSlM0L2GrJr1tEh+mkpoig0e78KguRCZ3HEWH/Jvga9RrrTEsAgMFj W1hFXcKfAVxF6JAABvpVQDTiJQy885jvFnpnxai8BKz5Ap2PYGywGNo+5sLjNnDNrD 2x89bJ85v0OPVqusQMv46EQj3PZTsiSrqhB7KktviTyw1JoaIyPJHw/vqIEpNY0Nv3 7su5W0CbIH5xML28Ci3hxIaQ8q2i/b2kD/1FJ+Mdsek8+FlU18hO2fHeEi24Zkh34m p8siY0g9AF8Ug== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 9C7F364DAC; Mon, 22 Dec 2025 18:17:03 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 22 Dec 2025 18:16:25 -0700 Message-ID: <20251223011632.380026-11-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251223011632.380026-1-sjg@u-boot.org> References: <20251223011632.380026-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 6Z7SVX4BUIOTRVMXNY4BDRMA4MYBJ3RW X-Message-ID-Hash: 6Z7SVX4BUIOTRVMXNY4BDRMA4MYBJ3RW 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: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 10/12] ext4l: Export ext4_readdir() for directory listing 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 Remove the static qualifier from ext4_readdir() so it can be called from the ext4l interface code for directory listing operations. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ext4l/dir.c b/fs/ext4l/dir.c index 9c4b853defa..c527847a300 100644 --- a/fs/ext4l/dir.c +++ b/fs/ext4l/dir.c @@ -122,7 +122,7 @@ int __ext4_check_dir_entry(const char *function, unsigned int line, return 1; } -static int ext4_readdir(struct file *file, struct dir_context *ctx) +int ext4_readdir(struct file *file, struct dir_context *ctx) { unsigned int offset; int i; From patchwork Tue Dec 23 01:16:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1070 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=1766452631; bh=32VEegwt5MfDxvKjrznz1d08ayIXoxTigp0wz2CGHC8=; 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=G/ntqR+vyWzDELNFtFVAy9ndzr45KZtegGgcr31LP0BDiy461suE79o76xZIsRePp YrD1HLvMvKF9mBmukgIYHD26NybexgPbFf9SWuzI6A8Vz8f4nfmyMd9RnIG6+lSIrr PSIH/6Xec4P5ItbAXPSqo5NIvpIRQlfB2yvedwYFFkiyd4++hhpq5GFBPB24XDcAD9 M8TGWEcIAXjubySDNn5C2idfjuXP98DJEH2WR9Coa00eKlWP1VzAnnstqACPRDVbVk qlWprGPnzHpEf1xMROk3w2YtvKbrhY6//1M0tcwf5eIZbPtcGgBDrH8+WhxZx4yZNt nNdt1+BYJFrpQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9B42C64DA9 for ; Mon, 22 Dec 2025 18:17: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 fyRzn3Vnt3Ym for ; Mon, 22 Dec 2025 18:17:11 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452630; bh=32VEegwt5MfDxvKjrznz1d08ayIXoxTigp0wz2CGHC8=; 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=L2WgarDnmT7hBakQD+rsV72JqZBEB+X/cBnuKOnbZFiNosATlI9ypMrAcID1Tn7hJ TwswpvhaAufP1BOqkJvlvlAGQnALqR2zXB2BagBBMMhihwB7JTrAP/vcYXpg5LnoT6 gEbksY1dfBz9iE5ehnGD9wtl8HcIuBVNj16w08VG7lPA7PRuM2PlZR1aWWdAorUXJi vCibaK+BidSzkT4cIBAFJdk+pJZH9STqghp9aBcdrmRhjJ+dkM8nQzJPr+tjoX2j6z futF/aVvnhO3HBinic/yJnBgQnLtycllTaLgNout2X4vPQSixnbX3Ot1XU7Uk1gheT dghFKuGQi4HuQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DE3E064DB3 for ; Mon, 22 Dec 2025 18:17:10 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452628; bh=WvrddjaA1rkQ9uHk3Ecmjrd0TiRW7xLjW8gxbZBhCjg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nmiCb2X7GKzVb5dOHYU6PGT1wwzdKiZ+PdP4Z00b8N7v7eB6TaHKEjUOBFKxpbUBs NvXbA6W+eBC261hyBBmca4d+tX3aDQJxCkPeCJGFXEV2Z4YFcF+u08gCgKYvWVULK6 R2tWhqXxq5RdWsPil+6FhubDYXIkpsD1/ZuxoNuLSTILKTFEj6ANub0PqMpTy/Kf82 oUYUdeDrQm/Nlgpikvy/cnblc/Vzi64O6BvnatBvXXQ8eeVsFRXiVMIP9O0HbSi1pu zwpz0yU5qaDGGzXQ/9KlTk1vwRfOEJ+vXBweam0uCznbL0DWK7/bPpnnFEqMQMM/dH 8bdXAkBcSn2VQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C029C64D43; Mon, 22 Dec 2025 18:17:08 -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 qUrQeyZDSSHg; Mon, 22 Dec 2025 18:17:08 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452628; bh=Pxlo5TRq25jHX33Dg8lpfYIAVicgF41GoBmHnGytOmA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dO3HTBMTZ4j4uHE8IQLBIifTntf9Np63F8tpqrkNLq1fh7FmF12Qqopfg+A88E2u5 3m68GzmzFgsOQw+YoUTHyVMIYXbCZfPSXKx2FIbqHKYzViJkncPhBTYChdDgueZ+hi sdASFOrgmU8o7Rfu5sYMWjUWPvg+6YVe9l3Z6REYgBUMi2P4fdkGRypH+o0+3Tv0Mp 4K0qnG3J9Ua1D98Afm3MYVPudjNc4phpTZuatdOBD8x1b/FLsL3fTJ9qbXZ6Usa6+L /0pjvS8Pr3Hlp4s05if96Opt7FzP7/kKEQAhYoyanv/JHtdGY6T/PXC2fYJlqRCUcY WtHgm6rHVapBA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 3A9F464C17; Mon, 22 Dec 2025 18:17:08 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 22 Dec 2025 18:16:26 -0700 Message-ID: <20251223011632.380026-12-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251223011632.380026-1-sjg@u-boot.org> References: <20251223011632.380026-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: O3EX4Z4DU2UQ6DWEKR5EDPUCBRWO3LTH X-Message-ID-Hash: O3EX4Z4DU2UQ6DWEKR5EDPUCBRWO3LTH 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: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 11/12] ext4l: Fix dir_emit() to call the actor callback 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 dir_emit() macro was stubbed to do nothing, which meant directory listing would never output any entries. Replace it with a proper inline function that calls ctx->actor() to emit each directory entry. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/ext4_uboot.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 116f0475217..52f479e9673 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -1703,8 +1703,12 @@ extern struct inode *iget_locked(struct super_block *sb, unsigned long ino); #define inode_eq_iversion(i, v) ({ (void)(i); (void)(v); 1; }) #define inode_query_iversion(i) ({ (void)(i); 0ULL; }) -/* Directory context operations */ -#define dir_emit(ctx, name, len, ino, type) ({ (void)(ctx); (void)(name); (void)(len); (void)(ino); (void)(type); 1; }) +/* Directory context operations - call the actor callback */ +static inline bool dir_emit(struct dir_context *ctx, const char *name, int len, + u64 ino, unsigned int type) +{ + return ctx->actor(ctx, name, len, ctx->pos, ino, type) == 0; +} #define dir_relax_shared(i) ({ (void)(i); 1; }) /* File llseek */ From patchwork Tue Dec 23 01:16:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1071 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=1766452635; bh=ytv3tf37ebiwzyWh+KpQVNZJa56M0SoW2sv+ABg9+bQ=; 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=TxYUTUIp8bzUMJFxszzxSx9mZuFj/L5jEWWrCZ2bz/HbbZv/YqYGxVgCfjtqT1KbB u4AR5fYdak5caZSY1EK7Gj40LYyvCkDwPWPA29gPw9jrkWFhSJ4Knv6VpvnHrYhkbD 3Wc2ip5pM21rgM16kxgv1/AsuojIDsn/7+NmpejAOHZ3i3IjPDW9Sylmz1v+j5c2/S BxioWM2atYRA6A3fnmnlhHD70Evqt8kv8pA4yx75wMfnhBuMTXF/S0ttXnqrJi3lJI EjfMhHRYs64DqCS7db5yVP5c1bslM5P4NvDWWqftEQpQ+1GhiWdlovxF6UwjupNNmA HcT4258j59l/w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5C61764D70 for ; Mon, 22 Dec 2025 18:17: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 10024) with ESMTP id k_QA2Lrd3CNQ for ; Mon, 22 Dec 2025 18:17:15 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452635; bh=ytv3tf37ebiwzyWh+KpQVNZJa56M0SoW2sv+ABg9+bQ=; 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=TxYUTUIp8bzUMJFxszzxSx9mZuFj/L5jEWWrCZ2bz/HbbZv/YqYGxVgCfjtqT1KbB u4AR5fYdak5caZSY1EK7Gj40LYyvCkDwPWPA29gPw9jrkWFhSJ4Knv6VpvnHrYhkbD 3Wc2ip5pM21rgM16kxgv1/AsuojIDsn/7+NmpejAOHZ3i3IjPDW9Sylmz1v+j5c2/S BxioWM2atYRA6A3fnmnlhHD70Evqt8kv8pA4yx75wMfnhBuMTXF/S0ttXnqrJi3lJI EjfMhHRYs64DqCS7db5yVP5c1bslM5P4NvDWWqftEQpQ+1GhiWdlovxF6UwjupNNmA HcT4258j59l/w== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4C36E64D45 for ; Mon, 22 Dec 2025 18:17:15 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452633; bh=J6s2QT0zhScURLQ13Nus3ff+Ob05y+/DCrHkj+FCe4Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i6q8pEJOz9ATWlQlFeONHJC8w4YXWUj/LnwRfGkh2Ckr2pswG/UkhalLTRHoQ6g57 8O80J4NA80VxvHV9gq5F/z28RFt4CcRCkCJT0yNb8QXNOTaGer46m8xGSQrrZER6hJ qeluW6CzB3O9cLSszhfUvmmh3XYjzht60feXT7uEbPCs5uxodaXCbfmaytZUDuHTez qLQGXjjPl7439+8FT8TosahrY48bq9hl31bQLbhPmHPvKQa5TtrTRkkaI28tEON4qT 4dxWGJmHl02n32tkJo2juiVHdKFPSH5umDU4gPUlsDJdXPj5qN3yHag95AyFv9VDUv XU5CTxyi7NfaQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DC48764D45; Mon, 22 Dec 2025 18:17: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 mcyOWwGea_XP; Mon, 22 Dec 2025 18:17:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766452629; bh=mLn6MulmMWTR+Psx3ZOSainqBC8dmDbW1X793m9zzMM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K748uky1JcfvlqSEzXgNc8PipOmVu4F2g3J5N4KNG5eTD9ij9JSortgiHNMzV9TsV Q2q3Isd06ACT+lyXqEO8ruuPGCq/XPjzEROAN0MxRkOWSzFfFCY1RC0GVrfN/k8XSh T8aH53OgzB4eeS303SJ2Ds+qbbRC0OwnSAKSXCh5BJG0nLpwK2hDybQ+OnV6afq4lb be3ge1lkPdh4yM9nRrgAmAF8u5EEdY+hx1qd9BzEDKdedQ/ytXN18uFOMEWf1McwLP iVQqTM7AkOIjNBHMcEHbtDskc7oAvkh77hoLvhWfkuDvX7cNIc3yMyBuyJWAMXg67S Or3aAiVLmVyaw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 104C264C17; Mon, 22 Dec 2025 18:17:09 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 22 Dec 2025 18:16:27 -0700 Message-ID: <20251223011632.380026-13-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251223011632.380026-1-sjg@u-boot.org> References: <20251223011632.380026-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: GOSAPNRMQA2CTGJSFBBSFCWZ2TJDIDRC X-Message-ID-Hash: GOSAPNRMQA2CTGJSFBBSFCWZ2TJDIDRC 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: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 12/12] ext4l: Add ls command 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 directory listing (ls) for the ext4l filesystem driver. This includes path resolution with symlink following (limited to 8 levels to prevent loops). Add ext4l_ls() which uses ext4_lookup() for path resolution and ext4_readdir() for directory enumeration. The dir_context actor callback formats and prints each directory entry. Export ext4_lookup() from namei.c and add declarations to ext4.h. Add test_ls to the Python test suite, which creates a test file using debugfs and verifies it appears in the directory listing with the correct size. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/ext4.h | 3 + fs/ext4l/interface.c | 321 ++++++++++++++++++++++++++++ fs/ext4l/namei.c | 2 +- fs/fs_legacy.c | 2 +- include/ext4l.h | 7 + test/fs/ext4l.c | 29 +++ test/py/tests/test_fs/test_ext4l.py | 19 ++ 7 files changed, 381 insertions(+), 2 deletions(-) diff --git a/fs/ext4l/ext4.h b/fs/ext4l/ext4.h index b2f75437bbc..1c2d5beb121 100644 --- a/fs/ext4l/ext4.h +++ b/fs/ext4l/ext4.h @@ -2857,6 +2857,9 @@ extern int ext4_htree_store_dirent(struct file *dir_file, __u32 hash, struct ext4_dir_entry_2 *dirent, struct fscrypt_str *ent_name); extern void ext4_htree_free_dir_info(struct dir_private_info *p); +extern int ext4_readdir(struct file *file, struct dir_context *ctx); +extern struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, + unsigned int flags); extern int ext4_find_dest_de(struct inode *dir, struct buffer_head *bh, void *buf, int buf_size, struct ext4_filename *fname, diff --git a/fs/ext4l/interface.c b/fs/ext4l/interface.c index 638f51d8c64..b897f30c223 100644 --- a/fs/ext4l/interface.c +++ b/fs/ext4l/interface.c @@ -302,6 +302,327 @@ err_exit_es: return ret; } +/** + * 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 + * Return: Length of target on success, negative on error + */ +static int ext4l_read_symlink(struct inode *inode, char *target, size_t max_len) +{ + struct buffer_head *bh; + size_t len; + + if (!S_ISLNK(inode->i_mode)) + return -EINVAL; + + if (ext4_inode_is_fast_symlink(inode)) { + /* Fast symlink: target stored in i_data */ + len = inode->i_size; + if (len >= max_len) + len = max_len - 1; + memcpy(target, EXT4_I(inode)->i_data, len); + target[len] = '\0'; + return len; + } + + /* Slow symlink: target stored in data block */ + bh = ext4_bread(NULL, inode, 0, 0); + if (IS_ERR(bh)) + return PTR_ERR(bh); + if (!bh) + return -EIO; + + len = inode->i_size; + if (len >= max_len) + len = max_len - 1; + memcpy(target, bh->b_data, len); + target[len] = '\0'; + brelse(bh); + + return len; +} + +/* Forward declaration for recursive resolution */ +static int ext4l_resolve_path_internal(const char *path, struct inode **inodep, + int depth); + +/** + * ext4l_resolve_path() - Resolve path to inode + * @path: Path to resolve + * @inodep: Output inode pointer + * Return: 0 on success, negative on error + */ +static int ext4l_resolve_path(const char *path, struct inode **inodep) +{ + return ext4l_resolve_path_internal(path, inodep, 0); +} + +/** + * 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) + * Return: 0 on success, negative on error + */ +static int ext4l_resolve_path_internal(const char *path, struct inode **inodep, + int depth) +{ + struct inode *dir; + struct dentry *dentry, *result; + char *path_copy, *component, *next_component; + int ret; + + /* Prevent symlink loops */ + if (depth > 8) + return -ELOOP; + + if (!ext4l_mounted) { + ext4_debug("ext4l_resolve_path: filesystem not mounted\n"); + return -ENODEV; + } + + dir = ext4l_sb->s_root->d_inode; + + if (!path || !*path || (strcmp(path, "/") == 0)) { + *inodep = dir; + return 0; + } + + path_copy = strdup(path); + if (!path_copy) + return -ENOMEM; + + component = path_copy; + /* Skip leading slash */ + if (*component == '/') + component++; + + while (component && *component) { + next_component = strchr(component, '/'); + if (next_component) { + *next_component = '\0'; + next_component++; + } + + if (!*component) { + component = next_component; + continue; + } + + /* Handle special directory entries */ + if (strcmp(component, ".") == 0) { + component = next_component; + continue; + } + if (strcmp(component, "..") == 0) { + /* Parent directory - look up ".." entry */ + dentry = kzalloc(sizeof(struct dentry), GFP_KERNEL); + if (!dentry) { + free(path_copy); + return -ENOMEM; + } + dentry->d_name.name = ".."; + dentry->d_name.len = 2; + dentry->d_sb = ext4l_sb; + dentry->d_parent = NULL; + + result = ext4_lookup(dir, dentry, 0); + if (IS_ERR(result)) { + kfree(dentry); + free(path_copy); + return PTR_ERR(result); + } + if (result && result->d_inode) { + dir = result->d_inode; + if (result != dentry) + kfree(dentry); + kfree(result); + } else if (dentry->d_inode) { + dir = dentry->d_inode; + kfree(dentry); + } else { + /* ".." not found - stay at root */ + kfree(dentry); + if (result && result != dentry) + kfree(result); + } + component = next_component; + continue; + } + + dentry = kzalloc(sizeof(struct dentry), GFP_KERNEL); + if (!dentry) { + free(path_copy); + return -ENOMEM; + } + + dentry->d_name.name = component; + dentry->d_name.len = strlen(component); + dentry->d_sb = ext4l_sb; + dentry->d_parent = NULL; + + result = ext4_lookup(dir, dentry, 0); + + if (IS_ERR(result)) { + kfree(dentry); + free(path_copy); + return PTR_ERR(result); + } + + if (result) { + if (!result->d_inode) { + if (result != dentry) + kfree(dentry); + kfree(result); + free(path_copy); + return -ENOENT; + } + dir = result->d_inode; + if (result != dentry) + kfree(dentry); + kfree(result); + } else { + if (!dentry->d_inode) { + kfree(dentry); + free(path_copy); + return -ENOENT; + } + dir = dentry->d_inode; + kfree(dentry); + } + + if (!dir) { + free(path_copy); + return -ENOENT; + } + + /* Check if this is a symlink and follow it */ + if (S_ISLNK(dir->i_mode)) { + char link_target[256]; + char *new_path; + + ret = ext4l_read_symlink(dir, link_target, + sizeof(link_target)); + if (ret < 0) { + free(path_copy); + return ret; + } + + /* Build new path: link_target + remaining path */ + if (next_component && *next_component) { + size_t target_len = strlen(link_target); + size_t remaining_len = strlen(next_component); + + new_path = malloc(target_len + 1 + + remaining_len + 1); + if (!new_path) { + free(path_copy); + return -ENOMEM; + } + strcpy(new_path, link_target); + strcat(new_path, "/"); + strcat(new_path, next_component); + } else { + new_path = strdup(link_target); + if (!new_path) { + free(path_copy); + return -ENOMEM; + } + } + + free(path_copy); + + /* Recursively resolve the new path */ + ret = ext4l_resolve_path_internal(new_path, inodep, + depth + 1); + free(new_path); + return ret; + } + + component = next_component; + } + + free(path_copy); + *inodep = dir; + return 0; +} + +/** + * ext4l_dir_actor() - Directory entry callback for ext4_readdir + * @ctx: Directory context + * @name: Entry name + * @namelen: Length of name + * @offset: Directory offset + * @ino: Inode number + * @d_type: Entry type + * Return: 0 to continue iteration + */ +static int ext4l_dir_actor(struct dir_context *ctx, const char *name, + int namelen, loff_t offset, u64 ino, + unsigned int d_type) +{ + struct inode *inode; + char namebuf[256]; + + /* Copy the name to a null-terminated buffer */ + if (namelen >= sizeof(namebuf)) + namelen = sizeof(namebuf) - 1; + memcpy(namebuf, name, namelen); + namebuf[namelen] = '\0'; + + /* Look up the inode to get file size */ + inode = ext4_iget(ext4l_sb, ino, 0); + if (IS_ERR(inode)) { + printf(" %8s %s\n", "?", namebuf); + return 0; + } + + if (d_type == DT_DIR || S_ISDIR(inode->i_mode)) + printf(" %s/\n", namebuf); + else if (d_type == DT_LNK || S_ISLNK(inode->i_mode)) + printf(" %s\n", namebuf); + else + printf(" %8lld %s\n", (long long)inode->i_size, namebuf); + + return 0; +} + +int ext4l_ls(const char *dirname) +{ + struct inode *dir; + struct file file; + struct dir_context ctx; + int ret; + + ret = ext4l_resolve_path(dirname, &dir); + if (ret) + return ret; + + if (!S_ISDIR(dir->i_mode)) + return -ENOTDIR; + + memset(&file, 0, sizeof(file)); + file.f_inode = dir; + file.f_mapping = dir->i_mapping; + + /* Allocate private_data for readdir */ + file.private_data = kzalloc(sizeof(struct dir_private_info), GFP_KERNEL); + if (!file.private_data) + return -ENOMEM; + + memset(&ctx, 0, sizeof(ctx)); + ctx.actor = ext4l_dir_actor; + + ret = ext4_readdir(&file, &ctx); + + if (file.private_data) + ext4_htree_free_dir_info(file.private_data); + + return ret; +} + void ext4l_close(void) { ext4l_dev_desc = NULL; diff --git a/fs/ext4l/namei.c b/fs/ext4l/namei.c index 7ef20d02235..53c48d12918 100644 --- a/fs/ext4l/namei.c +++ b/fs/ext4l/namei.c @@ -1746,7 +1746,7 @@ success: return bh; } -static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) +struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) { struct inode *inode; struct ext4_dir_entry_2 *de; diff --git a/fs/fs_legacy.c b/fs/fs_legacy.c index 5b96e1465d8..29b3ee83922 100644 --- a/fs/fs_legacy.c +++ b/fs/fs_legacy.c @@ -265,7 +265,7 @@ static struct fstype_info fstypes[] = { .null_dev_desc_ok = false, .probe = ext4l_probe, .close = ext4l_close, - .ls = fs_ls_unsupported, + .ls = ext4l_ls, .exists = fs_exists_unsupported, .size = fs_size_unsupported, .read = fs_read_unsupported, diff --git a/include/ext4l.h b/include/ext4l.h index dead8ba8e6f..e6ca11c163a 100644 --- a/include/ext4l.h +++ b/include/ext4l.h @@ -28,6 +28,13 @@ int ext4l_probe(struct blk_desc *fs_dev_desc, */ void ext4l_close(void); +/** + * ext4l_ls() - List directory contents + * @dirname: Directory path to list + * Return: 0 on success, negative on error + */ +int ext4l_ls(const char *dirname); + /** * ext4l_get_uuid() - Get the filesystem UUID * @uuid: Buffer to receive the 16-byte UUID diff --git a/test/fs/ext4l.c b/test/fs/ext4l.c index e566c9e97b0..122b022d8d8 100644 --- a/test/fs/ext4l.c +++ b/test/fs/ext4l.c @@ -79,3 +79,32 @@ static int fs_test_ext4l_msgs_norun(struct unit_test_state *uts) } FS_TEST_ARGS(fs_test_ext4l_msgs_norun, UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL, { "fs_image", UT_ARG_STR }); + +/** + * fs_test_ext4l_ls_norun() - Test ext4l ls command + * + * This test verifies that the ext4l driver can list directory contents. + * + * Arguments: + * fs_image: Path to the ext4 filesystem image + */ +static int fs_test_ext4l_ls_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("ls host 0")); + /* + * 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). + */ + ut_assert_skip_to_line(" 12 testfile.txt"); + ut_assert_console_end(); + + return 0; +} +FS_TEST_ARGS(fs_test_ext4l_ls_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 3b206293cbc..93b6d4d34e8 100644 --- a/test/py/tests/test_fs/test_ext4l.py +++ b/test/py/tests/test_fs/test_ext4l.py @@ -10,6 +10,7 @@ Test ext4l filesystem probing via C unit test. import os from subprocess import CalledProcessError, check_call +from tempfile import NamedTemporaryFile import pytest @@ -35,6 +36,17 @@ class TestExt4l: check_call(f'dd if=/dev/zero of={image_path} bs=1M count=64 2>/dev/null', shell=True) check_call(f'mkfs.ext4 -q {image_path}', shell=True) + + # Add a test file using debugfs (no mount required) + with NamedTemporaryFile(mode='w', delete=False) as tmp: + tmp.write('hello world\n') + tmp_path = tmp.name + try: + check_call(f'debugfs -w {image_path} ' + f'-R "write {tmp_path} testfile.txt" 2>/dev/null', + shell=True) + finally: + os.unlink(tmp_path) except CalledProcessError: pytest.skip('Failed to create ext4 image') @@ -57,3 +69,10 @@ class TestExt4l: output = ubman.run_command( f'ut -f fs fs_test_ext4l_msgs_norun fs_image={ext4_image}') assert 'failures: 0' in output + + def test_ls(self, ubman, ext4_image): + """Test that ext4l can list directory contents.""" + with ubman.log.section('Test ext4l ls'): + output = ubman.run_command( + f'ut -f fs fs_test_ext4l_ls_norun fs_image={ext4_image}') + assert 'failures: 0' in output