From patchwork Fri Jan 2 00:50:31 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1165 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=1767315090; bh=XR00dczz4DEaF4edATUYXdvXMmbhUgZITYaU9FxXigU=; 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=E5ghq19qgh+68IPBRSmwHLOlHxrrOrj3cRoI7q8kYHqUxIFgGHkkLFwKBl1HVAc0W WWlt1ze9/d89VvSKEQhcgDR3rgWEM4vOKlYN5hbjn9HsKqFGFWGEKqyA/g3qj2lJ4a MEnChok7DtNGgA2vuQ16dWeC2xb6Lu++v5jCDR4WxMbTKzt3/QiGPH+QPTomfYkjJt oPlm9yh6vjABuC7JAYnJ5GQFyeyD8lQBkitJ7bJ7ew3vjQrXsOCD6uR6/mWuOS/Six nNMTN2Q25a7EomfzgnmCm1zuiHHOA2rqkEAt/KiDE6EMv2qXb1ib96+91miPBN+d3h 2CtvcDiz6ooTA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6BD2B6900A for ; Thu, 1 Jan 2026 17:51:30 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id w76Si7uWdPTL for ; Thu, 1 Jan 2026 17:51:30 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315090; bh=XR00dczz4DEaF4edATUYXdvXMmbhUgZITYaU9FxXigU=; 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=E5ghq19qgh+68IPBRSmwHLOlHxrrOrj3cRoI7q8kYHqUxIFgGHkkLFwKBl1HVAc0W WWlt1ze9/d89VvSKEQhcgDR3rgWEM4vOKlYN5hbjn9HsKqFGFWGEKqyA/g3qj2lJ4a MEnChok7DtNGgA2vuQ16dWeC2xb6Lu++v5jCDR4WxMbTKzt3/QiGPH+QPTomfYkjJt oPlm9yh6vjABuC7JAYnJ5GQFyeyD8lQBkitJ7bJ7ew3vjQrXsOCD6uR6/mWuOS/Six nNMTN2Q25a7EomfzgnmCm1zuiHHOA2rqkEAt/KiDE6EMv2qXb1ib96+91miPBN+d3h 2CtvcDiz6ooTA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 58C0C69007 for ; Thu, 1 Jan 2026 17:51:30 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315088; bh=SpHXFCS19YhSqFkK//vdUcTvtUBL4uTyJuaGmHTS/es=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vZn8s3FRDZzmTBloyyQB631+Twhx3PFLcNZbuhe7/sAtqcNefa2uehEHvoLswWoHe zEZKhsRk4Szv7tc1lUKkmRD55nXTWuywvcLXHGmXtPfeEqufDRvxVRniwwr4XBMQp4 UVApylSk6mr370MpYNxg/pORsuvy5XaU+CqNFctHezBN8133atPepT+dHq0ceg8Vvb tDPArs5go697s+GT6+Y6R7e8mdwH9rpiwLS7XDiy63kKdieb9ydyGRBrSj61cCxMlT eJFOtE1Jg2iigd1vke+VQekoVMPE2KayF7UiLk8pQOqhWCQ7He2FwG7n4QVa/IOS0c iLSC0ev7Rp8fQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B15F068F58; Thu, 1 Jan 2026 17:51:28 -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 83IYD_7tcKi9; Thu, 1 Jan 2026 17:51:28 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315084; bh=dOSEzSGMbleVCKqmk5BM9qMRy6INtUjwYJvoOTQBVRw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e+yIKWaPI2wYLiwD98PdjJrA8wyoOvR9ajdWGmNsKr1bSr+FvoWYFxRXJXKI906PO HWHz4mgxbuYpZaei5kpRGNPdQR712BXGcnpyA+HE7zcdgItlb4haoMZAuPSSaNf+gp 0lG4Yb7Q8JJ8lrI9f/iCOwCWdWxft501S7/Nqq8OsqjuXcApUG+PImttiq4ONZZyBH sqKj/pis0ThOJcWHeKq8mclaABDNj5KzXT4dVULCv6TuMwl7KLPqIKFnIY1RULi+/q AR0LJTGs3elf2ynbeHLxgBwitDguvozQUQpzNcQqiZnZ2NcVF7zAkoE/eg6VS2nURs sIRW5v3wjL5cw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 4449E68313; Thu, 1 Jan 2026 17:51:24 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:31 -0700 Message-ID: <20260102005112.552256-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: S7MMCDRL26JAHYVUPZFQAEO5J7SLRMYY X-Message-ID-Hash: S7MMCDRL26JAHYVUPZFQAEO5J7SLRMYY X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 01/30] Update claude file to use uman instead of crosfw 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 Now that we have the new uman tool, use this instead of the old one. Signed-off-by: Simon Glass --- (no changes since v1) CLAUDE.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index b2590b17fab..d9e0245cdee 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -4,15 +4,15 @@ This file contains information about building U-Boot for use with Claude Code. ## Building U-Boot -### Using crosfw (Recommended) +### Using uman (Recommended) -To build U-Boot for sandbox testing, use the `crosfw` command: +To build U-Boot for sandbox testing, use the `uman` command: ```bash -# Build for sandbox -crosfw sandbox -L +# Build for sandbox without LTO (um is a symlink to uman) +um -B sandbox build -# The -L flag disables LTO (equivalent to NO_LTO=1) +# The -l flag can be used to enable LTO # The build is silent unless there are warnings or errors # The build is done in /tmp/b/, so /tmp/b/sandbox in this case ``` @@ -55,11 +55,11 @@ pyt ## Notes -- The `crosfw` tool is the preferred build method for this codebase +- The `um` tool is the preferred build method for this codebase - Always run `make mrproper` if you encounter build issues - The sandbox build creates a test environment for U-Boot that runs on the host system - When using `git diff`, add `--no-ext-diff` to avoid external diff tools that may not work in this environment -- crosfw shows no output if everything was ok! +- `um build` shows no output if everything was ok! - Remember not to cd into the build directory; run U-Boot directly in the source dir - Do not run in-tree builds; always use the crosfw script or 'make O=/tmp/...' From patchwork Fri Jan 2 00:50:32 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1166 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=1767315092; bh=nyas5D+BvfhT/bcU32toScmmJFB5tUGVOTY1t0HwAjQ=; 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=O7Z0SU+frJ9Xdx3Bi3igIBmqSLlJ1d3FX2ntYcBhuJMgs/MI72/tbVhEQAJq+WQOa WbffMxZVI6Y2GTUrYHLXTtEH+aUpwuFUxATZ9u9uWppF5Hqe/u2rKIA4S3dKJg/8ZO sbfPLZcISK7qBlfPEs9oPLb0Luf5qXONufoJy9cnObEzGUpyUqDpLhpFeWO/t4j9+9 o84ORd6EMcZIQ+68gmW64Pq7qY5ksB3l4e08zegQsq3ooGipRN8gfInaDZv3FY4ssj OqdoP+zyigel6jfcGB+vVtMiLYlRpGAULV5N8f2i8Q6KNsLf6guF5VjV8j+4fplxGM Q9K7ynL1iQykQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DED1A68313 for ; Thu, 1 Jan 2026 17:51:32 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id WhGQtfcPdpql for ; Thu, 1 Jan 2026 17:51:32 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315091; bh=nyas5D+BvfhT/bcU32toScmmJFB5tUGVOTY1t0HwAjQ=; 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=wW8wCeEyzro04Ik2teVZZdqOAAQF0HMudETLBccY51EtLm+jJ4nBbWl8XOWTBkMri BQENie7mjaypIDwbT3fGSy6+Bv3QTlnKCJ3sCQB3QMdZ0aKRYV2I05sfu03f3F5sxS c1SH9ocIg6lv05f/TxJBbKtMa+nsnxn3fx+1Yqo2nZDH5V1aJa6+VmKrTZcA55n9kQ sAHTGd8UqmKGf86zNOCehWqlYFC19mP8EmLHxAHqK+XQE0AggHK5zByOkJeC7csVEq q8ZxenS9qC0PvcG3gj+w0bNNV3okvDRyFZwHrqlcuaOKm3t7gESAOm1epsxWDOKCyH n7DM6HPmYqF+Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C136669001 for ; Thu, 1 Jan 2026 17:51:31 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315089; bh=FGiLeCKM8Ez5nMohCsirD8IohEHHTYWPPsWxPUT+ZLY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OCHI/uadATIZKt/KrjyMQWv0QtyzHZ7RvFhtoBwhkqVJo233HN5LXvWsh+CAPxSaA 6cZvMrzJ1OfNZNe/l7RdKSjNqfTtWAWmPy8l3wocoPvPBbYRpFdkz9XvatUWb66gJE x5ppPrzx/RcnWfFv1Xy3HEm/odl7Wx2gpaAW4+CS29s0ybZDvJTbnF1p8ITzre1oyy fa7sQOxI25AYcJjHSKxsbZSQWAHpyO3BZRjMH8I3RehSpNYMjVNtBanMeFgrCYyPu3 Mkml5czpdYeqHciaz+D+F0WS/GEmfuJQtGgsPU3HDTs49hZvF6203TmgOXXVlty5iz pimVny2Eq1+zw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 945BB68FFD; Thu, 1 Jan 2026 17:51:29 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id s_OztNykp3hU; Thu, 1 Jan 2026 17:51:29 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315089; bh=Rqa+ZcFEFqWRsL/qoTDFjLvEG1Xg+zmXho2D2g9v5/A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wBPTb+QcNO6TBCCmhvF5m/WJTq/NOk8OGONJOiIelEqH9d0XDf00TqEUM1I2Ldlzo QPj+J2Fk+h1Obd8g7eUO3tYM9WeJ+YznMHrv7BncyFhpHdWVSIbjGciLTr0KCWrgNu AJppp87N1B9a81Gdn8MlwaQKDUiF9i/5Ou2JMxoyl1LD/6fINGmiNnPcrGlSH15Hzs 0cqx/1rma4+7GEdNT+Nas9mhnvouX/ZDikBLHdltxjAl4JyrORqtyVRMTPcSo+R7qg hL5xKCz+aTbza6Wy/pXh4rkfVWRSqU0wmhrGoVnnjkfYzhYZMxTCEeWWVp02isPti1 DANBIkdqhJuHA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id F31FF68313; Thu, 1 Jan 2026 17:51:28 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:32 -0700 Message-ID: <20260102005112.552256-3-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 4PRMU4H555WHDOL5PKCUWSE2YCEPLPI5 X-Message-ID-Hash: 4PRMU4H555WHDOL5PKCUWSE2YCEPLPI5 X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 02/30] sandbox: os: Check executable directory for persistent files 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 When os_persistent_file() is called without a directory set in the environment variable and the file isn't found in the current directory, also check in the executable's directory. This allows tests like dm_test_host to work when run directly from the build directory rather than through the pytest framework, avoiding the need to set U_BOOT_PERSISTENT_DATA_DIR manually. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- (no changes since v1) arch/sandbox/cpu/os.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 891dfd9c9b8..5278ce55766 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -5,6 +5,7 @@ #define _GNU_SOURCE +#include #include #include #include @@ -338,10 +339,30 @@ int os_persistent_file(char *buf, int maxsize, const char *fname) } strcpy(ptr, fname); - if (access(buf, F_OK) == -1) - return -ENOENT; + if (access(buf, F_OK) == 0) + return 0; - return 0; + /* + * If no directory was specified and the file wasn't found, try the + * executable's directory with "persistent-data" appended. + */ + if (!dirname) { + struct sandbox_state *state = state_get_current(); + const char *prog; + char *slash; + + prog = state->prog_fname ? state->prog_fname : state->argv[0]; + assert(prog); + slash = strrchr(prog, '/'); + if (slash) { + snprintf(buf, maxsize, "%.*s/persistent-data/%s", + (int)(slash - prog), prog, fname); + if (access(buf, F_OK) == 0) + return 0; + } + } + + return -ENOENT; } int os_mktemp(char *fname, off_t size) From patchwork Fri Jan 2 00:50:33 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1167 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=1767315095; bh=wgCbQk46sAVp5mMGNWdKJceZGnXsJPEI35CaExYsIfo=; 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=CqGAjHMaFUilyyrS0eoGnKnQmsoH9OLFHxQtZSwI3tK2Mfct95phOVog/kggSewZt a1mdFVWVX2/tPIxBj8bHAh/THoXjZaKpTD64Hchu+C+zM7IQ8e82+1OQzI83K2Q2Ag vxiLyUb4xOVNJKxIz22tsCXUWatuuwB6G8osi7JY4ceAf+Nzr701ywSYzbPz+rLlSg aGb7DRu8rm74TIVKl1GnX7B1v3Z9B2KA0hFxHt4sWK3pd17tdKsCeGvNRIRZ0f6NRY 1rHZ5yYVeqfUPXeCGAc6wFJ7w4Isb0M9AV0ho8eaD3o6fFkztQbiJb5KYPpjNmCs1k dMV9ENH3p8DGg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5E1D468F56 for ; Thu, 1 Jan 2026 17:51:35 -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 qK59ycc_A81S for ; Thu, 1 Jan 2026 17:51:35 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315095; bh=wgCbQk46sAVp5mMGNWdKJceZGnXsJPEI35CaExYsIfo=; 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=CqGAjHMaFUilyyrS0eoGnKnQmsoH9OLFHxQtZSwI3tK2Mfct95phOVog/kggSewZt a1mdFVWVX2/tPIxBj8bHAh/THoXjZaKpTD64Hchu+C+zM7IQ8e82+1OQzI83K2Q2Ag vxiLyUb4xOVNJKxIz22tsCXUWatuuwB6G8osi7JY4ceAf+Nzr701ywSYzbPz+rLlSg aGb7DRu8rm74TIVKl1GnX7B1v3Z9B2KA0hFxHt4sWK3pd17tdKsCeGvNRIRZ0f6NRY 1rHZ5yYVeqfUPXeCGAc6wFJ7w4Isb0M9AV0ho8eaD3o6fFkztQbiJb5KYPpjNmCs1k dMV9ENH3p8DGg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4A04A68FFD for ; Thu, 1 Jan 2026 17:51:35 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315092; bh=HqLvP0KbRAVat8ijXoQt1gnRNZ6FwDh3X8R8q6YB8cg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b5BTyLKiUdnL6fBf9AibdwCGPBdryUuoBEUqUNQjQBl+p4R2rZAdKrEuX2N88Up7L huOO1W73cTX417RcJim4smqBDD+aLkxna4GhMkNBfbl7B2yjleO+Rl7JL2/Om7ljqY g98rueIuyi0CN5gLGwIjLKSF5HncAsNxAuYRw5MivFOZHAA1p9JzvNaa9hSQw4ZSNN NSM8uuKod15EDJm9CoZtOnqLL0EXbSDW455sR/wSeiu7WM1HUBrWwJgpjyDQl664Yb WaDwu4s55WyAXnGScGmBRnAFo863D2LGi91a9ncAy3E1tuZBqcl0FmmHyVU/fF68UW tE3YP3IQo1FZQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CE7306901E; Thu, 1 Jan 2026 17:51:32 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id rZL9wzHZ9HQy; Thu, 1 Jan 2026 17:51:32 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315090; bh=7X2Ky4hRS1WoM79Thw9wzQ6bymehUUYWeJF5kHEZs3g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=USILo2gB0TTYeqxn1/ADGQAoaTmROFZN+oDkTcELDlM8rFLR4NJ9YZA1kzc0yywdn tENd+teJQ/6/xpqpr9pzKajNab+5J/xvF0b/d8LO3JG3LB4uGMr8DZlBS5E3mNO8C0 KxaMyc0l5XTGtbcolBPKS64op1ZCSvxmmwTrDN1x8tjiWSabXWMRWHeHquMsxxWXkF g2NvVEEKPM9Se8OvDNx7/JihUVYh1EnKJpXI5Rf/c/gou6WeS2gWvbxLNol7/MUsDG 2DAqekhdlydDGSZoEQmtWD0w+oc0sJ3RukJrOwnQiB3SRyB7zxNy5Dq2Zet4H9lljA xbXUMVLZSJwcA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D60EA68313; Thu, 1 Jan 2026 17:51:29 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:33 -0700 Message-ID: <20260102005112.552256-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 7H7T74LJ3CE37I57NUOGI6NIZHEDH7Z4 X-Message-ID-Hash: 7H7T74LJ3CE37I57NUOGI6NIZHEDH7Z4 X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 03/30] sandbox: Add --quiet_vidconsole option to speed up output 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 When running sandbox with lots of console output, the vidconsole slows things down significantly since it renders truetype fonts to the internal framebuffer. Add a -Q/--quiet_vidconsole command-line option that removes vidconsole from stdout and stderr, using only the serial console. This can provide a ~300x speedup for output-heavy operations. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- (no changes since v1) arch/sandbox/cpu/start.c | 10 ++++++++++ arch/sandbox/include/asm/state.h | 1 + board/sandbox/sandbox.c | 16 ++++++++++++++++ doc/arch/sandbox/sandbox.rst | 7 +++++++ test/py/tests/test_event_dump.py | 1 + 5 files changed, 35 insertions(+) diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c index 30d4f83b6ee..1a5ca97e15e 100644 --- a/arch/sandbox/cpu/start.c +++ b/arch/sandbox/cpu/start.c @@ -476,6 +476,16 @@ static int sandbox_cmdline_cb_no_term_present(struct sandbox_state *state, SANDBOX_CMDLINE_OPT_SHORT(no_term_present, 'A', 0, "Assume no terminal present (for pager testing)"); +static int sandbox_cmdline_cb_quiet_vidconsole(struct sandbox_state *state, + const char *arg) +{ + state->quiet_vidconsole = true; + + return 0; +} +SANDBOX_CMDLINE_OPT_SHORT(quiet_vidconsole, 'Q', 0, + "Don't use vidconsole for stdout/stderr"); + static int sandbox_cmdline_cb_upl(struct sandbox_state *state, const char *arg) { state->upl = true; diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h index 6a89f0ca5ef..ff7493ec5d6 100644 --- a/arch/sandbox/include/asm/state.h +++ b/arch/sandbox/include/asm/state.h @@ -177,6 +177,7 @@ struct sandbox_state { bool soft_fail; /* Continue on failure */ bool pager_bypass; /* Enable pager-bypass mode */ bool no_term_present; /* Assume no terminal present */ + bool quiet_vidconsole; /* Don't use vidconsole for stdout */ int video_test; /* ms to wait before next assert */ const char *video_frames_dir; /* Directory to write video frames */ int video_frame_count; /* Number of frames written */ diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c index d97945e58fc..78b2b7b1f47 100644 --- a/board/sandbox/sandbox.c +++ b/board/sandbox/sandbox.c @@ -10,7 +10,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -19,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -185,3 +188,16 @@ void fwu_plat_get_bootidx(uint *boot_idx) *boot_idx = 0; } #endif + +static int sandbox_settings(void) +{ + struct sandbox_state *state = state_get_current(); + + if (state->quiet_vidconsole) { + env_set("stdout", "serial"); + env_set("stderr", "serial"); + } + + return 0; +} +EVENT_SPY_SIMPLE(EVT_SETTINGS_R, sandbox_settings); diff --git a/doc/arch/sandbox/sandbox.rst b/doc/arch/sandbox/sandbox.rst index b2f4d8913d2..90c3dfa837e 100644 --- a/doc/arch/sandbox/sandbox.rst +++ b/doc/arch/sandbox/sandbox.rst @@ -208,6 +208,13 @@ available options. Some of these are described below: -P, --pager_bypass Enable pager bypass mode for testing. +-Q, --quiet_vidconsole + Don't use vidconsole for stdout/stderr. By default, sandbox outputs to both + serial and vidconsole. This can be slow when there is a lot of output, due to + truetype font rendering to the internal framebuffer. Use this option to use + only serial output, which can provide a significant speedup for output-heavy + operations. + -r, --read Read driver state from a dtb file. In conjunction with `-w`, this allows sandbox to save and restore emulated hardware state (such as a TPM) across diff --git a/test/py/tests/test_event_dump.py b/test/py/tests/test_event_dump.py index 3ddd60198fe..ff0da82196b 100644 --- a/test/py/tests/test_event_dump.py +++ b/test/py/tests/test_event_dump.py @@ -22,5 +22,6 @@ EVT_LAST_STAGE_INIT efi_block_device_create .*lib/efi_driver/efi_block EVT_LAST_STAGE_INIT install_smbios_table .*lib/efi_loader/efi_smbios.c:.* EVT_LAST_STAGE_INIT last_stage_init .*arch/sandbox/cpu/start.c:.* EVT_MISC_INIT_F sandbox_early_getopt_check .*arch/sandbox/cpu/start.c:.* +EVT_SETTINGS_R sandbox_settings .*board/sandbox/sandbox.c:.* EVT_TEST h_adder_simple .*test/common/event.c:''' assert re.match(expect, out, re.MULTILINE) is not None From patchwork Fri Jan 2 00:50:34 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1168 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=1767315097; bh=E2Mwh2H2gMIeLHYBwJihrUCuUWec+lByo4KqW/rXcWA=; 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=l6d7ErDcHoD/ckvhf+Oh2F2pvkT0D065CcxkP5SGUXxOOOgZ/4BrxXqV8hsxaR80C LrL4aVejzD2S+biu8Fy+5twYS3TIJd5o6B8lEAdkP2dw9aYWvlcaOUGhpcxogAR6ww CEihnURCf81C8QcXpTUMmikgLmzAw7SX0H9DTHpuPC5DVPIpQ7Q7p1pumBTf6Ib/dI wS0rYH50QhuucyrU11RAcwECjunvk/27iKNMbZANkJ2FADgQiuU3HiKFBQR1lP16X+ vPW5lKfdOf0yWkSwJXBhSph4eow7Lr2yee2O5parX02OaIr3bQTyBT53ME/hTnLwtb vVtwZnrFQB9JQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C2F6D68F58 for ; Thu, 1 Jan 2026 17:51:37 -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 rPAtoj2suVln for ; Thu, 1 Jan 2026 17:51:37 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315096; bh=E2Mwh2H2gMIeLHYBwJihrUCuUWec+lByo4KqW/rXcWA=; 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=F7SKfu08hcpofxChBSeHQe9VWR855JxOGFrDPVxO0UfBk/GDWFL8glPhPqbHA+NBw vgtqUoXutyircJD0qb53BFAFFsOphHbd9+I4F1AvqtBb+zPNq9zIPN8hlOW2nYxMXc fH36Z7mzOKrYTDcmAGuUr9F3vidKSiM4VUpreZ4y0IEQUoybCIv5pyvmwLYlNKTXrw HJlgDJeEmqCEqWLd4pO9NMbeTqU5N6COtg5TkU5W95uFFF3fAD2rZf+yiXnbrz6OI5 g8BUlPXs7K5pJs8p+5CNxTLCRO3mYyOF4yJ/4XCqQ1hIWd4RM6RmJF0umPHfiMX1G6 WuuyL1LrVNSgg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F0BA868F56 for ; Thu, 1 Jan 2026 17:51:36 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315095; bh=nwpGfLIxsKNTqNyE7PjZQsjB9SlAx580SZ91UpYAsmc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gh5bxGPAVZKSYFXdwySPLJmjpX2N2nMoyAaLOaZZNMaCpg/coa2EgTHI1fPgPm8dE BBPNerGb51ilTKGEWQTWv7nCccMEBAyWPGMNtHUkL4u3laxTE3aMyyhcL726qpXaK4 JuwhNtK//7o13o0vtvEf/OTZn/5uO5WsDoS12UKb2kTHxHi9+fA8UTtKAEPulaq/Dv CfUhePVw5CpQrDAV9upMS+CsunqEMg6bRxnxZ7GmS48ZZT1MFzi9TrnyXfT0JznmjB K8okzEYOAw/QPnVojZJB98eLYplj9AsadjLcwhAQlh29AsOrlEMznjLr5ylDowItHF okgoux6Pq/eYQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4A03B68F58; Thu, 1 Jan 2026 17:51:35 -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 Bowe3wSmuBgQ; Thu, 1 Jan 2026 17:51:35 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315091; bh=cTYW1yNJqFceXrOIJ6XIu+HKhgFNXrzA6XKuzlVvTuc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U6d2/n9kI6lccYVCagiRGigb7va0BYW2nXevbTo+FmZbMplNEajBtzwBAXTMwPi8s 78BY4TU2k65LM+pfragkU9VgqmmaI1Evozy3DQ24H4ZykwJ4M23OCw7+AN3GkgJlKj X3HgHRUXJNSHydXvkZPxL5Rk/dbj5UkS2SR1u5BoK3BihdQnuWjisLuF0huHqkwvYa xA0EgL7IBLsMYGNLrYFKNf5gCut4lJkbVDsGix2zB0T5ApVhLWPF+KkX13gD8YSxnI FnwWWk+ksMQzPHFfbaA9srxZ4v6y7djre27o4fC9IV7fQAQYOB0XDTTOnBzsq8jW9y 4trrDBZJeX6qg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D3AD868F56; Thu, 1 Jan 2026 17:51:30 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:34 -0700 Message-ID: <20260102005112.552256-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: CNU2H5GJG76YSKVTD6OXK5HC26L4IOXW X-Message-ID-Hash: CNU2H5GJG76YSKVTD6OXK5HC26L4IOXW X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 04/30] video: Avoid uclass allocation in video_idle() cyclic 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 When the test framework reinits driver model, it orphans existing uclasses without calling their destroy callbacks. The video_idle() callback remains registered and when it runs, it calls uclass_get() which creates new uclasses if they don't exist. A surprising time when it runs is when any environment variable is read. Use uclass_find() instead, which returns NULL if the uclass doesn't exist, allowing video_idle to gracefully exit without allocating memory. This avoids memory-leak detection failures in tests like dm_test_host() Co-developed-by: Claude Signed-off-by: Simon Glass --- (no changes since v1) drivers/video/video-uclass.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c index f50452cc956..383be0d96b8 100644 --- a/drivers/video/video-uclass.c +++ b/drivers/video/video-uclass.c @@ -669,10 +669,14 @@ static void video_idle(struct cyclic_info *cyc) { struct video_uc_priv *uc_priv; struct uclass *uc; - int ret; - ret = uclass_get(UCLASS_VIDEO, &uc); - if (ret) + /* + * Use uclass_find() rather than uclass_get() since the latter may + * create a new uclass if the test framework has reinitialised driver + * model while this cyclic function is still registered. + */ + uc = uclass_find(UCLASS_VIDEO); + if (!uc) return; uc_priv = uclass_get_priv(uc); @@ -683,13 +687,15 @@ static void video_idle(struct cyclic_info *cyc) if (CONFIG_IS_ENABLED(CURSOR)) { struct udevice *cons; - struct uclass *uc; /* Handle cursor display for each video console */ - uclass_id_foreach_dev(UCLASS_VIDEO_CONSOLE, cons, uc) { - if (device_active(cons)) { - vidconsole_idle(cons); - video_sync(cons->parent, true); + uc = uclass_find(UCLASS_VIDEO_CONSOLE); + if (uc) { + list_for_each_entry(cons, &uc->dev_head, uclass_node) { + if (device_active(cons)) { + vidconsole_idle(cons); + video_sync(cons->parent, true); + } } } } else { From patchwork Fri Jan 2 00:50:35 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1169 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=1767315102; bh=P30kGybYmwYfUNVyfoacwflEcYTeDxDYY44D2N84qUw=; 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=kz2N86Fll35vUUJzfX0ktOLFShv25wnuAyllAlcIOVXfUokFiOBejgwG6mMbYJMj/ k5hrgSS2tmw66QcOvuKs5mvrlFlJw3z69H/e11XqVgL9oUGqlcWyZotYYW08DVW2sP zPBA9jDeBTP2bC0uVHyWsB7n3rfsBvlfFH5rWoL8zfqP0IuVZNON5iq8uK9QO4wRix MWLUbrFANBM9nPLntBo02MtFrSSOQLdq71ukOPQ06/ctVgpFhLbfD7pJsEvUFd2t0F Kk0N3zXaNzld+uQksrHh7Ki0SNf4QTGs+RDQE23iY7z3Uo/OutkOWFhKQ5KjWJ2zXZ f2gAABBWOq6Jg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8741A69001 for ; Thu, 1 Jan 2026 17:51:42 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id dPyi67G5F611 for ; Thu, 1 Jan 2026 17:51:42 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315102; bh=P30kGybYmwYfUNVyfoacwflEcYTeDxDYY44D2N84qUw=; 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=kz2N86Fll35vUUJzfX0ktOLFShv25wnuAyllAlcIOVXfUokFiOBejgwG6mMbYJMj/ k5hrgSS2tmw66QcOvuKs5mvrlFlJw3z69H/e11XqVgL9oUGqlcWyZotYYW08DVW2sP zPBA9jDeBTP2bC0uVHyWsB7n3rfsBvlfFH5rWoL8zfqP0IuVZNON5iq8uK9QO4wRix MWLUbrFANBM9nPLntBo02MtFrSSOQLdq71ukOPQ06/ctVgpFhLbfD7pJsEvUFd2t0F Kk0N3zXaNzld+uQksrHh7Ki0SNf4QTGs+RDQE23iY7z3Uo/OutkOWFhKQ5KjWJ2zXZ f2gAABBWOq6Jg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 765F168F58 for ; Thu, 1 Jan 2026 17:51:42 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315099; bh=WhJWf+6J0aA1VmYh84WjxzyprI2ucBuBhceuRDI8VA4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aK2lJ34jCulzbzNmKHDI7VB2h4CcNw5NQlmf/pakFebWK7MOt4sT4uhORPIKYILJX PvX+YbLKfctVaPhHs6JvxBEQUgil12LFoKU/GTPq+ojHS86Ak7r1kvXh+q1TN9LER+ jBxXcMb+2vsJZhF2k7gD5piPipJHHYiJcPG+9whOQEzrVcWHXUEYcFuBUbR1fZR4/z bjZYCRhW4oWu4pXPdHGQ2dF9VWuXzHDi2fwIIO0/XHm6vH7nizzTMs2Fuhppror4oc cN656MgiWcLC0vE40h+i8+/ioXFHdrWoCE3vrHmLJga1psz5PHoWu2n90ylL/jTsFf jWGKX8po7jBVw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E22DD68313; Thu, 1 Jan 2026 17:51:39 -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 Vxk7hgr5_aBa; Thu, 1 Jan 2026 17:51:39 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315095; bh=kJYNw5y9awEu025U2v24nrqAoXNHrKe2BfyqKAG/BtE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BlfLZVrO150oRmsatuL2kJidhVff3cH2tAuo/iNGc0byKv8eW9i51kKj3mlhwbyEW MKp0XQ53r+Etvn8bsDoNcFtbjbvE15j7wTku34QhDPmBm3vEUr/kBqX00eQA2Z6tyk 3Si13sHawmKYy1+bPc+qsV0eDvTSsCPfc73/JYzuicF7bFx0nF+vYVLbbHnINUNQpm kD/Djnk4JEtZAB9ElOTcTM0Ms0/lOfljDuS6B3SbG0cyTfdOsfHFSAg9K9w8Z32PtH S5Osl4MEL+Q+TVYAvdIPuic78iA147C+0+DVH5f6V3gS7huvCQUTZ7MFCHceoPgcla WSGzQj4YwMWeg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 8608368FFD; Thu, 1 Jan 2026 17:51:35 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:35 -0700 Message-ID: <20260102005112.552256-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: UOSYFUS5UPQBBGWIYJO7LOSDAEDS6TOC X-Message-ID-Hash: UOSYFUS5UPQBBGWIYJO7LOSDAEDS6TOC X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 05/30] video: Unregister cyclic on the last video-device removal 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 pre_remove() handler to unregister the video_idle() cyclic when the last video device is removed. This ensures the cyclic won't run after driver model is reinited by the test framework. This complements the uclass_find() fix by properly cleaning up the cyclic registration rather than just gracefully handling the orphaned state. Co-developed-by: Claude Signed-off-by: Simon Glass --- (no changes since v1) drivers/video/video-uclass.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c index 383be0d96b8..3e02c48d399 100644 --- a/drivers/video/video-uclass.c +++ b/drivers/video/video-uclass.c @@ -874,6 +874,23 @@ __maybe_unused static int video_destroy(struct uclass *uc) return 0; } +__maybe_unused static int video_pre_remove(struct udevice *dev) +{ + struct video_uc_priv *uc_priv = uclass_get_priv(dev->uclass); + + /* + * Unregister the cyclic before removing the last video device. This + * ensures the cyclic won't run after driver model is reinitialised + * by the test framework. + */ + if (uc_priv->cyc_active && uclass_id_count(UCLASS_VIDEO) == 1) { + cyclic_unregister(&uc_priv->cyc); + uc_priv->cyc_active = false; + } + + return 0; +} + void video_set_manual_sync(bool enable) { struct video_uc_priv *uc_priv; @@ -897,5 +914,6 @@ UCLASS_DRIVER(video) = { .priv_auto = sizeof(struct video_uc_priv), .per_device_auto = sizeof(struct video_priv), .per_device_plat_auto = sizeof(struct video_uc_plat), + CONFIG_IS_ENABLED(CYCLIC, (.pre_remove = video_pre_remove, )) CONFIG_IS_ENABLED(CYCLIC, (.destroy = video_destroy, )) }; From patchwork Fri Jan 2 00:50:36 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1170 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=1767315106; bh=MB3rDfPLQEppmS2Po+tw9a1zgA5mhXGKJxVO2QhCd6U=; 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=hCi8s269ZVSt4XiAnGcJz038qeSsKH1I7SdZXMbiMf8xlD7+vDjDDb3mxpKeWkQtC 0lpwvDfTxKciCsmexcA271fGhA4HU1zfbqehH5CuKJjQdx36tUpnlcOxO2KnrnH3B/ OpAT0L7VtJ22NNuftDKBGPr04Hcs5/b8oOeAp1K3V+FBmjbPYQdXEOPsxTj+Ey5xhe s40Y06v8TPBmOr0DosrFL2+WFM16CBUhtuRSEM/HiS/J00La0USaWfowbXL5LQ/BJe Qd22Lvln01lQjqu6g1FedRbjgkS8n8pANa0RVRd9wRgujWeG6PjhcIx16wIG2vWd+U 3fKc6z22ou3pw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id ED5AF68F58 for ; Thu, 1 Jan 2026 17:51:46 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 6yc6KbTas55a for ; Thu, 1 Jan 2026 17:51:46 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315106; bh=MB3rDfPLQEppmS2Po+tw9a1zgA5mhXGKJxVO2QhCd6U=; 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=hCi8s269ZVSt4XiAnGcJz038qeSsKH1I7SdZXMbiMf8xlD7+vDjDDb3mxpKeWkQtC 0lpwvDfTxKciCsmexcA271fGhA4HU1zfbqehH5CuKJjQdx36tUpnlcOxO2KnrnH3B/ OpAT0L7VtJ22NNuftDKBGPr04Hcs5/b8oOeAp1K3V+FBmjbPYQdXEOPsxTj+Ey5xhe s40Y06v8TPBmOr0DosrFL2+WFM16CBUhtuRSEM/HiS/J00La0USaWfowbXL5LQ/BJe Qd22Lvln01lQjqu6g1FedRbjgkS8n8pANa0RVRd9wRgujWeG6PjhcIx16wIG2vWd+U 3fKc6z22ou3pw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DB00468FFD for ; Thu, 1 Jan 2026 17:51:46 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315104; bh=Qv+szGtN5yKKjCIbsEhdwaIaILBT7/cEIA1Ajo/Lt3w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E1Vm/8b80nxrpNN31LgMACV6xWT7oz0FBpg0XswbN688q4iO9gKbXHyLj+vmI8eou L5T/GJEiy5ga5GG+3mzLlnS5x7f2OxVPjLXJUmDOCLC3Xtwb36+3t+hmj0rsoi6UuD V+ZNK9Gg+FxeTSgHmdxtes3CtD7ITqdggR/3xQsW0LrSiLMeJ8E4OFz7oo7XKXFQdK fIoTInYroGe0r0gO0WohbgT+mQR2cZnZdirC3YxpqsojJ8Fm+Q4oJlAaC7BSWKOu2N PZMYHjWd0IbUwy3DFAmsaolGNkTfpECwKxxXlcbmbF+ICkKcYrBqoK58+JLqkKkK54 zXM2+cMBE6ouw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DF62C68F58; Thu, 1 Jan 2026 17:51:44 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id gzX6ZD9SPoZo; Thu, 1 Jan 2026 17:51:44 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315100; bh=ZoeNz0Peh1QVTScAMKM+OdaaZNrVm3SKDbO06BOjh4s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lBP+HF7oItEX9briaWGtDKy7Wn/jriZPf5dTGEtkncgks1rF+kb0YDwJMMurgY+rc hXADNWrqYiwhplTzBPROcIqDuYW/eHxR3eP7ffYHmNDjRcmSu2wGD+ZUV8BQYD/hj9 RqM/UDNaPfk24xlXGvcUCzfg5T63D4agyCWdPjw8xdXzwZG40xwuU4Hora+4pdc2Fs xxGCiK3c1yzgSNSoFvIXfudrAxtAEd9No3eUji/9PWAjapG6reDPTa6bgJLVBm6QyM oO1ts3fH3S7iMKlKKZ/DOACV2Eq5Y6kmy83N9D7AGnpXbRy7vCGsAoJnbTxwE1cHWI gGXvpbcNrfVKw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 3212A68F56; Thu, 1 Jan 2026 17:51:40 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:36 -0700 Message-ID: <20260102005112.552256-7-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 5E52MITCVMVIW47CJXDNOKCSAIP73ML3 X-Message-ID-Hash: 5E52MITCVMVIW47CJXDNOKCSAIP73ML3 X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 06/30] video: Correct the U-Boot logo 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 Update the ReadTheDocs documentation to use the correct U-Boot logo from the original 2023 website, stickers and coins. This includes the project name. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- (no changes since v1) doc/conf.py | 2 +- tools/logos/u-boot-logo-text.svg | Bin 0 -> 8552 bytes 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 tools/logos/u-boot-logo-text.svg diff --git a/doc/conf.py b/doc/conf.py index 348f0132ffc..498893ad669 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -257,7 +257,7 @@ except ImportError: # The name of an image file (relative to this directory) to place at the top # of the sidebar. -html_logo = '../tools/logos/u-boot_logo.svg' +html_logo = '../tools/logos/u-boot-logo-text.svg' # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 diff --git a/tools/logos/u-boot-logo-text.svg b/tools/logos/u-boot-logo-text.svg new file mode 100644 index 0000000000000000000000000000000000000000..55b7f5c6e2a7e14067c28136238977d81a4a8810 GIT binary patch literal 8552 zcmd5?YjfMS68)ZEfhyBZJ24+1DN3XzwN5;p+nMxEr*5aWA1M-&SW^Tq2w75o{oMr# zKJ;*u*w=|Xj>X06?C!zt63FDo-8v%=Oq40lrvqx*1H$r{CuzQ%4*vY(XJb4drHt|< z%6QJEgPae3oV}WSV;JP_x7+_1@6(v&B{P0WST55=%0x)sy))kaZQR`$o@o=qn7yj{ zzvIPTq|22g-^V`?$EM>e@-LR=B8^w%E?#ZoRU{HgCcAwhcy2DU;{K=QdS@nVR!>tt zEME~qwrL_)fOhN;@Nva(*7o@!W!txWHyzl-CeR6gRmU`$4qysLJ#>_&Rcn4<#!#6rA`hd6dGE8etr-PN0 zMQB;u?bg&nlZ&N=kjf&8S!rpxf?ti-`ZnXWz%2Pj#B2dmFf(V;y8YwU(v5~~CNgQK zX-4DfTUV{?*tTtHTh)s_024bn&-WC`;#5x>1c7Bcmg5-E!zlN;jCMv|zHXs}aomiI z1&d_*z+%2$^SrFg(d(SFor{ggRF5RKSjN_{2}+Ba)EdlynG>1Hj3Gq{LGGzX*B;FN zG~NO|$a|p2#8Oh#ea&Q)L^5heXo*YJgfJzj5dMDqGxo>NB#y(sxVWz$L4qBkIp4sB zsK=;&NgRS(){&g0>uAZ)$Zx>F6RT}#=9qv??u!~Z4zH#atnzPTtFHPj;P%$3=^-vgFMY z9M~0hVV{as-(~XpI9z?Vl-J6zjcb(&;h%{G${nntdL98na{(9F?AK^d99qgN6*5(4 zC9iFxW<&;P*vN=FD!1nAkfPp7ms(CwTN$We0=!(d6Q3c*so7!2{mvk=C!1J8w(0u> zKtFNr+q9G-oo`OgE!clIDbV+Gf&ZIJVB`_xr%rn#&qIEyIhaTvR3Jlgl+ORr{Se<}1v2;Ac#!12!wL>sC;*%59I43%3gqVpE%;=Tt3J5DP&$yTl zUN6)~MR7vrTqI2BCSQGeO&ro01SlvIYB8Vx!(u6U#zd6IkhG~?w=4w|7^mc$G-0P2 zbdC%WUbB#%uGd>chXzw*@pq6O%vxZfaS+V$@i8+S~^Ta|4EAKUR5{f^XhpOJ} zcqxnKESnDABO-EyWhwZkSn~wPq`+!x!J0MrdRN4$h;?N^pupZ|Fa&DBEPQR-p6C15 z_+Zpj3h6b(Hh#~-9E$Mzd&QJc8?CA^ib$@;uC_HH%9U;n10KL=b z671&sIp9z__ck+Zyy@PaTB0=9(8>Ke<=LA#_+3B-bdxBeMPnM)K=Q} zM4-K=w12wtU<4g+AsVwRON+9p`Ff5`k{}okKf|%-><&xo*j14fyxKSmS?bXyE2OH+N*2c>B zFUG>57eKJmUc;#FwouUBVr)M3nn+_378?11*2bljfixF&x)CiS2 zmqLBiyq8p)9zcaMLW9B3^ii-aEfiQx^)F{vqhrcTz;^Z5Bf-^Jptfw+M#N4c+-c&`s{jvl7~p7Q7(J3t-AE;iQtTY$#~V5!O=?S4o%ng zhQ;nWOLJya**Ubot!7_D>onVk@1iW7i}c#iul|NwyDV4?_j)lLCGx!KlrbrpFi;)1 zDGY6xdJ6||JwbJxQ617<{OahKf#=u=wL0-I5HZ}!g>bMdyRv_Hnul-}&4iXVhb2ui zg7EHnrst2lH7KS>A5ytzkJ=Ij-&4_7u4g-g*+hb3x%L})N8j%WI244V9DvlUQQz#~ z02thomynaI6LNC>0|qFkxp28RKJXbeouSrOm0e+DFny~87fJ|b27f`J`n>7u;2|BE zBkw??r?3#UGJv+rJcL_lq{1bhnBQh3j75 z8~K4gzOAS-GROAFr>(H1st1>XpGH-n+IG40Fz{5@&Et; literal 0 HcmV?d00001 -- 2.43.0 _______________________________________________ Concept mailing list -- concept@u-boot.org To unsubscribe send an email to concept-leave@u-boot.org From patchwork Fri Jan 2 00:50:37 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1171 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=1767315111; bh=mlMOPvry7AdjUkvYqU8Hhzy35DW4nXFkjP62BMurm8E=; 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=NwCUeWMIcEb1LHB5bSErI3/0C/MpZ7uNqpPhH+kTjmGOh2AtDSLRCUQ90CSgWCxMf dVtPEhuemHGwmAbp3f8eJK03iu3Fy7ZBiVkN+P1XiaSm83r3C79jBjtdZWt9sYJ6VL gwa6n4P/IY6gbPt438X3ttlxVqoiOz2RuPXOdHl+7x4IRDtaFzLOx13Yn4pogsmHEw 2ncbtPyxto0cT4o60KZCt8zOBsMTBodOhasve0OOqW8qt0VKvk2dbjuxoebGjmfh7p wpJYikPKfkqqqOCgjJ4lTkkP0q/vs8N8jW9ZKYqnEHT9lreruErcT/iHev1lij2sil t1YAZt2eWIpfw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6F9E269007 for ; Thu, 1 Jan 2026 17:51: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 k9QFKMnP0_Sx for ; Thu, 1 Jan 2026 17:51:51 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315111; bh=mlMOPvry7AdjUkvYqU8Hhzy35DW4nXFkjP62BMurm8E=; 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=NwCUeWMIcEb1LHB5bSErI3/0C/MpZ7uNqpPhH+kTjmGOh2AtDSLRCUQ90CSgWCxMf dVtPEhuemHGwmAbp3f8eJK03iu3Fy7ZBiVkN+P1XiaSm83r3C79jBjtdZWt9sYJ6VL gwa6n4P/IY6gbPt438X3ttlxVqoiOz2RuPXOdHl+7x4IRDtaFzLOx13Yn4pogsmHEw 2ncbtPyxto0cT4o60KZCt8zOBsMTBodOhasve0OOqW8qt0VKvk2dbjuxoebGjmfh7p wpJYikPKfkqqqOCgjJ4lTkkP0q/vs8N8jW9ZKYqnEHT9lreruErcT/iHev1lij2sil t1YAZt2eWIpfw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5F3EA68FFD for ; Thu, 1 Jan 2026 17:51:51 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315109; bh=IdPD5nLrcij4Y6j6YaKudJJC2o3GJgSb1CvpMVgyaBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q379F4LC4oYHPHePAdoxMhFQLbDFIX6cdSJrxeQ/am9O4Yne7RlKQEMyZxLheJ7As 56GfGIafUzTI5FLDcmoEEZpuNklZsy+JAVNF/UeZqUHazxjWR+5sJEzODzNw+Dytti qU7i49i2Hyuva+coTBJHNqhzklYie6NZvF64J0RYm7sBhhcUDkH8zx4TllyLs76HoI x4jzD8qCt0gEnjAijZsAlPNqkJ3/lmps0gAQeaVQJfA0I1I3SAAuKiQDGEUGODWYBW 1ahc1VPvCrVKEPrQBwk0+ESpUokvxniWkZ2wJBXRWz3VGhan2EROM46ssVY2U32GG7 4nc78oP3Q/kNQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5371A68F56; Thu, 1 Jan 2026 17:51:49 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id vlg6YhAiCLpd; Thu, 1 Jan 2026 17:51:49 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315105; bh=KFbXeYBGmqawrlCAVCobEGoHa2a2U0nIV2zLvzkBs5M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RJHLdwgfuu220m5mx/6qn/Wayg8qaAPc1lAFTENr6sF0E40HZcjBfbu3td6p8/oir SFpBb2Rs39aSVLQ9UCXC2/uoMtEyRZy5bJCM0NUWCEC7Lf5iJaq2Ac43X2NxGVvQPM lP4ObrQ+P3J2q5qXFO/FFeioVDPXLsfblsJm5Pnwr9mNaLq3kuV2bf6iOIQavU9gb0 rZsZuQ+WCQKo84CZCpnAn38FlY2HLTenr27rkktHnIQpaH6ZlT+c+6MRoPr0w6oaf8 2Qe1BDSlPCwDoLT/IARF8xXzHUaK85e25Dzq/Lqd53r89Pto7vOpJCoHbQyLd96QNH cJii5qZT9+HKQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B247E68313; Thu, 1 Jan 2026 17:51:44 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:37 -0700 Message-ID: <20260102005112.552256-8-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: EQCB2C6KNCJ35LPM3XZJZIGBTANWM5RJ X-Message-ID-Hash: EQCB2C6KNCJ35LPM3XZJZIGBTANWM5RJ X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 07/30] blkmap: Handle read-only slices in write path 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 Some blkmap slices (like blkmap_crypt) don't support writes and have their write function set to NULL. The blkmap_blk_write_slice() function calls the write function without checking if it's NULL, causing a crash when attempting to write to such slices. Add a NULL check before calling the write function. When the slice doesn't support writes, return 0 to indicate no blocks were written. Co-developed-by: Claude Signed-off-by: Simon Glass --- (no changes since v1) drivers/block/blkmap.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/block/blkmap.c b/drivers/block/blkmap.c index 14aa1e4d088..bd55bdf24b7 100644 --- a/drivers/block/blkmap.c +++ b/drivers/block/blkmap.c @@ -281,6 +281,9 @@ static ulong blkmap_blk_write_slice(struct blkmap *bm, struct blkmap_slice *bms, { lbaint_t nr, cnt; + if (!bms->write) + return 0; + nr = blknr - bms->blknr; cnt = (blkcnt < bms->blkcnt) ? blkcnt : bms->blkcnt; return bms->write(bm, bms, nr, cnt, buffer); From patchwork Fri Jan 2 00:50:38 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1172 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=1767315113; bh=BDk4Ws/ufE56zj90m+kQNWxrzSTvSMCdNh8BVdcdmQw=; 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=AQptBJRPQb/qE/ym0NofE1zDZZj7EwMGCNdFzY7DK9JShzL48dBJp8onqaBP2GF+W 77DlycDXREe3z8Q9IxrK9n7wlB3yb0UqrVqBowjv6S/D8G9two9oxqZGFFA0t2+J2L kYT1iky+/T9MYq4+HTUY1Hic+yIlsB+ORGic7BtQPLdPOnX9Adqvze/iNp4ki3Xp00 sCgftS4ny9vBPQJtrzUgO1puOFq9J4sRkKrESs4hvvVUKxgIuFdWIXNZwc3WUN8EVT TDjr5BUS8orXXw+GUmyQvyZywRm1Gp0Kd40UUQDOd6Z3loHb2E/fh31e+JPcF7DJsP ZvZb3jYA0YN+g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C4E1A68FFD for ; Thu, 1 Jan 2026 17:51: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 EsL3rrjvC_1Z for ; Thu, 1 Jan 2026 17:51:53 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315112; bh=BDk4Ws/ufE56zj90m+kQNWxrzSTvSMCdNh8BVdcdmQw=; 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=Jpeug1W3PWgMKzGWfCYWMzzGag7KWpdkgg7qgv0Sb+rRnGKOLZepePbr7zlyZVgkr wuI1NYdu6j+c/RgVN5YMZxCFYyYZuyiHVBnQJxlCIFDJWj/6Rx5QJFkVE7XV+ZHefp +fT9MK2TzJ77bjdYt7n6jizu/IWibcghYFyQRXM25lnqx19pXtsnu9BChWrQK1XGjd fJ2KrEzCMofL1X52lhPBHtYSMQ6nuOOHLyUuKUHFtte/NS0zpeynjpZRrzx12k/3zX jBXMoxz8O0OBKJ/ReOAiLWrVtAMj8U+3KO/j4t3MmtCS2FUsx6e7IGMGIEuii97JZZ ZrgsnSWOgBybg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1D87469010 for ; Thu, 1 Jan 2026 17:51:52 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315109; bh=yiVP8HLA1mkUPVFWrHUYBZkJNerFDUhnA60IakuitXk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HkFip4PPnrFnDLmrIwslNhWPxrfRcFJN4DJ4hF5bYxmryZCuo6UQDy/sFNfQLKQuY pB95nvwYbXxJUd34RMuHt+n3Y6fjmmsQ1swW6Mq4iTu+BEbis1TYkF9J8j9xKAo6iy 0sft6+AUozgnxa6dnOogokxHE6UOu+gFveAqPcX1edn7ZX6fkxmcGvdAKJB0QOmJWs 5D7YqTPPlUuxCRfJH4w29s4DExEMM/649yodbkAXwVa19m2zVuKxrR2hEtaJZbI59D /3kHoRkFsH5q0KIylgepojmA6KHYf1b8np9aTw4UW1b+DLpUlF1xZJsKfR4MFCGu28 l73l4jeg7BVpw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E8D1D68313; Thu, 1 Jan 2026 17:51:49 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id iBfBlCROLmQo; Thu, 1 Jan 2026 17:51:49 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315109; bh=JynQcMwTEbamLUuFEdG7sGoFZhrD8ckN15WkNeAU55Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L0x7Y/ZP1QpLkLM71kKyK6Hx5jXZpy2u5KuwS0enNR39rO59xF9UClTtdp5f5k7qI J02CNRdc0gegwZ5G/QVJL5p/XeZ/5abE4BPqzaAEFH83eSSFdZ5WLzlIRwn96hy+iC sbxCQdCYmT+p9i1jHeB4ubuyF2petdSjOWpDTK88V8/ILBAQTPNNtLp3KW2QjejFhR cUnigr7H6AQwRAWKjGnsEEzCd2lvljlZKE+oij59c0rcrjluNOjbcqHC5iKDUSced8 CswKTH1L2qZXvxzY2ZklLejtEDHfF4tSp5fPGeYqwWIYmS7y6G7xr95SAvbJ/3wN0i mWvOf4gb2wapw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 54DD368F58; Thu, 1 Jan 2026 17:51:49 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:38 -0700 Message-ID: <20260102005112.552256-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: BMA7KV3YFNDEPNJKOVYP4PACYPYQZELT X-Message-ID-Hash: BMA7KV3YFNDEPNJKOVYP4PACYPYQZELT X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 08/30] mcheck: Add Kconfig option for caller string length 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 mcheck heap protection stores a caller string in each allocation header for debugging purposes. The length is hard-coded to 48 bytes in mcheck_core.inc.h Add a CONFIG_MCHECK_CALLER_LEN Kconfig option to make this configurable, allowing users to adjust the trade-off between the amount of debugging context and the memory overhead per allocation. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- (no changes since v1) Kconfig | 11 +++++++++++ common/mcheck_core.inc.h | 5 ++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Kconfig b/Kconfig index c28fddf5016..3b89f2c48dd 100644 --- a/Kconfig +++ b/Kconfig @@ -355,6 +355,17 @@ config MCHECK_HEAP_PROTECTION significantly increases memory overhead and should only be used for debugging. +config MCHECK_CALLER_LEN + int "Length of caller string in mcheck header" + depends on MCHECK_HEAP_PROTECTION + default 48 + help + Sets the maximum length of the caller string stored in each + allocation header. This string records the function/file/line + that allocated the memory, useful for debugging memory leaks. + Larger values provide more context but increase memory overhead + per allocation. + config SPL_SYS_MALLOC_F bool "Enable malloc() pool in SPL" depends on SPL_FRAMEWORK && SYS_MALLOC_F && SPL diff --git a/common/mcheck_core.inc.h b/common/mcheck_core.inc.h index 598a5d018ab..fa152790d45 100644 --- a/common/mcheck_core.inc.h +++ b/common/mcheck_core.inc.h @@ -73,7 +73,6 @@ // Full test suite can exceed 10000 concurrent allocations #define REGISTRY_SZ 12000 #define CANARY_DEPTH 2 -#define MCHECK_CALLER_LEN 48 // avoid problems with BSS at early stage: static char mcheck_pedantic_flag __section(".data") = 0; @@ -89,7 +88,7 @@ struct mcheck_hdr { size_t size; /* Exact size requested by user. */ size_t aln_skip; /* Ignored bytes, before the mcheck_hdr, to fulfill alignment */ mcheck_canary canary; /* Magic number to check header integrity. */ - char caller[MCHECK_CALLER_LEN]; /* caller info for debugging */ + char caller[CONFIG_MCHECK_CALLER_LEN]; /* caller info for debugging */ }; static void mcheck_default_abort(enum mcheck_status status, const void *p) @@ -212,7 +211,7 @@ static void *mcheck_allocated_helper(void *altoghether_ptr, size_t customer_sz, for (i = 0; i < CANARY_DEPTH; ++i) hdr->canary.elems[i] = MAGICWORD; if (caller) - strlcpy(hdr->caller, caller, MCHECK_CALLER_LEN); + strlcpy(hdr->caller, caller, CONFIG_MCHECK_CALLER_LEN); else hdr->caller[0] = '\0'; From patchwork Fri Jan 2 00:50:39 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1173 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=1767315118; bh=Ed+og2rfPz9ks2cw4yTeuKzxmeKQ0OlS12883G80fAI=; 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=eGbUsj/2/Hk4r7mpkRjrUO0IIZRmHqNsQS8iTjNBEfieZ0Nut5/l7oRcqWK0h1gW1 Blic9pc3AErF3Q2Kp5NK9gIUqR/6gm0UQvPnQW+SeZZqsU22Gu2M9LMj9tkXZ4joyc W6PLj+JYlKJxmTfEOwhdmba3sqDUwFyOINj1PUh+58BIri/mFdWeD0WT+0LLOvnvNt mHIvYEYYZAUbFggeqrKH/LuHj5lkF09qY87HDCk+o3alKgJdMaoqZzMYZ4lgPwu5Vc xPSkhs2JcGlDlZ33P3C7QnuSTXFbf4Jw3JCyEep+Ma5kDkNAYZ9Y7XxO0wJxbEc1vl JpnBeDQgIeSwg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 97F8769007 for ; Thu, 1 Jan 2026 17:51: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 CECE7_YwgFO2 for ; Thu, 1 Jan 2026 17:51:58 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315118; bh=Ed+og2rfPz9ks2cw4yTeuKzxmeKQ0OlS12883G80fAI=; 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=eGbUsj/2/Hk4r7mpkRjrUO0IIZRmHqNsQS8iTjNBEfieZ0Nut5/l7oRcqWK0h1gW1 Blic9pc3AErF3Q2Kp5NK9gIUqR/6gm0UQvPnQW+SeZZqsU22Gu2M9LMj9tkXZ4joyc W6PLj+JYlKJxmTfEOwhdmba3sqDUwFyOINj1PUh+58BIri/mFdWeD0WT+0LLOvnvNt mHIvYEYYZAUbFggeqrKH/LuHj5lkF09qY87HDCk+o3alKgJdMaoqZzMYZ4lgPwu5Vc xPSkhs2JcGlDlZ33P3C7QnuSTXFbf4Jw3JCyEep+Ma5kDkNAYZ9Y7XxO0wJxbEc1vl JpnBeDQgIeSwg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 87CFC68FFD for ; Thu, 1 Jan 2026 17:51:58 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315116; bh=cfyEcokymVFNC3aZA2grV9/K/wzKT5MpHez4bawXZmM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KYZ7bEDkCKmnO74gbZ+crdsfk+cyp2QoZ+WEScC76oOBpXIsKmLaV+GChVeaFh/P2 Lc/p5mLK5Dg8tWJibKXu62c44VvOyuJBOggoNaBPyIonpV9NwciKwl03bdpgoDawJ8 KgvryTz77ACkgasEfU0jJ0tuxxNzTW4CfE1BypPcSpVKMow8bclu/y+HvLJaXELY7l B2omw3QjXmpUpgOwsKGiaQ7lJ9UStEiJpMkIzxMtaPsqK45swNCCJMpUPNWBXgcNEp 5yf0iujAN9en89NhhbMoHGqBVsxu7ZRR2qqrk8fWmh+76SprXEmQOs5lALfl2Nf/a8 h6MeXlvndLiBQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2E75568FFD; Thu, 1 Jan 2026 17:51: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 5xuQ7Yybi0cL; Thu, 1 Jan 2026 17:51:56 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315110; bh=67rFhNp76sS2CJpWozdDjhkWWDZ2HNJ7V/YhEmlqss0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zj6e0xWzplxf/CkuctYkZOvvFHlTdU3opVmvM0aj6Hmwq2op+iIhLBaSD2wdvcXAD yj34XlllZLibZBe+p2B+NAUSJbX9LMYklVXg7zCqwWzwZHbDntTCN8sgYCwEjyWXPa KVxVwLeUDabQYFg72h5M6Cc56wAI+ssJHftOTULlG5KIeg7YRWVYN4DmetpgOiXccy Rapww7FBQvWhhjpKB9LeSwvFZtWsohqI00FsQKZlbJ5DbjF13GHk5QMwNJ/P+M6NUE b5v4NWJ00qxutB4uSmB6hWWWGmgNBofPlbWXKnfOMgU5aztzBrM3F9IkrONdBOLw0d YtJSrxHoXhBPQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 3C2F368F58; Thu, 1 Jan 2026 17:51:50 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:39 -0700 Message-ID: <20260102005112.552256-10-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: CPKKQRP3WJG3KIO2QUK32GHNBNZBDVKQ X-Message-ID-Hash: CPKKQRP3WJG3KIO2QUK32GHNBNZBDVKQ X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 09/30] mcheck: Skip mcheck overhead for pre-relocation allocations 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 When mcheck heap-protection is enabled, each allocation adds quite a bit of overhead for headers and canaries. While this is needed for the full allocator, it serves no purpose for pre-relocation allocations, since: 1. Simple malloc is a bump allocator that cannot free memory 3. Mcheck's corruption-detection provides no benefit for non-freeable memory Since the pre-relocation heap space is limited (typically <16KB), this overhead can exhaust the heap, causing boot failures. Fix this by bypassing mcheck hooks in dlmalloc(), dlfree(), dlmemalign() and dlcalloc() when called before relocation, directly calling the simple malloc functions instead. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- (no changes since v1) common/dlmalloc.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/common/dlmalloc.c b/common/dlmalloc.c index 62e1e0a77da..5069a95d9b3 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -5984,6 +5984,15 @@ static const char *mcheck_caller(void) void *dlmalloc(size_t bytes) { + /* + * Skip mcheck for simple malloc (pre-relocation). Simple malloc is a + * bump allocator that can't free, so mcheck overhead is useless and + * wastes the limited pre-relocation heap space. + */ + if (CONFIG_IS_ENABLED(SYS_MALLOC_F) && + !(gd->flags & GD_FLG_FULL_MALLOC_INIT)) + return malloc_simple(bytes); + mcheck_pedantic_prehook(); size_t fullsz = mcheck_alloc_prehook(bytes); void *p = dlmalloc_impl(fullsz CALLER_NULL); @@ -5993,7 +6002,15 @@ void *dlmalloc(size_t bytes) return mcheck_alloc_posthook(p, bytes, mcheck_caller()); } -void dlfree(void *mem) { dlfree_impl(mcheck_free_prehook(mem)); } +void dlfree(void *mem) +{ + if (CONFIG_IS_ENABLED(SYS_MALLOC_F) && + !(gd->flags & GD_FLG_FULL_MALLOC_INIT)) { + dlfree_impl(mem); + return; + } + dlfree_impl(mcheck_free_prehook(mem)); +} void *dlrealloc(void *oldmem, size_t bytes) { @@ -6020,6 +6037,10 @@ void *dlrealloc(void *oldmem, size_t bytes) void *dlmemalign(size_t alignment, size_t bytes) { + if (CONFIG_IS_ENABLED(SYS_MALLOC_F) && + !(gd->flags & GD_FLG_FULL_MALLOC_INIT)) + return memalign_simple(alignment, bytes); + mcheck_pedantic_prehook(); size_t fullsz = mcheck_memalign_prehook(alignment, bytes); void *p = dlmemalign_impl(alignment, fullsz); @@ -6033,6 +6054,16 @@ void *dlmemalign(size_t alignment, size_t bytes) void *dlcalloc(size_t n, size_t elem_size) { + if (CONFIG_IS_ENABLED(SYS_MALLOC_F) && + !(gd->flags & GD_FLG_FULL_MALLOC_INIT)) { + size_t sz = n * elem_size; + void *p = malloc_simple(sz); + + if (p) + memset(p, '\0', sz); + return p; + } + mcheck_pedantic_prehook(); /* NB: no overflow check here */ size_t fullsz = mcheck_alloc_prehook(n * elem_size); From patchwork Fri Jan 2 00:50:40 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1174 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=1767315122; bh=SjLJTnnLKx1Glp3ioMpZxFLmVmBaOxdYtiAMp6gMBg8=; 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=Q4l9IW8ml62EXNMiSL43sY0d0qStRJQP7Pfo+lZiW2uHinmIBjMRgLFck8h/j83J6 rtF3vfSozrE+nPIZTD5ipcF8BOIiRg33RVIOT5p8QZho8A9se6zcZkxRXz1jajju44 yIy7+yBt28/9KP57KPKTjcAA6ZIoL5SXBba82z0IJ6d3aRdX+iEuI2+Cx7E1flze0j l7f01cCRB3EcT0T9EDjNDaBEPuaxJ/i9uGIhkNeTQYdVDn/VVtw7zHAZDo5qO2iJbN iKbwg6rCo6ytCj+UKhg1MHFH4jNNmm+EvJJ+EazpAYCX3T+b4PAWiw3b6WliyRv9jT omHGkNN2GXszw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1EB6F68313 for ; Thu, 1 Jan 2026 17:52: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 hyDhXKEYRu4E for ; Thu, 1 Jan 2026 17:52:02 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315122; bh=SjLJTnnLKx1Glp3ioMpZxFLmVmBaOxdYtiAMp6gMBg8=; 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=Q4l9IW8ml62EXNMiSL43sY0d0qStRJQP7Pfo+lZiW2uHinmIBjMRgLFck8h/j83J6 rtF3vfSozrE+nPIZTD5ipcF8BOIiRg33RVIOT5p8QZho8A9se6zcZkxRXz1jajju44 yIy7+yBt28/9KP57KPKTjcAA6ZIoL5SXBba82z0IJ6d3aRdX+iEuI2+Cx7E1flze0j l7f01cCRB3EcT0T9EDjNDaBEPuaxJ/i9uGIhkNeTQYdVDn/VVtw7zHAZDo5qO2iJbN iKbwg6rCo6ytCj+UKhg1MHFH4jNNmm+EvJJ+EazpAYCX3T+b4PAWiw3b6WliyRv9jT omHGkNN2GXszw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0C28F68F56 for ; Thu, 1 Jan 2026 17:52:02 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315120; bh=CsAgQUSq0yWg1MS+i4ila8gVVAWBe0XPQm4m2CsXCpM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pDFC3lJ7jg/l0v+eQqLSWXe7YBv631Wk3wcECZ6JKJqn/pB+lTel1kg1LB8LuzExn CILgrl/+qacdigezK8cRKJIAV/SsekUtJq0m1/NrnglwIFtSGYZ0Opgb53+PO9qxyn KhgPcCHEsJ4nZk+RWsyVD1DOB6gopGhp0yYSGUt3J8BCAEhYP0vrQSdTm0LyOLAcYk FAbtwPs/hivq1OWL1jOaa999rdm/Dx1CeBtl4gcE6hefS526GYAA9UFOtA6fKfaBL0 skadtWnL4pF/T0i8QElRJvAOTc6qsSxpAWRNI+vpmmkk03Q/tgPiAoTqd1P02iNDp9 NxskFZ0ToVNXQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F03A168FFD; Thu, 1 Jan 2026 17:52: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 ene9YdGqm1hI; Thu, 1 Jan 2026 17:52:00 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315115; bh=OuBppOfD/GNFY1vPyClOqbYj2pu2mCqFRIjrT2HhGAM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z3QG067uT+kuXIXDhNJI6O5OCQBBJAzCFyFl644HCuCr2lMlNhWzmF7a4UVmFD3xv 3v3ZLxN0H+FzcA+eyTZe07h6XEqO9ZTnMZwy76k/R46UXI37aL6zGE2SY+Pzy899mK FrL9prnFFDt9MxCw0M7Ef5sDJj6v5SYzOJr+bA4p0a+80hGEL9A3fcCHhYiBvQfV3q r/BuL6dWBhdjfJz4MCA5mbl//7d3rQOh/N7ndtZk++bqc9RcMYmT61pSQYrnrV/ZSn WRQd8pnkvHywZpJ7CyABIlDSCc1WJIHwb4uA6yGhG0/4bQiHaobe7m3cO/tiHzeIbe IM+aRrTGhoNrg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D7C4868313; Thu, 1 Jan 2026 17:51:54 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:40 -0700 Message-ID: <20260102005112.552256-11-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: GQISEFPEWN5VR2NTL4DNOWJN7NY4NIX7 X-Message-ID-Hash: GQISEFPEWN5VR2NTL4DNOWJN7NY4NIX7 X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 10/30] Revert "lib: Add CONFIG_LIB_KMEM_CACHE for full kmem_cache support" List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass The memory leaks were in fact not coming from the kmem cache, so let's drop this unnecessary feature. This reverts commit e63fc511c3dadbc99b53611cea304bc2bb565888. Signed-off-by: Simon Glass --- (no changes since v1) include/linux/slab.h | 27 +++++++++++---------------- lib/Kconfig | 8 -------- lib/Makefile | 1 - lib/kmem_cache.c | 20 -------------------- 4 files changed, 11 insertions(+), 45 deletions(-) delete mode 100644 lib/kmem_cache.c diff --git a/include/linux/slab.h b/include/linux/slab.h index caaaa3d9e16..2b374641534 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -84,19 +84,24 @@ static inline void *krealloc(const void *p, size_t new_size, gfp_t flags) void *kmemdup(const void *src, size_t len, gfp_t gfp); -/* kmem_cache implementation / stubs */ +/* kmem_cache stubs */ struct kmem_cache { int sz; }; struct kmem_cache *get_mem(int element_sz); -#define kmem_cache_create(a, sz, c, d, e) get_mem(sz) +#define kmem_cache_create(a, sz, c, d, e) ({ (void)(a); (void)(e); get_mem(sz); }) void *kmem_cache_alloc(struct kmem_cache *obj, gfp_t flag); -#if CONFIG_IS_ENABLED(LIB_KMEM_CACHE) -void kmem_cache_free(struct kmem_cache *cachep, void *obj); -void kmem_cache_destroy(struct kmem_cache *cachep); -#else +static inline void *kmem_cache_zalloc(struct kmem_cache *obj, gfp_t flags) +{ + void *ret = kmem_cache_alloc(obj, flags); + + if (ret) + memset(ret, 0, obj->sz); + return ret; +} + static inline void kmem_cache_free(struct kmem_cache *cachep, void *obj) { free(obj); @@ -106,15 +111,5 @@ static inline void kmem_cache_destroy(struct kmem_cache *cachep) { free(cachep); } -#endif - -static inline void *kmem_cache_zalloc(struct kmem_cache *obj, gfp_t flags) -{ - void *ret = kmem_cache_alloc(obj, flags); - - if (ret) - memset(ret, 0, obj->sz); - return ret; -} #endif /* _LINUX_SLAB_H */ diff --git a/lib/Kconfig b/lib/Kconfig index 5ddf8125766..9c7eb27c392 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -396,14 +396,6 @@ config TPL_TINY_MEMSET config RBTREE bool -config LIB_KMEM_CACHE - bool "Enable full kmem_cache implementation" - help - Provide a proper kmem_cache implementation in lib/linux_compat.c - that tracks allocated objects. This is needed by subsystems like - ext4 that require cache management. When disabled, simple inline - stubs are used instead. - config BITREVERSE bool "Bit reverse library from Linux" diff --git a/lib/Makefile b/lib/Makefile index 3890a827d1c..e770c273a8c 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -136,7 +136,6 @@ obj-$(CONFIG_$(PHASE_)OF_LIBFDT) += fdtdec.o fdtdec_common.o fdt_print.o obj-y += hang.o obj-y += linux_compat.o obj-y += linux_string.o -obj-$(CONFIG_$(PHASE_)LIB_KMEM_CACHE) += kmem_cache.o obj-$(CONFIG_$(PHASE_)LMB) += lmb.o obj-y += membuf.o obj-$(CONFIG_REGEX) += slre.o diff --git a/lib/kmem_cache.c b/lib/kmem_cache.c deleted file mode 100644 index bff9329aa53..00000000000 --- a/lib/kmem_cache.c +++ /dev/null @@ -1,20 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * kmem_cache implementation for U-Boot - * - * Copyright 2025 Canonical Ltd - * Written by Simon Glass - */ - -#include -#include - -void kmem_cache_free(struct kmem_cache *cachep, void *obj) -{ - free(obj); -} - -void kmem_cache_destroy(struct kmem_cache *cachep) -{ - free(cachep); -} From patchwork Fri Jan 2 00:50:41 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1175 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=1767315124; bh=dvWZQH0P12UkVOpd3n+qZf3uKTt50ofMPRW82+vnC9Y=; 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=B8XBR6x9QCzhXY/PEP0iuY6m5ACnh1xTVrgbayQIbG04RyeJIxPMxpbVZT1JBsbay dbc7vA3EFWcXghTrPBoK3Vhq6/oGcT/1r8U7j5FEgukYSFa54sVaa5Re2852UXAfEF HgqcQFS5MaycE+roHC0+sD4P6CiamfwJphbRgR6U/0jqqQgxUBa4UV0jatSNrGPcK9 KQInmATw8UV9fRhlY2x0Z8C2jcZMByYEf8oU5QFxk85Z/OPueUk4FiJxhi3OLNa+st BWUtqKf3nTXODaIZ0tJ5iyEgoQ1NhY54NM6OGfb60I1slcLfl62DZ6Xykk8k0SKdwr a0sTmTnT9MfOw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BAAE36901F for ; Thu, 1 Jan 2026 17:52:04 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id XOAJljgjwZA2 for ; Thu, 1 Jan 2026 17:52:04 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315122; bh=dvWZQH0P12UkVOpd3n+qZf3uKTt50ofMPRW82+vnC9Y=; 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=GgeC3QOUHRcjlKRcW4/aJtVkRbwfDed56ID8/xH8V4en888PRnKcKwejBtJeqbpU5 nfW8BHHM8KSJ0ZrDSJpdjBbZVsx9Z9fzybnJ4aWRcpveNTNz0/1IHuLn59y9TewqJd YMvhYRpVbOZ77K4l+OmVdnUGM75fkgR5zxTi442g4m1yEJNH8cJbuknYFoUPuiEowR ijNrbAfEGIK1c4UmBW/uNAGq7dNrX/OQRv7vYVw+6eHxumskkwAg6t/1SghvSm2LTP EC9uXCOtL59+I/OVuHQ5P7AM8Na8PmToMPc8lfCk4XdPlJbSKcRhOEM+1bouJ8ctzE axEkcguIChjig== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A3D8669007 for ; Thu, 1 Jan 2026 17:52:02 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315120; bh=us5pwY5/2fFYHgm4zjgsTgDVHhAWo+f+CPVc7NwlDzM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mfcU19sLNMUiXSh7QI3TfoRVMZbghDQIgB0sxbXDZ+xOMM4xIkzlDF+bsUcG7rGXb eELs8ft2oIBCGMs6o8ge0wFCWae3ezBnjAvk2/XNGK7D0qdfowr+GRo5YEpPiX/5wg fOpIx3meSeso9H8hqyrt60lfBrWWM2DlBu4VI4WWE4thasPe8aQd/3JY3liOqsch1P Ivrw5k3kB4NsNa4wEjXz/jdRrHNFdFndim6diGtZmIKvyxDmbffV8D50A/Krkrn5ej 42hVKBVG6hAGczwi3+A5i8Cvogh7gPqmHSDp4JZZob0OD3mNx2rCJKTiMQybjAjLex oXj9s8/UuzYaw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F064A69004; Thu, 1 Jan 2026 17:52: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 HP25dzZp_Jq7; Thu, 1 Jan 2026 17:52:00 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315119; bh=W6/XkqrHF+DUiPi8E6mZc6bCln067vMIhDjlDj5I798=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pA9AmnUER/76IEu+Sv7gzZVwOJaUbYUI8xDs1+TK3KLh/b7GwbFob+0zUW6Xkr52a PEeWDeKR8tiBrZqLmVSuLMbTGp9rVK+FbBoTQWz9n4OqvSYe2zdCsW+jH6qxPgpkPJ VjtlMXKc+i3RRBFnTtHBkzkQUStLMlEygWr/cYP1jizEQDbSj2rc+Of0EHUZeCp8rs 7n2mtYm7lwJu3lLwGquOMtvSodv5Ulx3ROcp4J037rb9hOv1eWvRdHGngUIzWbjZQ/ mhJuRRKTYe11y9ZAIFtaPh6pH2PyA1UnbgxRKkDSaXfqEA+Pdjn0EYbTSL09DhDA66 Fn3zjUBIX0E5w== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 7934B68F56; Thu, 1 Jan 2026 17:51:59 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:41 -0700 Message-ID: <20260102005112.552256-12-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: XY5QMAXUR7RE7PPJ3RBAEKFYT3CD3DFP X-Message-ID-Hash: XY5QMAXUR7RE7PPJ3RBAEKFYT3CD3DFP X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 11/30] ext4l: doc: Document ext4l_msgs environment variable 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 for the ext4l_msgs environment variable which controls whether the ext4l filesystem driver prints mount messages when probing an ext4 filesystem. Co-developed-by: Claude Signed-off-by: Simon Glass --- (no changes since v1) doc/usage/environment.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/usage/environment.rst b/doc/usage/environment.rst index bc1141cb400..380a25a8d13 100644 --- a/doc/usage/environment.rst +++ b/doc/usage/environment.rst @@ -322,6 +322,12 @@ ethrotate anything other than "no", U-Boot does go through all available network interfaces. +ext4l_msgs + If set to "yes", the ext4l filesystem driver prints mount messages + when probing an ext4 filesystem, including the UUID, feature flags + and journal-recovery status. This is useful for debugging filesystem + issues. + httpdstp If this is set, the value is used for HTTP's TCP destination port instead of the default port 80. From patchwork Fri Jan 2 00:50:42 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1176 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=1767315131; bh=+VwixHsEgnj/K6Hx5Dm+fV6CcG+s4S+ps7DBnTOnPgo=; 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=gP2s9ZRPmlkY5ltpWN9/WiNNXPKnhe2Mp8uXWWbA9trCL8iJTDwlsMkoyzmZwfkZw 4Rau/FKpyB0ING4ppy9qGysToBZw+/eqUOOVYHECZSEuoldaynyIZnASFmyOpWKvs8 jcfCmoGkHLwaU46ghRF0/UagVCz5JS8CMXDZwPi/C6iENC2ghtAiWulSXbdgJW++z0 MqoVW7Pu24NoxkQzvXGbd17eB6EbvwjOHTIB8/pK8jR6Nb8Qy+brq5nb3aEaeUgHDd evKVd5MJU3M20L3KH3EHKGHPgHZSh8HKoLh76nzmcIgU1LP3Z6D1zHA+1ycW6xMVao a+4fSEt/aNkuw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9D7D168F56 for ; Thu, 1 Jan 2026 17:52: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 oYpORN3_CcwV for ; Thu, 1 Jan 2026 17:52:11 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315129; bh=+VwixHsEgnj/K6Hx5Dm+fV6CcG+s4S+ps7DBnTOnPgo=; 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=ecL9aB1PbNxIyTdsaHJtqcTdqygM5PffBFqZitEOmsrcEc/yXnN3+HgUhhZP+MjcG HzcNJ+eNDnx+broRaN9PH+b/qv7Asa9EGb/P/RSJAEJuqGn8eFTTY0AWLseLTZkNWV 5R4DLEZiSmSuLYhBQfngPS93E5POdC6gzOkG6+jgh7zM9NU6IgdTvRM+FiiQRQHBq9 YbF7BzjmhOKGZyc/tf+koQsin4uhueD8cHV9ACDNCGzNHAInHlTdJ6xsoIZ7vRKT92 dQdOzNE4IrTjHM2mdYSdi8l2ZLYAr9yaoAInqlQnYVQuQsTPMTV4GLeKe1gBb9Grg7 KTQD6MbZLVSYw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4673268F58 for ; Thu, 1 Jan 2026 17:52:09 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315127; bh=Fnw4oB8CzyP2cRsSfs6zjeETaPQakn0TG2eOt/APwK4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EV/BspvCH8HtrgFM/Xu6kkZ7QL9BKjfSOplw4FI1FEp+TgsgRYHA0NvH0UL88N7Oc X7DuDZrSb/cRSd8KniUa7iFcR4VHR4QNh5CFSVbyYVK/kG57BHIoUyck2YJIxXvE6r d4R1jhikkS397Z+adoXSL4XGWQAaMc8pSsG686uRRuddVIDvBu+AYvRKy3RLr3oGgQ yL500d6ydCAiMam3FqcOkIFdeZoFoVH0NkHwllFTFr4FZ8UE4ihFL9PznO/19M15i+ 5cn2BwoYWX6PjY3IgX/cYnTQLY8eFGJw77ZRfm/N2t8FB94mDnV8O8yWELGOtlX61B X2iIYU3NqBHkQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 20D7668F56; Thu, 1 Jan 2026 17:52: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 VfKzECTyO3x7; Thu, 1 Jan 2026 17:52:07 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315120; bh=oc8LbB9fPol8zy9BxeeMRA8mfae4O+Ud5NkMgcbzXxs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kNqPGfNZ1C7fmL740eQwYsinDGUEtXlOD85gvNqKFl3t1JCcRDMHyPmmn0DReV9xe diEl59erRCREF64XipahMW0sTe7H+pDj8pBQ/B5YgcKtFM14+dnI3Ry7w1YDtec0YR 6wp7sKMVeH8lPyNYFUOnlEJbEqfmQRZTftgy/RdVcUxzZEBQKNfN0ygS1La0FzxZLq wxEPgkUmVuK49OTSF0aRKLEE2Gw4SYgvz7iTu8UnPwpo/zbkiudMhrgRlCebqugRWb ztlmcE9t0LFpDamhjY1cg/qXDTzztfBqxx5si2lwj9acACbZhDM4NC+QPTPI3cyqf5 pk+sl70oORA9Q== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 66C8C68F58; Thu, 1 Jan 2026 17:52:00 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:42 -0700 Message-ID: <20260102005112.552256-13-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: GDPG7LSV4DIOBIQWF77GS6ZDOTHXGKT7 X-Message-ID-Hash: GDPG7LSV4DIOBIQWF77GS6ZDOTHXGKT7 X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 12/30] ext4l: Move message buffer functions to support.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 Move the message buffer functions from interface.c to support.c since they are internal support code rather than filesystem-interface functions. This keeps interface.c focused on functions called from the U-Boot filesystem layer. Functions moved: - ext4l_msg_init() - ext4l_record_msg() - ext4l_get_msg_buf() - ext4l_print_msgs() Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- (no changes since v1) fs/ext4l/ext4_uboot.h | 6 +++-- fs/ext4l/interface.c | 51 ------------------------------------------- fs/ext4l/support.c | 51 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 53 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 087d8394ab6..37a4abb537f 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -2892,12 +2892,14 @@ void bh_cache_clear(void); int bh_cache_sync(void); int ext4l_read_block(sector_t block, size_t size, void *buffer); int ext4l_write_block(sector_t block, size_t size, void *buffer); +void ext4l_msg_init(void); +void ext4l_record_msg(const char *msg, int len); +struct membuf *ext4l_get_msg_buf(void); +void ext4l_print_msgs(void); /* 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 7c37c99488a..aebcc17fd3a 100644 --- a/fs/ext4l/interface.c +++ b/fs/ext4l/interface.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -24,9 +23,6 @@ #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; @@ -42,10 +38,6 @@ static int ext4l_open_dirs; /* 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 * @@ -150,49 +142,6 @@ 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; -} - -/** - * 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) { diff --git a/fs/ext4l/support.c b/fs/ext4l/support.c index 72bf819c3d6..1fc0bc0aa21 100644 --- a/fs/ext4l/support.c +++ b/fs/ext4l/support.c @@ -10,6 +10,7 @@ */ #include +#include #include #include #include @@ -19,6 +20,13 @@ #include "ext4_uboot.h" #include "ext4.h" +/* Message buffer size */ +#define EXT4L_MSG_BUF_SIZE 4096 + +/* Message recording buffer */ +static struct membuf ext4l_msg_buf; +static char ext4l_msg_data[EXT4L_MSG_BUF_SIZE]; + /* * Global task_struct for U-Boot. * This must be a single global instance shared across all translation units, @@ -46,6 +54,49 @@ u32 ext4l_crc32c(u32 crc, const void *address, unsigned int length) return crc32c_cal(crc, address, length, ext4l_crc32c_table); } +/** + * ext4l_msg_init() - Initialise the message buffer + */ +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; +} + +/** + * ext4l_print_msgs() - Print all recorded messages + * + * Prints the contents of the message buffer to the console. + */ +void ext4l_print_msgs(void) +{ + char *data; + int len; + + while ((len = membuf_getraw(&ext4l_msg_buf, 80, true, &data)) > 0) + printf("%.*s", len, data); +} + /* * iget_locked - allocate a new inode * @sb: super block of filesystem From patchwork Fri Jan 2 00:50:43 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1177 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=1767315134; bh=P+jKATRgEQJg6gClbeeWMYD4DCDAJIhQ9F2NVsxA0CM=; 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=dtnFfNvSQRd9+9gPS/F8UBZ2h9hY9KE3uA6WiiR4lVHyh3fC+Ob0PPoDCg6KxUfmM Ih/Jq+t87GKm7wxmY2kjWfJa2xBQKAVl4zrKP7LaDB3EppwNAcJTKfny8iMSoTK9MR 3fJiAVVtSjeeh9LxQ5XXgvpF3ieWIsF2/VqmfKIFhLHYn2//1I6nRPlYv3BifT47l1 bvnxKyFOwFLITrZFoyWzpUigGfRHozYqB2Bzm1gwBbjfcolkn62pNwSn2+vveol+zR W0tH17hxnGpKaR4jZzJhHoeY124Ih5XmUDL+NwLcpkfQ9KJAdzessmUMFD9MyMtExv BzfPzyMoVjYiA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6E28669007 for ; Thu, 1 Jan 2026 17:52:14 -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 R3Y6dI7sZ_bM for ; Thu, 1 Jan 2026 17:52:14 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315132; bh=P+jKATRgEQJg6gClbeeWMYD4DCDAJIhQ9F2NVsxA0CM=; 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=G68TQ/V3MxgGPTiwyc6PSS37hmUxtdbua+X8d5M3Lb7SGSJ3M5ylzJcScsvkRUU4E lQwhNXBC0k3EiMuQ6wq2s0BgpGx6sp/CZ5ApP80EaX7RSwm9ZW0yKtrrxluhooVZrD Hwn1OUWwSf4u/+mUuO3GRzWqKkSwK4OO1lxa4qCxQiXZFe1r4POVCPLJk1UcgqHo8V V0vJUN0G4SoDR0xQchftYqXodI5ixndLWpsSslLiLT/eJQR/KeyCYTfB0RHCWsTPsu pOlXMu1YItceUAe94QdAu0wjhH5zzulSBugSf9535XahezL/fz4rBvD4wo05XLpgXs mt/CKX3CzJh/A== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 20DEE6901F for ; Thu, 1 Jan 2026 17:52:12 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315129; bh=X6YiCqOqXiz67XDDuIk8hYcK6I/MFsaWGH4kcX/fuO0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FkyR8AmAdk7I9lP3A2RD7Hco7q1ffQBB1D8fudVgNoEQxxA2EdYEyPdw5Ck6SxpCt qSzXQ/erhZwc77mzsqefcPYvw9IDqOHbtSADu46+MQLZuxz7mYx0w14x99YM87JymV tjVfrJEJLJMvNyzepQkdVzbckHzuSOfMNrbE4K9DlRYsEfcwOzivZk7wIq0Plva0bn DmyWMLorc7LjiBrc2zP0WfyP/LJCN4pI+u4f7J5weCUekVqkRQJfd0HteGSF8qoo28 +ZI6/dC6a6T/UwHfFJmexCIq8FZfk8DB4mG2hrgFWE0BNSosnb7q3hyMpZMHtCoGkB OqFL83p9Ju2bQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 495ED69004; Thu, 1 Jan 2026 17:52:09 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 4WYviqXD2HLA; Thu, 1 Jan 2026 17:52:09 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315125; bh=6ZiUoCI+j/L6XQ7m01+mAF5QbPZ4eiVT+zUCKHmdfkY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bj12UMaoCNXhzUX1O7oMWnvcxPX3OmBt6NZX5QgBwUWHwHbO6n7JTfqS1ODfU2jBn iMgR/6S748KmD+SOz/FyMFtPZtjO9utR79vsJra4GGOcTaRrR6fcTyUftCaOO9a3vt iIxuawkg2t5/7aW7E6SlXC6jogy+jm+LhrYfVtLR5eUg7Sjsslf3HmTXZZxh6NOhn+ PwbYFkh7GukjxtFO/jMUmGdIbi+LJ0AVM4PCvHDf2+luX2VUS6la42Tn1QXz7Tef4t kf5KOOiYLE6IgzOUd6D8ycpxO70oGo5W/MR/JqV8FFIrQE38iO2dE54UFcuFS6eLM7 3MmPdCPxf7Ucw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 1E5DA68313; Thu, 1 Jan 2026 17:52:05 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:43 -0700 Message-ID: <20260102005112.552256-14-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 2BYZB25364PD4I2XL6EYJZVGCJHYWKTB X-Message-ID-Hash: 2BYZB25364PD4I2XL6EYJZVGCJHYWKTB X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 13/30] ext4l: Add inode-tracking lists 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 U-Boot does not track allocated inodes, causing memory leaks when remounting filesystems. Add s_inodes list to super_block and i_sb_list to inode structures to track all allocated inodes, allowing proper eviction on unmount. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- (no changes since v1) fs/ext4l/ext4_uboot.h | 6 ++++++ fs/ext4l/support.c | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 37a4abb537f..78d44faa0db 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -682,6 +682,9 @@ struct super_block { const struct export_operations *s_export_op; const struct xattr_handler * const *s_xattr; struct dentry *d_sb; /* Parent dentry - stub */ + + /* U-Boot: list of all inodes, for freeing on unmount */ + struct list_head s_inodes; }; /* Block device read-only check - stub */ @@ -859,6 +862,9 @@ struct inode { struct rw_semaphore i_rwsem; /* inode lock */ const char *i_link; /* Symlink target for fast symlinks */ unsigned short i_write_hint; /* Write life time hint */ + + /* U-Boot: linkage into super_block s_inodes list */ + struct list_head i_sb_list; }; /* Inode time accessors */ diff --git a/fs/ext4l/support.c b/fs/ext4l/support.c index 1fc0bc0aa21..7f2bea4ca06 100644 --- a/fs/ext4l/support.c +++ b/fs/ext4l/support.c @@ -126,6 +126,10 @@ struct inode *iget_locked(struct super_block *sb, unsigned long ino) inode->i_mapping = &inode->i_data; inode->i_data.host = inode; INIT_LIST_HEAD(&ei->i_es_list); + INIT_LIST_HEAD(&inode->i_sb_list); + + /* Add to superblock's inode list for eviction on unmount */ + list_add(&inode->i_sb_list, &sb->s_inodes); return inode; } @@ -154,6 +158,10 @@ struct inode *new_inode(struct super_block *sb) inode->i_mapping = &inode->i_data; inode->i_data.host = inode; INIT_LIST_HEAD(&ei->i_es_list); + INIT_LIST_HEAD(&inode->i_sb_list); + + /* Add to superblock's inode list for eviction on unmount */ + list_add(&inode->i_sb_list, &sb->s_inodes); return inode; } From patchwork Fri Jan 2 00:50:44 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1178 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=1767315136; bh=VEkrcGz3tFAEm1Y+zLG9A4cvsoweE2xrjv6Ea0bLkrY=; 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=bLRPVVENkncUTa+ZBPW2OpdbYPRAyXhQFtXAUGMdWZB93TFfiqZdxjkDGiFS0buwV IwAcVjo1PUf3o4Zy/RYf3PluSuQKiTsixrpoE0ctcd2wqtNXeWg4u9qySUzUXwk3Ce RzsvEe9wfdYsqCUsCDeg/VuG8iAltH5gEOqNboCxTQZC5+oJXy6tRHGcesYi1SVPmI e5KXJFlAEjjcsq+OKHumh3mjHWaaGJx+9ElU8sg3tuiv1CVskBf5lqKGAmZTpDv+5P SuR8DHn6pRkL8ZOPgyEceog1tYe+T/4NjwStn/VfpPrAC+igvVZ5iitoce2+HuJ29Y x5fFBFeOLdJ6Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E683E69010 for ; Thu, 1 Jan 2026 17:52:16 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id OEjqLUl1mt0z for ; Thu, 1 Jan 2026 17:52:16 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315136; bh=VEkrcGz3tFAEm1Y+zLG9A4cvsoweE2xrjv6Ea0bLkrY=; 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=bLRPVVENkncUTa+ZBPW2OpdbYPRAyXhQFtXAUGMdWZB93TFfiqZdxjkDGiFS0buwV IwAcVjo1PUf3o4Zy/RYf3PluSuQKiTsixrpoE0ctcd2wqtNXeWg4u9qySUzUXwk3Ce RzsvEe9wfdYsqCUsCDeg/VuG8iAltH5gEOqNboCxTQZC5+oJXy6tRHGcesYi1SVPmI e5KXJFlAEjjcsq+OKHumh3mjHWaaGJx+9ElU8sg3tuiv1CVskBf5lqKGAmZTpDv+5P SuR8DHn6pRkL8ZOPgyEceog1tYe+T/4NjwStn/VfpPrAC+igvVZ5iitoce2+HuJ29Y x5fFBFeOLdJ6Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D55A769007 for ; Thu, 1 Jan 2026 17:52:16 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315134; bh=1jHgxVGPUE+J5Rb/fD+bFmsYxGEL++WDvB2BjqUvMuM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gX4/4ZIz8JYPhHDXkfndQ+WIOlYwtAcFmfOy4uKocdTvcF4xX7R8qfHHm1rOmQm7q wdBTyYiTMZzr1sCXp2gi0ujEvevgBwCceGGSf83rfhC7zTUbzgZ+aFKvcnwGRVSODJ uEK+QsSziE7I4rpYa4pUwM9/+Egt/C1kIJfmkWwCcP+EJVIQ92Zb6dEH2pddCAun6e Y2dZhjGtmS5Gfvqw0/DDH+NYQ4kfE2LF3m2r3eOK9lz7QgVmYY0ahCM0vNaBlx+MXM xubAnGe+pWg+P+xORC5iCN//II0Gk4UaFmy4BpoR1efDrjLKOBt9pCZq7uBU4uFZJh yMau830zmlzbw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 978206901F; Thu, 1 Jan 2026 17:52:14 -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 QMGp86RYOYw7; Thu, 1 Jan 2026 17:52:14 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315126; bh=326KITdzvMFyq+QDv1q+q+QTPMQ6JejK9C8ZhDQ1yIY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VyNZw1QIa4WnzpFkwaGJonZobXW1ylBjCvIhuCSbfgZizxit2+Tc9O75xosHe9vfb axZmoGMr6gk/+Q1mAyMZD+XGm8t5PdJ4CdiYsTkxRUhxaLq7kmlW/r2EDF//f8avwQ VZq58SwQpHxrbKq2O1Cm2UeP6sSNvCBew+D/Kq8UKi7xjMYZMWefZ2vP5MRnCEhny3 1MFMoWetWMA6+P2znXRHbRzyHpdR4/nty7uT4Q3crjTJSviAbQCnYtAMB0lKCTOi33 EAfympDuR7vjEuutnVHxZXRI3M8PVin0lfOi7qtIZQhdu7p4pEIhJilVy92BB7LgHB 4jEX2h1k0ROcQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 4A7F568FFD; Thu, 1 Jan 2026 17:52:06 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:44 -0700 Message-ID: <20260102005112.552256-15-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 4D3EMC3X7DFAVLGKJVYM6FZDBCET2RMS X-Message-ID-Hash: 4D3EMC3X7DFAVLGKJVYM6FZDBCET2RMS X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 14/30] ext4l: Fix a few problems with handling bh_cache 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 Several buffer cache issues cause problems when remounting: 1. bh_cache_insert() only checks block number, but the same block can be read with different sizes (e.g. superblock at 1K vs 4K). Check both block number and size when determining if already cached. 2. bh_cache_clear() leaves stale buffer references, causing memory leaks. Force the reference count to 1 before releasing since ext4 code won't access these buffers after unmount. 3. brelse() frees buffer heads when the reference count reaches zero, but cached buffer heads should only be freed by bh_cache_clear() during unmount. This causes a double-free. Add a BH_Cached flag to distinguish cached buffers from temporary ones: set BH_Cached in bh_cache_insert() when adding to cache, and in brelse() only free non-cached buffers when count reaches zero. Also fix a bit conflict: BH_OwnsData was using BH_JBDPrivateStart which conflicts with BH_BITMAP_UPTODATE in ext4.h. Move U-Boot private bits to start at BH_JBDPrivateStart + 1. Co-developed-by: Claude Signed-off-by: Simon Glass --- (no changes since v1) fs/ext4l/ext4_uboot.h | 15 ++++++++++++--- fs/ext4l/support.c | 28 ++++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 78d44faa0db..588670a8b62 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -521,12 +521,21 @@ struct sb_writers { #include /* - * U-Boot: marks buffer owns b_data and should free it. - * Use BH_JBDPrivateStart to avoid conflicts with JBD2 state bits. + * U-Boot buffer head private bits. + * + * Start at BH_JBDPrivateStart + 1 because ext4.h uses BH_JBDPrivateStart + * for BH_BITMAP_UPTODATE. */ -#define BH_OwnsData BH_JBDPrivateStart +#define BH_OwnsData (BH_JBDPrivateStart + 1) BUFFER_FNS(OwnsData, ownsdata) +/* + * U-Boot: marks buffer is in the buffer cache. + * Cached buffers are freed by bh_cache_clear(), not brelse(). + */ +#define BH_Cached (BH_JBDPrivateStart + 2) +BUFFER_FNS(Cached, cached) + /* Forward declare for get_block_t */ struct inode; struct buffer_head; diff --git a/fs/ext4l/support.c b/fs/ext4l/support.c index 7f2bea4ca06..0f68746d99a 100644 --- a/fs/ext4l/support.c +++ b/fs/ext4l/support.c @@ -258,9 +258,10 @@ static void bh_cache_insert(struct buffer_head *bh) unsigned int hash = bh_cache_hash(bh->b_blocknr); struct bh_cache_entry *entry; - /* Check if already in cache */ + /* Check if already in cache - must match block AND size */ for (entry = bh_cache[hash]; entry; entry = entry->next) { - if (entry->bh && entry->bh->b_blocknr == bh->b_blocknr) + if (entry->bh && entry->bh->b_blocknr == bh->b_blocknr && + entry->bh->b_size == bh->b_size) return; /* Already cached */ } @@ -272,6 +273,9 @@ static void bh_cache_insert(struct buffer_head *bh) entry->next = bh_cache[hash]; bh_cache[hash] = entry; + /* Mark as cached so brelse() knows not to free it */ + set_buffer_cached(bh); + /* Add a reference to keep the buffer alive in cache */ atomic_inc(&bh->b_count); } @@ -316,7 +320,12 @@ void bh_cache_clear(void) struct buffer_head *bh = entry->bh; bh_clear_stale_jbd(bh); - /* Release the cache's reference */ + /* + * Force count to 1 so the buffer will be freed. + * On unmount, ext4 code won't access these + * buffers again, so extra references are stale. + */ + atomic_set(&bh->b_count, 1); if (atomic_dec_and_test(&bh->b_count)) free_buffer_head(bh); } @@ -629,13 +638,24 @@ struct buffer_head *sb_bread(struct super_block *sb, sector_t block) /** * brelse() - Release a buffer_head * @bh: Buffer head to release + * + * Decrements the reference count on the buffer. Cached buffer heads are + * freed by bh_cache_clear() on unmount, so this just decrements the count. + * Non-cached buffers are freed when the count reaches zero. */ void brelse(struct buffer_head *bh) { if (!bh) return; - if (atomic_dec_and_test(&bh->b_count)) + /* + * If buffer has JBD attached, don't let ref count go to zero. + * The journal owns a reference and will clean up properly. + */ + if (buffer_jbd(bh) && atomic_read(&bh->b_count) <= 1) + return; + + if (atomic_dec_and_test(&bh->b_count) && !buffer_cached(bh)) free_buffer_head(bh); } From patchwork Fri Jan 2 00:50:45 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1179 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=1767315138; bh=x5k+rBIil0u2ygwLb11mvDNXae1RJgvv7TuJSb7eqRw=; 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=LvTYeU27HdM4uPAmUm5ZdUPEh2rXWVBsXz2zNrQMQGQzG0Slnqcfu4pbNDifquuzj gOdBikhdC8kjdb519GFlR0P6wi0/1Fs8zzB3TKuWxEKyX00uPTf5HxMJ4x1C+5FcCv Dnj4d+nIpO2YEuU381dzzDHncLY6KoWRrVX1pGXd+cIqneAeaXdNQUHAeUfzkk8zZC 1EaqXtwf7idAwCbUmRVKxD3/+WLiFe8Tw/PUzSJIqG5SINm14iD9xln7eFyK//aBA4 Pt9u90TSkIelZ7De3iSs8iVrJh5t3UptWT0+Ybl1p1PL1DdIGUX+IATlrApnBstf/s /VZovLpLBsWDg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D508C69007 for ; Thu, 1 Jan 2026 17:52:18 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id iuIKDcJYRo8x for ; Thu, 1 Jan 2026 17:52:18 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315138; bh=x5k+rBIil0u2ygwLb11mvDNXae1RJgvv7TuJSb7eqRw=; 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=LvTYeU27HdM4uPAmUm5ZdUPEh2rXWVBsXz2zNrQMQGQzG0Slnqcfu4pbNDifquuzj gOdBikhdC8kjdb519GFlR0P6wi0/1Fs8zzB3TKuWxEKyX00uPTf5HxMJ4x1C+5FcCv Dnj4d+nIpO2YEuU381dzzDHncLY6KoWRrVX1pGXd+cIqneAeaXdNQUHAeUfzkk8zZC 1EaqXtwf7idAwCbUmRVKxD3/+WLiFe8Tw/PUzSJIqG5SINm14iD9xln7eFyK//aBA4 Pt9u90TSkIelZ7De3iSs8iVrJh5t3UptWT0+Ybl1p1PL1DdIGUX+IATlrApnBstf/s /VZovLpLBsWDg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BD85268FFD for ; Thu, 1 Jan 2026 17:52:18 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315136; bh=DEpoGdp2/z251984gp2334Q4QRz3gTg6gYAF3/CtIzY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qGgX95upDtXERa+yqSr91Ylm81PmQM1+UZJrt3zuEKoV1pYpdS+/qd7qBj41rCbAf 6kuzskllbAslZ1DhG2jHqGpZkqZBu4rtxgPo5ExrRZXNQLKjq/iK5D5IPVllLXtWNW hsvgQ2lGo2QNd2LskUhIZ5COrQ9Q5KCU9RLSLWh7kboIe/5G0bVMhd5nzjPgiXO787 WG2cS848ywABSCuTjow7BGHis4BX2COHUoELSzUIPsbnQGH8T71jUQhN9H/jS1TmrI uoRcOmWwthQzPxb5PwC3t9yMJ5YjgYuGZfGmyZf5HPFE25omYD+64NSKAs7+QtkLGM N1GKBV61F0+rg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C968868FFD; Thu, 1 Jan 2026 17:52:16 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id SPVmRhtIT9yK; Thu, 1 Jan 2026 17:52:16 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315131; bh=rYMUK32LL51aSKz35OGM6a/fUrg4jcMYPiQTOpso2zc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ISHRpREsH1TUtwlN418kKou/ESSKczPL6bmBwA/w8oSjvpCwGtU/kma4sgpIjRrjQ rIzgKk8hPVPgCXmku+Hi2YPeA1aBzIzLYcZ7yrCFGpcJp5DXFgP/SUZTiu32JaQJKd BEw/8H+XI1M+asIAUd2G83K1eGVZ+vdPzg8GTZYhaezHjPt7eBj08F6gcPdgfusrOw I+cFGg1GUFtwwYBnz/JMOZ2cGMOfExd68/wWamsxjC5P0xdGCUrUvc65OCPiQcYDON RZehrGSeiqpdOEuiuIJzo2ExBe9WTRv03d5kxGx41JmRS6WJ0TOJV82KFz/szcXCoW IShvEpxywVTzw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id EEF8E69004; Thu, 1 Jan 2026 17:52:10 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:45 -0700 Message-ID: <20260102005112.552256-16-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: EGFP3B7EUJAR2UCDFSVTLOVBFXECDYBU X-Message-ID-Hash: EGFP3B7EUJAR2UCDFSVTLOVBFXECDYBU X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 15/30] ext4l: Clean up fully when unmounting 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 Resources are not properly released on unmount, causing memory leaks in long-running U-Boot sessions that remount filesystems. Add ext4l_free_sb() to release all resources on unmount: - Destroy journal and commit superblock - Release superblock buffer and unregister lazy init - Free mballoc data and release system zone - Destroy xattr caches - Free group descriptors and flex groups - Evict all tracked inodes - Free root dentry, sbi, and superblock structures Also: - Init the s_inodes list when allocating superblock - Free mount context (ctx, fc) after successful mount - Call destroy_inodecache() during global cleanup - Clear folio cache on buddy cache inode before iput() Co-developed-by: Claude Signed-off-by: Simon Glass --- (no changes since v1) fs/ext4l/ext4.h | 6 ++ fs/ext4l/ext4_uboot.h | 2 + fs/ext4l/interface.c | 135 ++++++++++++++++++++++++++++++++++++++++++ fs/ext4l/mballoc.c | 4 ++ fs/ext4l/super.c | 25 ++++++-- fs/ext4l/support.c | 24 ++++++++ 6 files changed, 191 insertions(+), 5 deletions(-) diff --git a/fs/ext4l/ext4.h b/fs/ext4l/ext4.h index 669d5522f27..a1c80dd7cdf 100644 --- a/fs/ext4l/ext4.h +++ b/fs/ext4l/ext4.h @@ -3947,4 +3947,10 @@ extern int ext4_block_write_begin(handle_t *handle, struct folio *folio, #define EFSBADCRC EBADMSG /* Bad CRC detected */ #define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */ +/* Cleanup functions exported from super.c */ +void ext4_group_desc_free(struct ext4_sb_info *sbi); +void ext4_flex_groups_free(struct ext4_sb_info *sbi); +void ext4_destroy_lazy_init(void); +void destroy_inodecache(void); + #endif /* _EXT4_H */ diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 588670a8b62..70ac403d9fd 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -1395,6 +1395,7 @@ struct folio *__filemap_get_folio(struct address_space *mapping, gfp_t gfp); void folio_put(struct folio *folio); void folio_get(struct folio *folio); +void mapping_clear_folio_cache(struct address_space *mapping); /* projid_t - project ID type */ typedef unsigned int projid_t; @@ -2095,6 +2096,7 @@ struct fs_context { /* ext4 superblock initialisation and commit */ int ext4_fill_super(struct super_block *sb, struct fs_context *fc); int ext4_commit_super(struct super_block *sb); +void ext4_unregister_li_request(struct super_block *sb); /* fs_parameter stubs */ struct fs_parameter { diff --git a/fs/ext4l/interface.c b/fs/ext4l/interface.c index aebcc17fd3a..ceedabdb727 100644 --- a/fs/ext4l/interface.c +++ b/fs/ext4l/interface.c @@ -22,6 +22,8 @@ #include "ext4_uboot.h" #include "ext4.h" +#include "ext4_jbd2.h" +#include "xattr.h" /* Global state */ static struct blk_desc *ext4l_dev_desc; @@ -142,6 +144,134 @@ void ext4l_clear_blk_dev(void) ext4l_mounted = 0; } +/** + * ext4l_free_sb() - Free superblock and associated resources + * @sb: Superblock to free + * @skip_io: If true, skip all I/O operations (for forced close) + * + * Releases all resources associated with the superblock including the journal, + * caches, inodes, and the superblock structure itself. + */ +static void ext4l_free_sb(struct super_block *sb, bool skip_io) +{ + struct ext4_sb_info *sbi = EXT4_SB(sb); + + /* + * Destroy journal first to properly clean up all buffers. + * If skip_io is set, the device may be invalid so skip + * journal destroy entirely - it will be recovered on next mount. + */ + if (sbi->s_journal && !skip_io) + ext4_journal_destroy(sbi, sbi->s_journal); + + /* Commit superblock if device is valid and I/O is allowed */ + if (!skip_io) + ext4_commit_super(sb); + + /* Release superblock buffer */ + brelse(sbi->s_sbh); + + /* Unregister lazy init and free if no longer needed */ + ext4_unregister_li_request(sb); + ext4_destroy_lazy_init(); + + /* Free mballoc data */ + ext4_mb_release(sb); + + /* Release system zone */ + ext4_release_system_zone(sb); + + /* Destroy xattr caches */ + ext4_xattr_destroy_cache(sbi->s_ea_inode_cache); + sbi->s_ea_inode_cache = NULL; + ext4_xattr_destroy_cache(sbi->s_ea_block_cache); + sbi->s_ea_block_cache = NULL; + + /* Free group descriptors and flex groups */ + ext4_group_desc_free(sbi); + ext4_flex_groups_free(sbi); + + /* Evict all inodes before destroying caches */ + while (!list_empty(&sb->s_inodes)) { + struct inode *inode; + struct ext4_inode_info *ei; + + inode = list_first_entry(&sb->s_inodes, + struct inode, i_sb_list); + list_del_init(&inode->i_sb_list); + /* Clear extent status and free the inode */ + ext4_es_remove_extent(inode, 0, EXT_MAX_BLOCKS); + ei = EXT4_I(inode); + kfree(ei); + } + + /* Free root dentry */ + if (sb->s_root) { + kfree(sb->s_root); + sb->s_root = NULL; + } + + /* Free sbi */ + kfree(sbi->s_blockgroup_lock); + kfree(sbi); + + /* Free structures allocated in ext4l_probe() */ + kfree(sb->s_bdev->bd_mapping); + kfree(sb->s_bdev); + kfree(sb); +} + +/** + * ext4l_close_internal() - Internal close function + * @skip_io: If true, skip all I/O operations (for forced close) + * + * When called from the safeguard in ext4l_probe(), the device may be + * invalid (rebound to a different file), so skip_io should be true to + * avoid crashes when trying to write to the device. + */ +static void ext4l_close_internal(bool skip_io) +{ + struct super_block *sb = ext4l_sb; + + if (ext4l_open_dirs > 0) + return; + + if (sb) + ext4l_free_sb(sb, skip_io); + + ext4l_dev_desc = NULL; + ext4l_sb = NULL; + + /* + * Force cleanup of any remaining journal_heads before clearing + * the buffer cache. This ensures no stale journal_head references + * survive to the next mount. This is critical even when skip_io + * is true - we MUST disconnect journal_heads before freeing + * buffer_heads to avoid dangling pointers. + */ + bh_cache_release_jbd(); + + ext4l_clear_blk_dev(); + + /* + * Clean up ext4 and JBD2 global state so it can be properly + * reinitialised on the next mount. This is important in U-Boot + * where we may mount/unmount filesystems multiple times in a + * single session. + * + * Even when skip_io is true (journal wasn't properly destroyed), + * we must destroy the caches to free all orphaned journal_heads. + * The next mount will reinitialise fresh caches. + */ + ext4_exit_system_zone(); + ext4_exit_es(); + if (IS_ENABLED(CONFIG_EXT4_WRITE)) + ext4_exit_mballoc(); + if (IS_ENABLED(CONFIG_EXT4_JOURNAL)) + jbd2_journal_exit_global(); + destroy_inodecache(); +} + int ext4l_probe(struct blk_desc *fs_dev_desc, struct disk_partition *fs_partition) { @@ -192,6 +322,7 @@ int ext4l_probe(struct blk_desc *fs_dev_desc, ret = -ENOMEM; goto err_exit_es; } + INIT_LIST_HEAD(&sb->s_inodes); /* Allocate block_device */ sb->s_bdev = kzalloc(sizeof(struct block_device), GFP_KERNEL); @@ -279,6 +410,10 @@ int ext4l_probe(struct blk_desc *fs_dev_desc, /* Store super_block for later operations */ ext4l_sb = sb; + /* Free mount context - no longer needed after successful mount */ + kfree(ctx); + kfree(fc); + /* Print messages if ext4l_msgs environment variable is set */ if (env_get_yesno("ext4l_msgs") == 1) ext4l_print_msgs(); diff --git a/fs/ext4l/mballoc.c b/fs/ext4l/mballoc.c index 47863efd1cb..1643fd54f27 100644 --- a/fs/ext4l/mballoc.c +++ b/fs/ext4l/mballoc.c @@ -3890,6 +3890,10 @@ void ext4_mb_release(struct super_block *sb) ext4_mb_largest_free_orders_destroy(sbi); kfree(sbi->s_mb_offsets); kfree(sbi->s_mb_maxs); +#ifdef __UBOOT__ + if (sbi->s_buddy_cache) + mapping_clear_folio_cache(sbi->s_buddy_cache->i_mapping); +#endif iput(sbi->s_buddy_cache); if (sbi->s_mb_stats) { ext4_msg(sb, KERN_INFO, diff --git a/fs/ext4l/super.c b/fs/ext4l/super.c index 9ed6f907b7a..48c87eb0e97 100644 --- a/fs/ext4l/super.c +++ b/fs/ext4l/super.c @@ -48,7 +48,6 @@ static int ext4_unfreeze(struct super_block *sb); static int ext4_freeze(struct super_block *sb); static inline int ext2_feature_set_ok(struct super_block *sb); static inline int ext3_feature_set_ok(struct super_block *sb); -static void ext4_unregister_li_request(struct super_block *sb); static void ext4_clear_request_list(void); static struct inode *ext4_get_journal_inode(struct super_block *sb, unsigned int journal_inum); @@ -1228,7 +1227,7 @@ static void ext4_percpu_param_destroy(struct ext4_sb_info *sbi) percpu_free_rwsem(&sbi->s_writepages_rwsem); } -static void ext4_group_desc_free(struct ext4_sb_info *sbi) +void ext4_group_desc_free(struct ext4_sb_info *sbi) { struct buffer_head **group_desc; int i; @@ -1241,7 +1240,7 @@ static void ext4_group_desc_free(struct ext4_sb_info *sbi) rcu_read_unlock(); } -static void ext4_flex_groups_free(struct ext4_sb_info *sbi) +void ext4_flex_groups_free(struct ext4_sb_info *sbi) { struct flex_groups **flex_groups; int i; @@ -1484,7 +1483,7 @@ static int __init init_inodecache(void) return 0; } -static void destroy_inodecache(void) +void destroy_inodecache(void) { /* * Make sure all delayed rcu free inodes are flushed before we @@ -3708,7 +3707,7 @@ static void ext4_remove_li_request(struct ext4_li_request *elr) kfree(elr); } -static void ext4_unregister_li_request(struct super_block *sb) +void ext4_unregister_li_request(struct super_block *sb) { mutex_lock(&ext4_li_mtx); if (!ext4_li_info) { @@ -3722,6 +3721,22 @@ static void ext4_unregister_li_request(struct super_block *sb) mutex_unlock(&ext4_li_mtx); } +/* + * ext4_destroy_lazy_init() - Free lazy init info if no longer needed + * + * In U-Boot, there is no lazy init thread, so this must be called after + * ext4_unregister_li_request() to free ext4_li_info when the list is empty. + */ +void ext4_destroy_lazy_init(void) +{ + mutex_lock(&ext4_li_mtx); + if (ext4_li_info && list_empty(&ext4_li_info->li_request_list)) { + kfree(ext4_li_info); + ext4_li_info = NULL; + } + mutex_unlock(&ext4_li_mtx); +} + static struct task_struct *ext4_lazyinit_task; /* diff --git a/fs/ext4l/support.c b/fs/ext4l/support.c index 0f68746d99a..0d365e28265 100644 --- a/fs/ext4l/support.c +++ b/fs/ext4l/support.c @@ -897,3 +897,27 @@ void folio_get(struct folio *folio) if (folio) folio->_refcount++; } + +/** + * mapping_clear_folio_cache() - Release all folios in an address_space cache + * @mapping: The address_space to clear + * + * Releases the cache's reference to each folio. If no other references exist, + * the folio will be freed. + */ +void mapping_clear_folio_cache(struct address_space *mapping) +{ + int i; + + if (!mapping) + return; + + for (i = 0; i < mapping->folio_cache_count; i++) { + struct folio *folio = mapping->folio_cache[i]; + + if (folio) + folio_put(folio); + mapping->folio_cache[i] = NULL; + } + mapping->folio_cache_count = 0; +} From patchwork Fri Jan 2 00:50:46 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1180 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=1767315141; bh=+TvWHc5l6w6zh390oqnCCf7ugIpZBAhWpZMXlPHM7jU=; 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=GAvaJfePf45E8b+8HYwZTozZx7yDcgTJ5nIHleBp5xc4LUq443dZtS1Q2anWjklib SdzFd3FN6FsFAoUg/ioEd8ue0qR6BhRsST4h5on4/bFO2YOcHvEG5ioK+O3hhi57iO ceqQlanfmsdon8qa1VzQL5qgwyk+zcn1GZP9/BVCMBg6asfoDd0HPD3nXcqTg4RN0Q 5u7E/GCS3XOvUZn/WR39g+FPE2uFLAww2WzW9Bg+HnjhVyRDu0qR0leStzbUcdejCu mAF5UV3OBg9XEcqZGarjNdGPeB39k8hHH1l+qUoccI+pO/fX0XdH++QUQSkVKoiC6Z UiGpH5UIeqMVA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3791769031 for ; Thu, 1 Jan 2026 17:52:21 -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 mx1YMZzppCxp for ; Thu, 1 Jan 2026 17:52:21 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315139; bh=+TvWHc5l6w6zh390oqnCCf7ugIpZBAhWpZMXlPHM7jU=; 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=R28duESmD8yp2VLVjiUdjoN4toLAbtGOICW+8y9iP7WmBLBHYQBYBve0jhZZ7bvmD RhHjfTtAvKDxbzLe12VdVCV5HztRpMdLDHXijxyNY7fJwoBBccsEBmn8Dh4LV8AzPP +NlVQ0rik11qSj8L3xrRUX0nH5sLaz/wNhTTHO57Mh/hxeeR/NF4gSCge7Sf5TN+dX 4fK4f7rUSP6xEeemh/FH6hJK71Xsrqxk5l8f2Ht5A48FuYRDvOq7i2pGBikbCOBxBY u5dr/go45I7+pTHsQWoDN4CAPn8xN3Ktk1ahbDKX7wQ69q0Y03m03rP4fsYLkE7HvP 1CBkdN8/IYkaw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 337E768FFD for ; Thu, 1 Jan 2026 17:52:19 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315136; bh=7wM9rqizbdaPGP2E0P6R05xOpdfDbx/+hCy/raNbzsM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JZ+q8IReRK0tnlzmeMlCjx2KP6IXz9uWedjw3+ITeAzcXVdaW4/3L17AYd+/uqCG8 vYuSjyQo8RK6uNIPj3jqpmvrAsB7zz7r/PSlkBLe+hF4v7ZFXDyRirLBc7k01xgCQ/ Q1Y1zuQ4TRhCgWit8c4l3YclaAFjT+j3wpZPcRJVvL8ztDNp92D5vzsYE4/KcJ46pK 305cM2e9CSBUzNSjJFM4AA/3ZApWAOPsL0gsxQnB8dXKe92YFX1UtEgXeP0bR7pMFS cejygewkY52RCNNJxrgYIwY09pWuHlcSzkDjYcVz352BYCamzYAY58aKbDDJjTP+iM hcX/zjm6LFROw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D391669004; Thu, 1 Jan 2026 17:52:16 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 2fKTmEXHXN6s; Thu, 1 Jan 2026 17:52:16 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315136; bh=rYY0yBrsB9sKzs56iCfT0C6M39Jct2HofTGzRCYcp5k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nPF2tDacQXimkz8fdnSCxrw67IQANfI0T/qkPRb9xgvjBua3yHfExqeYesd+2qSMH huOH8mb773UZRkCe2twJIelUu2UIO2rCDgnO/Sxn2IhNjopqmUZSBf0bcpBd7X9Dm9 /GvXtEOTfXx0eXcc1GW6jFgOeMBiv1ZQyxeLoRQvzpOafwzJC/MJn0F9nhtmOf9nqU mPqFonGbk9Dww7FNgOhgSn2f4jgPh/qP9trUFXsEn7ekekxRJYQXcxt/UzhPkO1diC ify51Ie4XzQz9uKhDITvZWXogHl1GmS0b+zFLrE6lAVeZmBKu0culBXsi8wsjIjrxX R5lszeEmqXN2g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id C24EE68313; Thu, 1 Jan 2026 17:52:15 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:46 -0700 Message-ID: <20260102005112.552256-17-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 76YP2FWE72QF6BYTS2MVZCJIAAU4JHVR X-Message-ID-Hash: 76YP2FWE72QF6BYTS2MVZCJIAAU4JHVR X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 16/30] ext4l: Remove duplicate atomic_add declarations 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 atomic_add() and atomic64_add() functions are now provided by asm-generic/atomic.h so remove the duplicate declarations from ext4_uboot.h and the implementation from stub.c Co-developed-by: Claude Signed-off-by: Simon Glass --- (no changes since v1) fs/ext4l/ext4_uboot.h | 4 ---- fs/ext4l/stub.c | 8 +------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 70ac403d9fd..4cfe9e6de89 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -2320,10 +2320,6 @@ void *kvzalloc(size_t size, gfp_t flags); #define kvmalloc(size, flags) kvzalloc(size, flags) unsigned long roundup_pow_of_two(unsigned long n); -/* Atomic operations - declarations for stub.c */ -void atomic_add(int val, atomic_t *v); -void atomic64_add(s64 val, atomic64_t *v); - /* Power of 2 check - declaration for stub.c */ int is_power_of_2(unsigned long n); diff --git a/fs/ext4l/stub.c b/fs/ext4l/stub.c index f072cb5713f..d328c6821a9 100644 --- a/fs/ext4l/stub.c +++ b/fs/ext4l/stub.c @@ -617,13 +617,7 @@ int percpu_init_rwsem(struct percpu_rw_semaphore *sem) return 0; } -/* Atomic operations */ -void atomic_add(int val, atomic_t *v) -{ - v->counter += val; -} - -/* atomic64_add is now a macro in ext4_uboot.h */ +/* atomic_add and atomic64_add are now in asm-generic/atomic.h */ /* Discard */ unsigned int bdev_max_discard_sectors(struct block_device *bdev) From patchwork Fri Jan 2 00:50:47 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1181 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=1767315141; bh=BLVge++0MGgPsDka5bCOAqKQ4QojhLPlWHcPpRZNPvI=; 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=QJJX/UAI/MZ3aB6mw26EJmK5tkw0nI9cnPI32RN0+Ri5u1spAUJqzfydJWcS01fkB VXCbIr7RbZ5Fe0RLsBxdcmTnHM/Uj+NCvxXyHrgQjnzgu6SsngyGpUQgcLqPvyzoNB m7vA7RET/FbYierVxSQSQ10SaNJmA4W4L1jwzCBzaIaLJP3LVrjQfFLp1un3OHQUol N3Si/oma+BvDtuuc4mcTDeoQGDgksUBZEYEsK8n6JSkzEhWWaN18cDZzRLGsNPKMAF gUsv5+9xh1mNWkP0Y40ppNTkJ2QwGffqjCrXFGFl7M8nFfSn+DSvbFgvG8xkZXvbXM U5GDk2BJmy1hw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7EE786901F for ; Thu, 1 Jan 2026 17:52:21 -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 PZnhVBO8y6w1 for ; Thu, 1 Jan 2026 17:52:21 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315140; bh=BLVge++0MGgPsDka5bCOAqKQ4QojhLPlWHcPpRZNPvI=; 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=JvJYabi7eTedZ5AkOBVAcduupY/TE4b0tp95qd/jb4Lhi42vNuCYFeeF2Ix+v9HC8 wg4SGPQXCRWjQ09t4NWO04oN3ebUc0d3Jxmy1OD89KY9VCIKNX8TlNTTzDLIqF4ZRQ LVpuRnPggsFDHcTL0p58VvxNGW5Xim8abiN8N7LwsgQXXv+bkmQhK4E+qtRKNx4K6r iJ5FE+uSTkelvnlsjotA4AYKgz1/zbDI+/mlBdV8MxIAi6nuZkIZOljadXpIesPJmC kUjjJVqklLYpBQs3/1O38HWrEWEmxCEfnSEWvwTRUo53eRLGvH1ONny71AOfoarMy2 ng/yDrTLw7vIA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 85E8D6902A for ; Thu, 1 Jan 2026 17:52:20 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315137; bh=+TjswyAogVdtr9DVCi9Rzr60mJa2ra8FzV2cDwu7kyc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YbBwT/TZBJ2h52ZdKK/qhv7avvJ+N2VeRI4NHKWnSuqV1M1ATrAFDeHIO8bv88N3S woGkRasXe4ykp+FFVIKCxkx3rjsM+SjGOFh+f/8MgC8JgIJf5E2vqzrUz2VafRYtqW u0soXzpOrcqpCuHIjU9SeXzU2N6uJQGLHESzysumOlHLz3+Z2/53dSbA6pMTqF9m8V Q7C+6Jf06scAduL9ccpGyT3M77Z6VwauxQWy2r0qcBrm1YLbuBs11h+/Z3mUnUYzpP ajUh3HwqmpTzQr1sPnaqtIoBp4mAWhlGIuS5CXUYcT5tfOq9QIB/8DZzOZ4/XW446e wtgj76e+CA99g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 748CC68F58; Thu, 1 Jan 2026 17:52:17 -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 3C8RlEZuZ0tK; Thu, 1 Jan 2026 17:52:17 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315137; bh=+MxqFUx5rKWuode0MaJsAzxufJoH44Ekndq3gFkTjSE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HKcfaTvLgt9AeG+Ps4RUWQRqmfHHmg0c2F3AwdPu6l6E0saYQapJbvB7W/39OYLnI 31Q5TejkfpsUy4Tp0cimXGdTnvbRZ+kaHG3YlGQ6brwOZJFu7rOIw4CQtydbIbmlj6 FcXqbDF6HXfo5jlQvfkErFFHvtIHsCVljPB5qnpHMSqEJtf1YwU63LcPiZ7ELFULYC YV9d6N22IEBr491SiOmr53VxKXHN3ZUSLmNSQg5G46iq47/cxe/oF0E3mLHFkM0huR f3ogHxcrjAhrdj400+rn439D/1xWcQSM+K4cXEXDDsHadAipTsSfi6sR422mAYFUQE 6f8kZbkI+rrgg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id AE5D168F56; Thu, 1 Jan 2026 17:52:16 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:47 -0700 Message-ID: <20260102005112.552256-18-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: TUMOY3ZP6GAT4GLXVEYCOTL3RZ7ZLATM X-Message-ID-Hash: TUMOY3ZP6GAT4GLXVEYCOTL3RZ7ZLATM X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 17/30] ext4l: Use the real crc16 implementation 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 crc16() stub always returns 0, which causes group-descriptor checksum-verification to fail for filesystems using the old CRC16 checksum algorithm (gdt_csum feature without metadata_csum). Replace the stub with U-Boot's real CRC16 implementation to allow mounting these filesystems. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- (no changes since v1) 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 4cfe9e6de89..1c87e2a1181 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -2153,8 +2153,8 @@ struct fs_parse_result { /* ctype */ #include -/* crc16 */ -#define crc16(crc, buf, len) (0) +/* crc16 - use U-Boot's implementation */ +#include /* Timer and timing stubs */ #define HZ 1000 From patchwork Fri Jan 2 00:50:48 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1182 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=1767315146; bh=UxhUCbUaX5bbgyl079MQ5VcECwh3Q7SqrzpQrtd6TfA=; 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=n+8+Jg2uiJq6cHQTitm152XIf9PCI/efZTCzLrl8kzr38XStTPwcvM03ehsomoUD0 QAAyFt/PXHzWplD5jMYTWtay4B596n/Fnm+GJVVLbwYjrpPicCGoo566x66GvJXuNA eiUubTQhPChkmS+DKDtjmjQd8S4krQnpVeZoAD2+K+Wv/Otxd69liGWORFuIa224+f LT1xQVL9QEdTHPVk+ZOl1BF21EITytiBM+zysCBFDLis7V9wtmZGdHWCc8StVp2/ef iXARZlLVGxoLxwWGn0slJvpcmLCaLepAbyea3WBfX0Bm5HkrEz6qpl2vig1w9tcNNF 9eXxl17boaC9A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0EECC69004 for ; Thu, 1 Jan 2026 17:52:26 -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 ZiiWrPi--9aI for ; Thu, 1 Jan 2026 17:52:26 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315145; bh=UxhUCbUaX5bbgyl079MQ5VcECwh3Q7SqrzpQrtd6TfA=; 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=WpocENExVoraOkPiCUq3spvzothPAdFa/i1fLcyrC81yfPO+XA92Yk6rCymuAt4+d ODoEgtoKVkpz+U6fjiTXgUEsxadOlHDzCqNgNd4oOSaK/Pjn/vJiqvNikQfuOKlh+I n65Gc6/AVIQ1oCNktsXaMU/38yxMNzAZUAWH2S94rcuTdKnRkYU42d3ct2A1ORkF2h yQ3t1mZTuYF4wHhsnnLQs7TYDxekudGJ2+15x2T5ON4gvP7rqMPefGszPUp1jUDvKn flYlKz3/pW35ITl3qagT80oz9CbjRM9PxSyQUvQXthjQBpaJzySi2IcaXfAIjiEKtc FYAstF1K4/E8A== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F24FF68F56 for ; Thu, 1 Jan 2026 17:52:25 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315143; bh=T5kDLzXcr2AJmWWW+XmSYMz5ru0G5VUNUV2DJL4IXaI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vCwGO4H8erU9mZ9JpC2QWzCgptzQ08kuI7agRih5fCtbiL0Rg0GkgU+s785E4jYVO UUy9Fu0nrNgfqnL+j5Xw+PCOM4+NvDqx20ASGI9EsorMToiiLVgpxg5htFqmbmHK+e w4g3QtzsfXv6Ef7kHQluH/tZgoQT+ELtd2twig+EDo0y9QUIjO9ZO3ieELNC7LuQrX FGfCCpGFhGFOhrC/Nx2mebQr+bFu9NcKNA2PNE9U7pGnvy8BWeBSTPr5PjyMXrBIkD 5WcHHQ+kP8/VhF8czZFhZYXOoa7YYQbcmvbR0a9scfEQ75xxaLuMrsA1ORDTrJTORt PO33qXMsP056g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C0A1E68313; Thu, 1 Jan 2026 17:52:23 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id IWuwL5j8NoJK; Thu, 1 Jan 2026 17:52:23 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315137; bh=vwHQeVxbRygfmSniQOgiCjA+kPs7yAxxyWZ5p4CDWlo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UCg4DlKZbqs5+GSpUCf67BSBC1EUUM7BMCpaft6wJbhe4ipVym1i0bNGQi6R0OaFx +736QweIC9KWkpyExGi9nuh2pfi2N2MsEL7Ojgpg1cfyHwQBoQYD5lIYpNvllvenog J+KAEGkujxH/P4cTvzZ5w/JOmqzx2O+3E7uw9NIXXghNoBnIFBUynAjFcDL5H/Hgt2 FqZdrRmXlM0tPltc6GWbisxXuPd4kXOtSgQHfakZ0AD0vVrARUoxLc3EhQNVNIS+Wy 2KA06zGyeFkm3dLAqdPNXNPcFwDSYf56SuRmKyRTaxrPxUSs17e72sih6I862qREKT gtVSU0d6hDRKA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 9837769025; Thu, 1 Jan 2026 17:52:17 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:48 -0700 Message-ID: <20260102005112.552256-19-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 3ZAKNWNUQ6GGRGX3YCVKCSB7KODLEQQH X-Message-ID-Hash: 3ZAKNWNUQ6GGRGX3YCVKCSB7KODLEQQH X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 18/30] ext4l: Add a few Kconfig dependencies 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 ext4l driver requires the filesystem framework (FS) and rbtree library (RBTREE) to build correctly. Add the first as an explicit dependency and 'select' the second, to prevent build failures when ext4l is enabled. Co-developed-by: Claude Signed-off-by: Simon Glass --- (no changes since v1) fs/ext4l/Kconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/ext4l/Kconfig b/fs/ext4l/Kconfig index 998f0f45474..be989208ec5 100644 --- a/fs/ext4l/Kconfig +++ b/fs/ext4l/Kconfig @@ -5,6 +5,9 @@ config FS_EXT4L bool "Enable ext4 filesystem support (Linux port)" + depends on FS + select RBTREE + select CRC32C help This provides support for reading images from the ext4 filesystem, using code ported from Linux. This is mutually exclusive with From patchwork Fri Jan 2 00:50:49 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1183 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=1767315150; bh=mcIQHI7m16JvlQtS+vQ3Ej/u6U5gPSTc2l4dE0OFOwI=; 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=Tuns54BjAnX4I73qc7pYD78rXG8j+bqErjN0EOcvj3chbI6tDmvGSDtkBriV2AR6w bGFxVQjxXfphY9MNHfpUtq/mvJmvXktVFW5r2Ztn/DhrguY+PGjl5aycymS2ikFnv7 zHXUZ1dCuyDA1nT9xdO+MPoBeRht4c4axu7VHJ1eXHisjZYuY9v+0yeGH2t+JQ4crX y8JiyXG31DTwrQ2xyKhfEE38XpMcpHIVP8+frSlcGJI5KwS74lP6GUTAt5PUi3fMo5 sGGLbjWPuMsCdf1TtKXgMS551HC3g4tqrqXJOmSZHMbXSxERNPlDQeKBKmL4Cu3o1E fvxl6EDAskVBw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8139069004 for ; Thu, 1 Jan 2026 17:52:30 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id rO-Csodw2ht7 for ; Thu, 1 Jan 2026 17:52:30 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315150; bh=mcIQHI7m16JvlQtS+vQ3Ej/u6U5gPSTc2l4dE0OFOwI=; 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=Tuns54BjAnX4I73qc7pYD78rXG8j+bqErjN0EOcvj3chbI6tDmvGSDtkBriV2AR6w bGFxVQjxXfphY9MNHfpUtq/mvJmvXktVFW5r2Ztn/DhrguY+PGjl5aycymS2ikFnv7 zHXUZ1dCuyDA1nT9xdO+MPoBeRht4c4axu7VHJ1eXHisjZYuY9v+0yeGH2t+JQ4crX y8JiyXG31DTwrQ2xyKhfEE38XpMcpHIVP8+frSlcGJI5KwS74lP6GUTAt5PUi3fMo5 sGGLbjWPuMsCdf1TtKXgMS551HC3g4tqrqXJOmSZHMbXSxERNPlDQeKBKmL4Cu3o1E fvxl6EDAskVBw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 699B968F56 for ; Thu, 1 Jan 2026 17:52:30 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315148; bh=z3W7KOuCUW5T9mSfsvMBVbZ9/oyi6dRkDFSs/kD2FI0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AfwxdF/NOg7bpZ0Vh8p95mKWJyC1/kjYa34PLH1b3k8/e4zE/Pc13QDL9m8Cz7rwp Z19dNcVTR7Z10z1mrxFRDvWQdsSMYVBRg3J7Vjo17kuH6Omu96gBkY/7zjtcTr+Xhe 7KYuS7o/1xOsHPKCRG0sUST11mI9w7BNxkXb4F0MwOnfvE1UTmem/hQQR5qY0UrFgO tGyw/Jju7MFjXcPcfOOwr/Tuhni/Pntqvh1HetpZs/s2cIPnsba30QECoMrpkCO7nz cVodKVjAGOW62J1HSlt4bTJhuZtzHHyybDxwfs6WFTH9nOPwMKFvXltEyMxi1bzarZ 5Xi4mCDef4i5g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7068E68F56; Thu, 1 Jan 2026 17:52:28 -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 ZTMF7T95fyGx; Thu, 1 Jan 2026 17:52:28 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315142; bh=4ObZNFXPA5wp+F7hdLjecgnBN78v1Ae+jIW3diBWgO0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TXz+ugtq8GR0WbZS017H9pItc1TCT0B2uOb3mmH6xA/Bh1KoQ6hdzDc12HWqFrg1l TmA1T2M2+wCOD8B9RDh4UIrmnZLLq+8H3Z3oMbdZVbea/G2Gdg7+rgus1q/ZC9lPeG QTO249joRWN66aOrMwHbiqKDCNEfO0yss3QYj1zcnxJ02m0FhQQXFaD+m1TR0esWJI 50t2mgj8Wwoma7XCwZ75LtjEQvlqOvMZBB+3Fg+Ee5mhotQkgozSBwPAaIYSvGVLPT F9ko3QKt/zSK/1pjo7oDElM1sQJWx1utLUD+MattFh8Ia013bWKWXt+UE78aq0O3l9 gmlQS+t9sI7aQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 3D91D68F53; Thu, 1 Jan 2026 17:52:22 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:49 -0700 Message-ID: <20260102005112.552256-20-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: IMBFF4UCPHR4RIWZQ5PLZBTXAFE47D3K X-Message-ID-Hash: IMBFF4UCPHR4RIWZQ5PLZBTXAFE47D3K X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 19/30] ext4l: Add bh_cache_release_jbd() to clean up journal references 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 bh_cache_release_jbd() to forcibly release any journal_heads still attached to buffer_heads after journal destroy. This must be called after journal destroy but before bh_cache_clear() to ensure all journal_heads are properly released, even if journal destroy did not fully clean up (e.g., on abort). The function clears b_bh in each journal_head to prevent use-after-free when the buffer_head is later freed, and resets transaction pointers. Co-developed-by: Claude Signed-off-by: Simon Glass --- (no changes since v1) fs/ext4l/ext4_uboot.h | 1 + fs/ext4l/support.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 1c87e2a1181..a5c0eba6f15 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -2901,6 +2901,7 @@ void free_buffer_head(struct buffer_head *bh); /* ext4l support functions (support.c) */ void ext4l_crc32c_init(void); +void bh_cache_release_jbd(void); void bh_cache_clear(void); int bh_cache_sync(void); int ext4l_read_block(sector_t block, size_t size, void *buffer); diff --git a/fs/ext4l/support.c b/fs/ext4l/support.c index 0d365e28265..71c906d9c88 100644 --- a/fs/ext4l/support.c +++ b/fs/ext4l/support.c @@ -335,6 +335,42 @@ void bh_cache_clear(void) } } +/** + * bh_cache_release_jbd() - Release all JBD references from buffer cache + * + * This must be called after journal destroy but before bh_cache_clear(). + * It ensures all journal_heads are properly released from buffer_heads + * even if the journal destroy didn't fully clean up (e.g., on abort). + */ +void bh_cache_release_jbd(void) +{ + int i; + struct bh_cache_entry *entry; + + for (i = 0; i < BH_CACHE_SIZE; i++) { + for (entry = bh_cache[i]; entry; entry = entry->next) { + if (entry->bh && buffer_jbd(entry->bh)) { + struct buffer_head *bh = entry->bh; + struct journal_head *jh = bh2jh(bh); + + /* + * Forcibly release the journal_head. + * Clear b_bh to prevent use-after-free when + * the buffer_head is later freed. + */ + if (jh) { + jh->b_bh = NULL; + jh->b_transaction = NULL; + jh->b_next_transaction = NULL; + jh->b_cp_transaction = NULL; + } + clear_buffer_jbd(bh); + bh->b_private = NULL; + } + } + } +} + /** * bh_cache_sync() - Sync all dirty buffers to disk * From patchwork Fri Jan 2 00:50:50 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1184 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=1767315155; bh=6TArTX8z1hWRFlsgFxs7zzQK3iSsDuVKiI9yP1ucBZY=; 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=Rhp/jupJ78lLdkXRY+kNO7K8hTB6aZ2L5dlgvkAj/WmE06QyYmVoA9dKTf6So0Q2Z UUr3jjLmIb+whoMboS/bjYjqeKrZkluvrQw/CFhAYXegEKc8CsvpugMRFyNEnRJhr3 5vizpgmvBYp3hTjML16aKa52HeJDi77hGCKqpa2w4iieuXvuDV9QuyuErW8WBIjQPS Oa2tt2QFSywYurLjDkP3ShxXAtGksqItPbxzzJMiAr1yVpuvm7dcCbyDKbk4YnBnkr jWmT8e0QQGsPLGP74AwIxrZVf3RgqC1wCY/LrRR2ecHm5t/7HLiV1wRm8f51pXZOsG 2F4zXk3582AUA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5F8F769023 for ; Thu, 1 Jan 2026 17:52:35 -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 peXjxoyOCV41 for ; Thu, 1 Jan 2026 17:52:35 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315155; bh=6TArTX8z1hWRFlsgFxs7zzQK3iSsDuVKiI9yP1ucBZY=; 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=Rhp/jupJ78lLdkXRY+kNO7K8hTB6aZ2L5dlgvkAj/WmE06QyYmVoA9dKTf6So0Q2Z UUr3jjLmIb+whoMboS/bjYjqeKrZkluvrQw/CFhAYXegEKc8CsvpugMRFyNEnRJhr3 5vizpgmvBYp3hTjML16aKa52HeJDi77hGCKqpa2w4iieuXvuDV9QuyuErW8WBIjQPS Oa2tt2QFSywYurLjDkP3ShxXAtGksqItPbxzzJMiAr1yVpuvm7dcCbyDKbk4YnBnkr jWmT8e0QQGsPLGP74AwIxrZVf3RgqC1wCY/LrRR2ecHm5t/7HLiV1wRm8f51pXZOsG 2F4zXk3582AUA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1A1DD68F58 for ; Thu, 1 Jan 2026 17:52:35 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315153; bh=ex+V+EswiWAXKUhYfsm+GWumW4hs+K0yeddTOjbEWgg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Psvlg7MZR7saU5eG04147l5wq9LBEnOq6PU6WtECvfgARs0ERSxk1lAt+A7SFDdf8 RIq7Vbi5pb9YKbNKLUfFbnGIVWjvT+lpSRdugfiNbtkkUxwDib1P07uYgVspP2xLD8 5erHEIuDt+4V6qiBRE42fuGm6ntrTOQFPiNNogm8/C+OA+UkJ2i3aDZKmaE4Ip7HJu 9CpdyomrWFxhKgtRiUPcAKSrHLi980qi/zNdLX3RYMF1PK2gJ2zfUH3mHA3fGkGQfi 7cNWWs062lWHcSaDUN/MYF6nruDvFOzFrJUZGqlPJFs47jK0H2PPgA7PdlWAsO4tBf LxPTZq9eEqVuA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1F84368F58; Thu, 1 Jan 2026 17:52:33 -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 qDzlBLpSrKj6; Thu, 1 Jan 2026 17:52:33 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315147; bh=zRzMd9tKFkHSqIvPJUORtjvD3qIVbHvZL8itEUEGPVs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kUkXsfwUcu/8BvL5ufuEzIcT0BjRau/RPt1iVnFzOcJOPbTNcCpjpKXajPJei4kpW Q2v6IHVjnj2Y2/leGsC0lWfk4YSId9BcP3WG+WCzxAw1YNM3K8vX+D73KYtLgAewHj 36izTS+FsxeYSQeZ4JhqpgmVxBNuoDSkBZvMrz/MOfBgCyIPx+bH887CzsvG3xhbDB t/SPZ09AVxzPscNNHYptf9bVm1EP1aLhWuDxEs8LvUetkGjtcEavsuPv+gxCGPPjzW rb/jCrVO/5VgO37AyXlb3s6ru81GbSOc6l+GyfFg2A6V58pM4/df3IVJ0qg/j2hTKK Ke4LTEFTXH/PQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D9AC868313; Thu, 1 Jan 2026 17:52:26 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:50 -0700 Message-ID: <20260102005112.552256-21-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: E3VTQUOZB75F5IX5B7LZFWPWTIWUEQLY X-Message-ID-Hash: E3VTQUOZB75F5IX5B7LZFWPWTIWUEQLY X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 20/30] ext4l: Add safeguard to close previous mount in probe 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 When running multiple filesystem tests in sequence, probe may be called without an explicit close of the previous mount. The old device may have been rebound to a different file, making I/O to it invalid. Add a new ext4l_close_internal() function with a skip_io parameter to handle this case. When skip_io is true, it skips journal-destroy entirely since the device may be invalid. It will be recovered on next mount. Also call the ext4- and JBD2- cleanup functions to properly reset the global state for subsequent mounts: ext4_exit_system_zone(), ext4_exit_es(), ext4_exit_mballoc(), and jbd2_journal_exit_global() This ensures the caches are destroyed, thus freeing all orphaned journal_heads, even when skip_io is true. Co-developed-by: Claude Signed-off-by: Simon Glass --- (no changes since v1) fs/ext4l/interface.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/fs/ext4l/interface.c b/fs/ext4l/interface.c index ceedabdb727..301e28af3b8 100644 --- a/fs/ext4l/interface.c +++ b/fs/ext4l/interface.c @@ -286,6 +286,17 @@ int ext4l_probe(struct blk_desc *fs_dev_desc, if (!fs_dev_desc) return -EINVAL; + /* + * Ensure any previous mount is properly closed before mounting again. + * This prevents resource leaks if probe is called without close. + * + * Since we're being called while a previous mount exists, we can't + * trust the old device state (it may have been rebound to a different + * file). Use skip_io=true to skip all I/O during close. + */ + if (ext4l_sb) + ext4l_close_internal(true); + /* Initialise message buffer for recording ext4 messages */ ext4l_msg_init(); @@ -855,12 +866,7 @@ int ext4l_read(const char *filename, void *buf, loff_t offset, loff_t len, void ext4l_close(void) { - if (ext4l_open_dirs > 0) - return; - - ext4l_dev_desc = NULL; - ext4l_sb = NULL; - ext4l_clear_blk_dev(); + ext4l_close_internal(false); } /** From patchwork Fri Jan 2 00:50:51 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1185 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=1767315160; bh=1prV6nGMCB+M3cnrN/31GZqnCy1J2GhDaE6MmY/mMJM=; 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=cI882lCfQu3ZNnnw9K2P/Ue/hCc9uXqs9dq2RFtuB+xOgqkIHo/uKfS7FeKUEM6TG QBydlhoEtdo/3IMNinLU5Ni4YuJoMg35uA7oUkvBlsl3sftYyiyubbAKvcUTeKOwmu 7qNViTB4PeqmbgYmsJgaqlD34J97x6OdYyGfB+3ey3glay3Nq+goi5y09CqTtfsm82 Z55Dyg3h834LTD9ibu3VvIpVN9EGaN3uQx1htMpZ5BXstENbGZWekkNgjSiREVSoxK qbP9gFi725IN7BA8II6dATLelqe5TvP+k4qQ2O990mYmKLGzP0FW45dTW5FqPywfwJ RSLEVRQ1yZqug== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CD5EB68313 for ; Thu, 1 Jan 2026 17:52:40 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id lwlP9g5IY2_c for ; Thu, 1 Jan 2026 17:52:40 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315160; bh=1prV6nGMCB+M3cnrN/31GZqnCy1J2GhDaE6MmY/mMJM=; 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=cI882lCfQu3ZNnnw9K2P/Ue/hCc9uXqs9dq2RFtuB+xOgqkIHo/uKfS7FeKUEM6TG QBydlhoEtdo/3IMNinLU5Ni4YuJoMg35uA7oUkvBlsl3sftYyiyubbAKvcUTeKOwmu 7qNViTB4PeqmbgYmsJgaqlD34J97x6OdYyGfB+3ey3glay3Nq+goi5y09CqTtfsm82 Z55Dyg3h834LTD9ibu3VvIpVN9EGaN3uQx1htMpZ5BXstENbGZWekkNgjSiREVSoxK qbP9gFi725IN7BA8II6dATLelqe5TvP+k4qQ2O990mYmKLGzP0FW45dTW5FqPywfwJ RSLEVRQ1yZqug== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B3B4768F58 for ; Thu, 1 Jan 2026 17:52:40 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315157; bh=YuLznqL6Eg+VMPq1MGzNeBaI1jNnUrPBn/2KKH6LwX4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wsGrXOGDjD/xjE9tclFLpapyTK4yLoGgapzPC8NWYars3dndRhYIUyhwOACctSHVv yJAGaQKOnOpujPUuGNYTw4g6WWhYlBArRPwxq2vUyZtI8kO7GEPXHy30JP8fxQKZt8 93zWbKP9GtJ6pa6v2ZS9fCN3/SZDikrpWdCatZWFikMgF1UtVWDiEdjetQeDpmaaGQ ZixVO4xKM0FgN497IIzJdGwWkC5C41dQj8eLqBuc5p/s1LVY/pMasiZQhWo7oJFB0h r974dJUVisbMTkBnw/EwbKL7ZcECbsl1u+WZ1RPdp+3UlG+h5rzKGgNg9IZEODrN/j LBCWR6rtkunGw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D559768F58; Thu, 1 Jan 2026 17:52:37 -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 GSQ9581YUw49; Thu, 1 Jan 2026 17:52:37 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315151; bh=6ZRGRb4ZxPdgVImImakStOxmsE9ADzGNVWklf/a8mMA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lIYF9ySZkHP5tli69sRZ4xJGIaPfu6hiwYQ9+Y4usmhCzkVXjcpUB6/u1AqPgHmxa 1X9cnKLqi08STnx2NXmPzEQCmcATyBeGn0v3u+SXspN/TB7iw/l32/sDAcoVksBiGh GsFdtvnso5qvozgWJOh+DXWxllmqHXs2vI3MB6ugpYPtbunDkcbqrrENd+8nnQnpKC Td46SSuQKw56M1EnmttSTofsEpCV2K0eajRqWdZT4o+62ZX9dKhy2V2fzmUuVp6S05 NfORpzBGhhzK6iq94loZZ3gZOkr99bOSr14CApbcI/y0b8rEjAYaSL7E2uMIA8/Io0 sOSrHb90qKEyQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 800B568F53; Thu, 1 Jan 2026 17:52:31 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:51 -0700 Message-ID: <20260102005112.552256-22-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 72UJGDKSMUOF2CZR2YWU7ML573YNNNYM X-Message-ID-Hash: 72UJGDKSMUOF2CZR2YWU7ML573YNNNYM X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 21/30] ext4l: Prevent freeing buffer_heads with active journal_heads 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 When running filesystem tests back-to-back, buffer_heads could be freed while journal_heads still reference them. This causes use-after-free crashes when the journal code later accesses the stale b_bh pointer. Add protection in free_buffer_head() to skip buffers with JBD attached, since the journal owns a reference and will clean them up properly. Also add protection in brelse() to prevent the ref count from dropping to zero while JBD is still attached. Update comments in ext4l_close_internal() to clarify why cache cleanup is critical even during skip_io mode. Fixes crashes when test_fs13 runs after test_fs11 in the same session. Co-developed-by: Claude Signed-off-by: Simon Glass --- (no changes since v1) fs/ext4l/support.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/ext4l/support.c b/fs/ext4l/support.c index 71c906d9c88..4025d291fec 100644 --- a/fs/ext4l/support.c +++ b/fs/ext4l/support.c @@ -469,6 +469,15 @@ void free_buffer_head(struct buffer_head *bh) if (!bh) return; + /* + * Never free a buffer_head that has a journal_head attached. + * This would cause use-after-free when the journal tries to access it. + * The journal owns a reference and the buffer will be cleaned up when + * the journal_head is properly released. + */ + if (buffer_jbd(bh)) + return; + /* * Shadow buffers (b_private != NULL) share their folio with the * original buffer. Don't free the shared folio. From patchwork Fri Jan 2 00:50:52 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1186 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=1767315162; bh=2cDDP2brL4IYfQFv4iQmyR7T10hloeT0GvdceTGblCQ=; 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=giv/CdPYSW3A9b1myY/VhktmaA1T2H0rbJ+ye5PDk7fHReFZF2/JkUQdBZI6of4Wz z7zL6bKrID47mKsXzwsQhlQdNoYAT9cB8u4bVrL09LpSmj9RdGFenQazkp9MGnBUwX rKhuCGlSNBH4qlfuayXp+1CMz78L5b1GQtXLyDhyyrf4MNDJhm1qFq0YFl2j+UXkr7 Udhtqa9GFhupv6sKcH75OxQvPtcBCwhOmv0OVilc9IjDICnf93g/pI6xj77NfYKFBk gvN84lqTCc79bFQtymMotg5sJxRWpuKTMJJlMFzgbcVp6zpN6wMxVoL+mqKHdvQrNn TTV3PXWKm8qLA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C2E6568313 for ; Thu, 1 Jan 2026 17:52:42 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id VN41m7EgDE7V for ; Thu, 1 Jan 2026 17:52:42 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315162; bh=2cDDP2brL4IYfQFv4iQmyR7T10hloeT0GvdceTGblCQ=; 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=giv/CdPYSW3A9b1myY/VhktmaA1T2H0rbJ+ye5PDk7fHReFZF2/JkUQdBZI6of4Wz z7zL6bKrID47mKsXzwsQhlQdNoYAT9cB8u4bVrL09LpSmj9RdGFenQazkp9MGnBUwX rKhuCGlSNBH4qlfuayXp+1CMz78L5b1GQtXLyDhyyrf4MNDJhm1qFq0YFl2j+UXkr7 Udhtqa9GFhupv6sKcH75OxQvPtcBCwhOmv0OVilc9IjDICnf93g/pI6xj77NfYKFBk gvN84lqTCc79bFQtymMotg5sJxRWpuKTMJJlMFzgbcVp6zpN6wMxVoL+mqKHdvQrNn TTV3PXWKm8qLA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AFB5868F53 for ; Thu, 1 Jan 2026 17:52:42 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315160; bh=MZXot1Z45o4hEVgXBAeWYuj6J1fAfe70RiH1rfnb1u4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uwwtC9xrQk6srXEyxjOcJxwzYbWZOgc85ZqJZNlbkMKDl9BBAJ98nsPyzJxNDMyfV f9BnWCyLzb1VCgbRZ58mUx1sx8ECyZmnDca1cuYsWFUeDz00cVFYZQ6Lt2Ou5twkGt Nk6/fTI7RlilK8AzzhVvAJ97fbdiKikKRWmGS1KPtcHYlJUkejpdu2bDayXVsi4+lk Tc6hjbKqDYDsOh8FcAHxGE2u371rM6r+gVSyNWcSkbPv039N/GrLwpEQM2Je+2t5JI i4KWbdP+IHPFsZ+P3M4kaaHricAi3i8gp8CHrcoM4Vd9NeY3NFn+x277x6YfYJCnOC NEUp24nr/BRXA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 98EEF68F53; Thu, 1 Jan 2026 17:52:40 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 7DxvDO7dCD6V; Thu, 1 Jan 2026 17:52:40 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315156; bh=6PHYCKdYUFB9h4N5JRD6dKyjXvmVJ7WcneCs72Th9hQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y8abCmMssRCAUJ/qskb/4GCU7RoeAAw0gzOVxqyYEoa/dTN+Ofb7N8Pw3tvu329zN AztXgx06/EJf7jZFgTSqp8hMPGEj6lDYF5Q9qQE8lvqnx+2jakAD6JWpPPxrO6aAWr PVz8DLweBuYHgA4xntuzNH/IoUtGhz6PlW4wu9va37jL0MhQFKwGyvpsOFencY9Uxs 2DpZp2BN3qoog/ArAw1bYuxtyEMeDNlIeogScHnuMY7eBtyrKn+MUUx9okkd2QjOhq 8l9ve1q6LQsuMZDMVD+P7i89Is4BfZq1I/cnl8otKB30z63OLSLnHWUL4LAqv2tXTn 8a8KS0SFFIVpQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 2C0E768313; Thu, 1 Jan 2026 17:52:36 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:52 -0700 Message-ID: <20260102005112.552256-23-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: X6B4HSBU6QGEZAH7OALG45AXSGJ74UPC X-Message-ID-Hash: X6B4HSBU6QGEZAH7OALG45AXSGJ74UPC X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 22/30] ext4l: Add support for read-only devices 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 Some block devices, such as LUKS-encrypted volumes mounted via blkmap_crypt, only support read access. When ext4l attempts to write the superblock during mount, the write fails and causes mount to fail. Add a way to detect this read-only device detection: - Test writes during mount by writing back the superblock data; if the write fails, mark the device as read-only - Update bdev_read_only() to return the actual read_only status - Update sb_rdonly() to check the SB_RDONLY flag This allows ext4l to successfully mount read-only devices like LUKS volumes for read access. We could perhaps have a read-only flag in the block device, but that is left for another day. Co-developed-by: Claude Signed-off-by: Simon Glass --- (no changes since v1) fs/ext4l/ext4_uboot.h | 8 ++++---- fs/ext4l/interface.c | 14 ++++++++++++-- include/linux/fs.h | 1 + 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index a5c0eba6f15..c29f582b1e0 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -315,8 +315,8 @@ extern struct user_namespace init_user_ns; /* might_sleep - stub */ #define might_sleep() do { } while (0) -/* sb_rdonly - U-Boot mounts filesystems read-write */ -#define sb_rdonly(sb) 0 +/* sb_rdonly - check if filesystem is mounted read-only */ +#define sb_rdonly(sb) ((sb)->s_flags & SB_RDONLY) /* Trace stubs */ #define trace_ext4_journal_start_inode(...) do { } while (0) @@ -696,10 +696,10 @@ struct super_block { struct list_head s_inodes; }; -/* Block device read-only check - stub */ +/* Block device read-only check */ static inline int bdev_read_only(struct block_device *bdev) { - return 0; + return bdev ? bdev->read_only : 0; } /* kuid_t and kgid_t - from linux/cred.h */ diff --git a/fs/ext4l/interface.c b/fs/ext4l/interface.c index 301e28af3b8..c60ea7db684 100644 --- a/fs/ext4l/interface.c +++ b/fs/ext4l/interface.c @@ -401,8 +401,6 @@ int ext4l_probe(struct blk_desc *fs_dev_desc, goto err_free_buf; } - free(buf); - /* Save device info for later operations */ ext4l_dev_desc = fs_dev_desc; if (fs_partition) @@ -411,6 +409,18 @@ int ext4l_probe(struct blk_desc *fs_dev_desc, /* Set block device for buffer I/O */ ext4l_set_blk_dev(fs_dev_desc, fs_partition); + /* + * Test if device supports writes by writing back the same data. + * If write returns 0, the device is read-only (e.g. LUKS/blkmap_crypt) + */ + if (blk_dwrite(fs_dev_desc, + (part_offset + BLOCK_SIZE) / fs_dev_desc->blksz, + 2, buf) != 2) { + sb->s_bdev->read_only = true; + sb->s_flags |= SB_RDONLY; + } + free(buf); + /* Mount the filesystem */ ret = ext4_fill_super(sb, fc); if (ret) { diff --git a/include/linux/fs.h b/include/linux/fs.h index 0bf0d3b0379..54c0148ee72 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -76,6 +76,7 @@ struct block_device { void *bd_disk; struct super_block *bd_super; dev_t bd_dev; + bool read_only; }; /* errseq functions - stubs */ From patchwork Fri Jan 2 00:50:53 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1187 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=1767315167; bh=eSqhWmmajrPtHmQQ1JNOrFRKwrN2P9DSEgxE6kE2e/8=; 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=hfWh0SQzHQQSlY6ljaDeq/dQN4ZQzuCAe+H/pnlLdU/Eu3qKtKMveO1sZEoCbJbcB oCWVMRuj7ryJjKNBnxWLzIhOvs6C7FmyCfcydazuH3Kzkyn1/rjJZprnlNN+SdfXPE l0DJ9Pbohzh5yrnFsrqtOAlubmilLo3Mgp2DUmEAUj5C2w+WpMAgqwSyWFC8jsGD2W AemlZtLEa+chO4jDc3X4qjrRKI0cEMwbnCzis4QIJ/1ZjTlysZkoTCGYdJdX5VQVXd clgW+o179IS6SQRAFSNCLtyXn5LXc2nPUQcq/fmLrxDuW44wfItyZpjZiU1uTK8kyF iHwx4MQsRcXSw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7DB6D69004 for ; Thu, 1 Jan 2026 17:52:47 -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 p5PABwN6UtAR for ; Thu, 1 Jan 2026 17:52:47 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315167; bh=eSqhWmmajrPtHmQQ1JNOrFRKwrN2P9DSEgxE6kE2e/8=; 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=hfWh0SQzHQQSlY6ljaDeq/dQN4ZQzuCAe+H/pnlLdU/Eu3qKtKMveO1sZEoCbJbcB oCWVMRuj7ryJjKNBnxWLzIhOvs6C7FmyCfcydazuH3Kzkyn1/rjJZprnlNN+SdfXPE l0DJ9Pbohzh5yrnFsrqtOAlubmilLo3Mgp2DUmEAUj5C2w+WpMAgqwSyWFC8jsGD2W AemlZtLEa+chO4jDc3X4qjrRKI0cEMwbnCzis4QIJ/1ZjTlysZkoTCGYdJdX5VQVXd clgW+o179IS6SQRAFSNCLtyXn5LXc2nPUQcq/fmLrxDuW44wfItyZpjZiU1uTK8kyF iHwx4MQsRcXSw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6D51568313 for ; Thu, 1 Jan 2026 17:52:47 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315165; bh=vdkBGgtGqCFuizgtM4akzqx9FA1lKxJdLujFQxI7gpg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aliSMxGmOCKNHfDLjPFMLus0e9xWGIf9Eorz39EsqltTW1UfE11fGmKyY+H3YsuHo Jq5DSTqi1awvNEKVjghJJOH4eBb/H5UYfNYsjiaVgrr9BsxMBWVksm8wvF7tIMKOcB jclUNjD8wLAbyhS3YDRMuVSOGoH7uOVDKRHVJ0WtdW8hiBIFBX/fUHlj9AWh3NpXrC FkEQoKgep3u6IUs43j939XK+rJ5ZaEvHYgcAqA3p0cl3gbpDp+eZtxO4MHhMH8saTu 7YlDOzeNR3KFJ0DAAqHC85E2hwszGI3DNgkVR5WRgaI3d129eygfJoSUx33t/0O9bg mfsOGDynB/G2g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7915168313; Thu, 1 Jan 2026 17:52:45 -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 0Jtaf69j3k_U; Thu, 1 Jan 2026 17:52:45 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315161; bh=V38bDF2EvJRDwVtCS3fxSOBWCkpGmr5tD+1xylWx5uI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k0BfdkQpz6iQ+irDAgbaUjqhQYk3+dscWQMF/V6eM/YpJBLz8bJUmWRmFeWAITXz6 BNFQHyzgc28phP9OcJ+vugLwUpKsH0yjzqJEdoXUAFBdmNOgBSThYHTMoBg0VkC9mP 8kcD2F6giDHY8zJd9SiwTpY+yUCtDmjeN8Wb5hWHXprG5xBmqAU6pcqK77QFRWmfeb RadeEeUzWRQ77cPajWG/sUodkIP2zgpvrGat7BiSdx2VrOXPwfXMOr9kdzeCdsIed2 1V7cdhUU64F01epKYl1lOLRKQg9CkeKQvdJRYnSE/ztEGLpEgX/yi9W54r0KzqLkzl Syz5eTl2zY3Sg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D313569007; Thu, 1 Jan 2026 17:52:40 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:53 -0700 Message-ID: <20260102005112.552256-24-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 53UM4LF252UWZ7PLIUMMBMUVCZVCHTHE X-Message-ID-Hash: 53UM4LF252UWZ7PLIUMMBMUVCZVCHTHE X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 23/30] ext4l: Add write support List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add the ability to write files to ext4 filesystems using the ext4l driver. This enables the 'save' command to work with ext4l. The implementation uses the jbd2 journal for crash safety: - ext4l_write() creates files if needed and writes data - Journal transactions commit synchronously for durability - Buffer cache syncs dirty buffers after write operations The write path consists of the following steps: 1. Lookup or create file via ext4_create() 2. Start journal transaction 3. For each block: get/allocate block, copy data, sync to disk 4. Update inode size and commit transaction 5. Sync all dirty buffers Add an ext4l_op_ptr() macro to select between a write operation and a fallback based on CONFIG_EXT4_WRITE, avoiding #ifdefs in fstypes[]. Co-developed-by: Claude Signed-off-by: Simon Glass --- (no changes since v1) fs/ext4l/interface.c | 271 ++++++++++++++++++++++++++++ fs/fs_legacy.c | 2 +- include/ext4l.h | 23 +++ test/fs/ext4l.c | 42 +++++ test/py/tests/test_fs/test_ext4l.py | 5 + 5 files changed, 342 insertions(+), 1 deletion(-) diff --git a/fs/ext4l/interface.c b/fs/ext4l/interface.c index c60ea7db684..94bfd71bfb5 100644 --- a/fs/ext4l/interface.c +++ b/fs/ext4l/interface.c @@ -874,6 +874,277 @@ int ext4l_read(const char *filename, void *buf, loff_t offset, loff_t len, return 0; } +static int ext4l_write_file(struct inode *dir, const char *filename, void *buf, + loff_t offset, loff_t len, loff_t *actwrite) +{ + struct dentry *dir_dentry, *dentry, *result; + handle_t *handle = NULL; + struct buffer_head *bh; + struct inode *inode; + loff_t pos, end; + umode_t mode; + int ret; + + /* Create dentry for the parent directory */ + dir_dentry = kzalloc(sizeof(struct dentry), GFP_KERNEL); + if (!dir_dentry) + return -ENOMEM; + dir_dentry->d_inode = dir; + dir_dentry->d_sb = dir->i_sb; + + /* Create dentry for the filename */ + dentry = kzalloc(sizeof(struct dentry), GFP_KERNEL); + if (!dentry) { + kfree(dir_dentry); + return -ENOMEM; + } + + /* Initialize dentry (kzalloc already zeros memory) */ + dentry->d_name.name = filename; + dentry->d_name.len = strlen(filename); + dentry->d_sb = dir->i_sb; + dentry->d_parent = dir_dentry; + + /* Lookup file */ + result = ext4_lookup(dir, dentry, 0); + + if (IS_ERR(result)) { + ret = PTR_ERR(result); + goto out_dentry; + } + + if (result && result->d_inode) { + /* File exists - use the existing inode for overwrite */ + inode = result->d_inode; + if (result != dentry) { + /* Use the result dentry instead */ + kfree(dentry); + dentry = result; + } + } else { + /* ext4_lookup returned NULL or a dentry with NULL inode */ + if (result && result != dentry) { + /* Free the result dentry since it doesn't have an inode */ + kfree(result); + } + /* Keep using our original dentry */ + dentry->d_inode = NULL; + + /* File does not exist, create it */ + /* Mode: 0644 (rw-r--r--) | S_IFREG */ + mode = S_IFREG | 0644; + ret = ext4_create(&nop_mnt_idmap, dir, dentry, mode, true); + if (ret) + goto out_dentry; + + inode = dentry->d_inode; + } + if (!inode) { + ret = -EIO; + goto out_dentry; + } + + /* + * Attach jinode for journaling if needed (like ext4_file_open does). + * This is required for ordered data mode. + */ + ret = ext4_inode_attach_jinode(inode); + if (ret < 0) + goto out_dentry; + + /* + * Start a journal handle for the write operation. + * U-Boot uses a synchronous single-transaction model where + * ext4_journal_stop() commits immediately for crash safety. + */ + handle = ext4_journal_start(inode, EXT4_HT_WRITE_PAGE, + EXT4_DATA_TRANS_BLOCKS(inode->i_sb)); + if (IS_ERR(handle)) { + ret = PTR_ERR(handle); + handle = NULL; + goto out_dentry; + } + + /* Write data to file */ + pos = offset; + end = offset + len; + while (pos < end) { + ext4_lblk_t block = pos >> inode->i_blkbits; + uint block_offset = pos & (inode->i_sb->s_blocksize - 1); + uint bytes_to_write = inode->i_sb->s_blocksize - block_offset; + int needed_credits = EXT4_DATA_TRANS_BLOCKS(inode->i_sb); + + if (pos + bytes_to_write > end) + bytes_to_write = end - pos; + + /* + * Ensure we have enough journal credits for this block. + * Each block allocation can use up to EXT4_DATA_TRANS_BLOCKS + * credits. Try to extend, or restart the transaction if needed. + */ + ret = ext4_journal_ensure_credits(handle, needed_credits, 0); + if (ret < 0) + goto out_handle; + + bh = ext4_getblk(handle, inode, block, 0); + + if (IS_ERR(bh)) { + ret = PTR_ERR(bh); + goto out_handle; + } + if (!bh) { + /* Block doesn't exist, allocate it */ + bh = ext4_getblk(handle, inode, block, + EXT4_GET_BLOCKS_CREATE); + if (IS_ERR(bh)) { + ret = PTR_ERR(bh); + goto out_handle; + } + if (!bh) { + ret = -EIO; + goto out_handle; + } + } + + /* Get write access for journaling */ + ret = ext4_journal_get_write_access(handle, inode->i_sb, bh, + EXT4_JTR_NONE); + if (ret) { + brelse(bh); + goto out_handle; + } + + /* Copy data to buffer */ + memcpy(bh->b_data + block_offset, buf + (pos - offset), + bytes_to_write); + + /* + * In data=journal mode, file data goes through the journal. + * In data=ordered mode, write directly to disk. + */ + if (ext4_should_journal_data(inode)) { + /* data=journal: write through journal */ + ret = ext4_handle_dirty_metadata(handle, inode, bh); + if (ret) { + brelse(bh); + goto out_handle; + } + } else { + /* data=ordered: write directly to disk */ + mark_buffer_dirty(bh); + ret = sync_dirty_buffer(bh); + if (ret) { + brelse(bh); + goto out_handle; + } + } + + brelse(bh); + pos += bytes_to_write; + } + + /* Update inode size */ + if (end > inode->i_size) { + i_size_write(inode, end); + /* + * Also update i_disksize in ext4_inode_info - this is what gets + * written to disk via ext4_fill_raw_inode -> ext4_isize_set + */ + EXT4_I(inode)->i_disksize = end; + /* Mark inode dirty to update on disk */ + ext4_mark_inode_dirty(handle, inode); + } + + *actwrite = len; + ret = 0; + +out_handle: + /* Stop handle - this commits the transaction synchronously in U-Boot */ + if (handle) { + int stop_ret = ext4_journal_stop(handle); + + if (stop_ret) { + if (!ret) + ret = stop_ret; + } + } + +out_dentry: + /* + * Free our manually allocated dentries. In U-Boot's minimal dcache, + * these won't be cached elsewhere. + */ + kfree(dir_dentry); + kfree(dentry); + return ret; +} + +int ext4l_write(const char *filename, void *buf, loff_t offset, loff_t len, + loff_t *actwrite) +{ + struct inode *parent_inode = NULL; + char *parent_path = NULL; + const char *basename; + char *path_copy; + char *last_slash; + int ret; + + if (!ext4l_sb) + return -ENODEV; + + if (!filename || !buf || !actwrite) + return -EINVAL; + + /* Check if filesystem is mounted read-write */ + if (ext4l_sb->s_flags & SB_RDONLY) + return -EROFS; + + /* Parse filename to get parent directory and basename */ + path_copy = strdup(filename); + if (!path_copy) + return -ENOMEM; + + last_slash = strrchr(path_copy, '/'); + + if (last_slash) { + *last_slash = '\0'; + parent_path = path_copy; + basename = last_slash + 1; + if (*parent_path == '\0') /* Root directory */ + parent_path = "/"; + } else { + parent_path = "/"; + basename = filename; + } + + /* Resolve parent directory inode */ + ret = ext4l_resolve_path(parent_path, &parent_inode); + if (ret) { + free(path_copy); + return ret; + } + + if (!S_ISDIR(parent_inode->i_mode)) { + free(path_copy); + return -ENOTDIR; + } + + /* Call write implementation */ + ret = ext4l_write_file(parent_inode, basename, buf, offset, len, + actwrite); + + /* Sync all dirty buffers - U-Boot has no journal thread */ + if (!ret) { + int sync_ret = bh_cache_sync(); + + if (sync_ret) + ret = sync_ret; + } + + free(path_copy); + return ret; +} + void ext4l_close(void) { ext4l_close_internal(false); diff --git a/fs/fs_legacy.c b/fs/fs_legacy.c index 155092519dd..66545834928 100644 --- a/fs/fs_legacy.c +++ b/fs/fs_legacy.c @@ -283,7 +283,7 @@ static struct fstype_info fstypes[] = { .exists = ext4l_exists, .size = ext4l_size, .read = ext4l_read, - .write = fs_write_unsupported, + .write = ext4l_op_ptr(ext4l_write, fs_write_unsupported), .uuid = ext4l_uuid, .opendir = ext4l_opendir, .readdir = ext4l_readdir, diff --git a/include/ext4l.h b/include/ext4l.h index 9cfe4867ffa..5dfb671690c 100644 --- a/include/ext4l.h +++ b/include/ext4l.h @@ -15,6 +15,13 @@ struct fs_dir_stream; struct fs_dirent; struct fs_statfs; +/* Select op when EXT4_WRITE is enabled, fallback otherwise */ +#if CONFIG_IS_ENABLED(EXT4_WRITE) +#define ext4l_op_ptr(op, fallback) op +#else +#define ext4l_op_ptr(op, fallback) fallback +#endif + /** * ext4l_probe() - Probe a block device for an ext4 filesystem * @@ -69,6 +76,22 @@ int ext4l_size(const char *filename, loff_t *sizep); int ext4l_read(const char *filename, void *buf, loff_t offset, loff_t len, loff_t *actread); +/** + * ext4l_write() - Write data to a file + * + * Creates the file if it doesn't exist. Overwrites existing content. + * + * @filename: Path to file + * @buf: Buffer containing data to write + * @offset: Byte offset to start writing at + * @len: Number of bytes to write + * @actwrite: Returns actual bytes written + * Return: 0 on success, -EROFS if read-only, -ENODEV if not mounted, + * -ENOTDIR if parent is not a directory, negative on other errors + */ +int ext4l_write(const char *filename, void *buf, loff_t offset, loff_t len, + loff_t *actwrite); + /** * ext4l_get_uuid() - Get the filesystem UUID * diff --git a/test/fs/ext4l.c b/test/fs/ext4l.c index 43801f252f7..82587a87894 100644 --- a/test/fs/ext4l.c +++ b/test/fs/ext4l.c @@ -396,3 +396,45 @@ static int fs_test_ext4l_statfs_norun(struct unit_test_state *uts) } FS_TEST_ARGS(fs_test_ext4l_statfs_norun, UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL, { "fs_image", UT_ARG_STR }); + +/** + * fs_test_ext4l_write_norun() - Test ext4l_write function + * + * Verifies that ext4l can write file contents to the filesystem. + * + * Arguments: + * fs_image: Path to the ext4 filesystem image + */ +static int fs_test_ext4l_write_norun(struct unit_test_state *uts) +{ + const char *fs_image = ut_str(EXT4L_ARG_IMAGE); + const char *test_data = "test write data\n"; + size_t test_len = strlen(test_data); + loff_t actwrite, actread; + char read_buf[32]; + loff_t size; + + ut_assertnonnull(fs_image); + ut_assertok(run_commandf("host bind 0 %s", fs_image)); + ut_assertok(fs_set_blk_dev("host", "0", FS_TYPE_ANY)); + + /* Write a new file */ + ut_assertok(ext4l_write("/newfile.txt", (void *)test_data, 0, + test_len, &actwrite)); + ut_asserteq(test_len, actwrite); + + /* Verify the file exists and has correct size */ + ut_asserteq(1, ext4l_exists("/newfile.txt")); + ut_assertok(ext4l_size("/newfile.txt", &size)); + ut_asserteq(test_len, size); + + /* Read back and verify contents */ + memset(read_buf, '\0', sizeof(read_buf)); + ut_assertok(ext4l_read("/newfile.txt", read_buf, 0, 0, &actread)); + ut_asserteq(test_len, actread); + ut_asserteq_str(test_data, read_buf); + + return 0; +} +FS_TEST_ARGS(fs_test_ext4l_write_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 25d09dca889..e953be379eb 100644 --- a/test/py/tests/test_fs/test_ext4l.py +++ b/test/py/tests/test_fs/test_ext4l.py @@ -118,3 +118,8 @@ class TestExt4l: """Test that fsinfo command displays filesystem statistics.""" with ubman.log.section('Test ext4l fsinfo'): ubman.run_ut('fs', 'fs_test_ext4l_fsinfo', fs_image=ext4_image) + + def test_write(self, ubman, ext4_image): + """Test that ext4l can write file contents.""" + with ubman.log.section('Test ext4l write'): + ubman.run_ut('fs', 'fs_test_ext4l_write', fs_image=ext4_image) From patchwork Fri Jan 2 00:50:54 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1188 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=1767315173; bh=G3YynsUmXvYW4lB1pkbXWGhu3QOY802Td2Uf2n7GM3w=; 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=oyF8nkkCD4BsTZzMFUWkxe58HQCgc8V2hUyhUSGAPkhCcdAOIBSzWn/+dZ0I8gM+Y obmz0rvacvBhR+gs1vd8zbjVH4vq0zH9iWpwuz1pMCztNmmDRc5Ly3C64EVb7tN9pl /Yu9sg0+NtouyR/w54g/y12CEVZMteSVsW0szSBrMPSxIgIztEcWcUJnjlV6QdGJE/ 4G2s2GRbNLFfZeAE8IPAWmQDOwC/PChxF5cODyf5b78xSt7ak4yMpbfzehXtOnUhYW tsnVxPNbdzOS4t0afSO5p3/KxxleCjfpFv71pWhgs6+9Q7OMXtYIwTXkKOi8CCCYZU /yDNHoYyPB1gg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6F75868F53 for ; Thu, 1 Jan 2026 17:52: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 MoO15hanbIgn for ; Thu, 1 Jan 2026 17:52:53 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315173; bh=G3YynsUmXvYW4lB1pkbXWGhu3QOY802Td2Uf2n7GM3w=; 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=oyF8nkkCD4BsTZzMFUWkxe58HQCgc8V2hUyhUSGAPkhCcdAOIBSzWn/+dZ0I8gM+Y obmz0rvacvBhR+gs1vd8zbjVH4vq0zH9iWpwuz1pMCztNmmDRc5Ly3C64EVb7tN9pl /Yu9sg0+NtouyR/w54g/y12CEVZMteSVsW0szSBrMPSxIgIztEcWcUJnjlV6QdGJE/ 4G2s2GRbNLFfZeAE8IPAWmQDOwC/PChxF5cODyf5b78xSt7ak4yMpbfzehXtOnUhYW tsnVxPNbdzOS4t0afSO5p3/KxxleCjfpFv71pWhgs6+9Q7OMXtYIwTXkKOi8CCCYZU /yDNHoYyPB1gg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5708069004 for ; Thu, 1 Jan 2026 17:52:53 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315170; bh=8bMhnr2l2TJKeDIS71DmvjNfyzUu8ysVwxYNyyBFA3k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZQIMJI3DfTLzQ5STmGJ1YWaum1asotmZ2KuzbGqLsj1Z9veC5bgIaBYzmLeDKxG5R B93O3CP/sx/PbY4mu9WSz4kU2uJ3ZrNRR2u7L43QnZIWy6jQa2LqtWytiMt4d3qsbV dLAjOo4of9uG+B/0ZVywF5NKs+vWAOC3DHD+ORu/Vp4b8vFwT/rd1gKdTtuPn8bR+8 4WZTtEwNvaqO9l67QtuUo8hLCK2fk/tRISXj7YfY+w+E1BkGdBoUnC5aglT0NYBhVS QSb2wysMcV+G3U/PZEgcxNQc3J2YPam120SiwblmO8OtFe0RXOPTPetyL/0KWVY4P5 Wkr7IkvCbYhMg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 381C868F56; Thu, 1 Jan 2026 17:52:50 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id WJu1-M9PcwXA; Thu, 1 Jan 2026 17:52:50 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315166; bh=9r9/OWAtjw5BKx4ClMUzGxyj+uB2X43/jpXTXkfj0YU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t6zGzASpj7gokDe/eS4WHX4JEc9+/Z7dNLmfc4DsPtWxUspuFX+pqbcsaYa+FQm/F CaEp5E2G1NH4DaoXQSB9qMmZcAoiGYH+Yl2Qo1YcM0CjibNg9FCh1Wsv5gaLccfttr LFQpZxK0EgS8zlLih60wwA1vCZPJTfCZsr3Nej6e5jy5gF+N3YfoYfvjxHttLcKVxb uiAwzXeKKjHOOZKYAhLQCEK0vxizsIOMmkcw2A6DE25xsdFbs+6yWLuAcVYc5wcujb aSwWIb6pQc69kVa5ZinTOaxX3XVd8wgigTsbrJEO6zcmzkNmxNk6jco03j1PHoiPAh 7NtXNE+VRw7xw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B8DEF68F53; Thu, 1 Jan 2026 17:52:45 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:54 -0700 Message-ID: <20260102005112.552256-25-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: QUFCQST6HOVMD7GPBVWR2F57WFHRSR6R X-Message-ID-Hash: QUFCQST6HOVMD7GPBVWR2F57WFHRSR6R X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 24/30] ext4l: Add unlink support for file deletion List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Implement ext4l_unlink() to delete files from ext4 filesystems. This enables the 'rm' command to work with ext4l. The implementation: - Resolves the parent directory and target file - Verifies the target is not a directory (use rmdir for that) - Calls ext4_unlink() to remove the directory entry - Uses journal transactions for crash safety Add ext4l_op_ptr() macro to select between ext4l_unlink() and the fallback based on CONFIG_EXT4_WRITE Call ext4_commit_super() to ensure the changes are written to disk. Co-developed-by: Claude Signed-off-by: Simon Glass --- (no changes since v1) fs/ext4l/interface.c | 251 +++++++++++++++++----------- fs/fs_legacy.c | 2 +- include/ext4l.h | 9 + test/fs/ext4l.c | 41 +++++ test/py/tests/test_fs/test_ext4l.py | 5 + 5 files changed, 212 insertions(+), 96 deletions(-) diff --git a/fs/ext4l/interface.c b/fs/ext4l/interface.c index 94bfd71bfb5..442617a0d3e 100644 --- a/fs/ext4l/interface.c +++ b/fs/ext4l/interface.c @@ -874,75 +874,131 @@ int ext4l_read(const char *filename, void *buf, loff_t offset, loff_t len, return 0; } -static int ext4l_write_file(struct inode *dir, const char *filename, void *buf, - loff_t offset, loff_t len, loff_t *actwrite) +/** + * ext4l_resolve_file() - Resolve a file path for write operations + * @path: Path to process + * @dir_dentryp: Returns parent directory dentry (caller must kfree) + * @dentryp: Returns file dentry after lookup (caller must kfree) + * @path_copyp: Returns path copy (caller must free) + * + * Common setup for write operations. Validates inputs, checks read-write + * mount, parses path, resolves parent directory, creates dentries, and + * performs lookup. + * + * Return: 0 on success, negative on error + */ +static int ext4l_resolve_file(const char *path, struct dentry **dir_dentryp, + struct dentry **dentryp, char **path_copyp) { + char *path_copy, *dir_path, *last_slash; struct dentry *dir_dentry, *dentry, *result; - handle_t *handle = NULL; - struct buffer_head *bh; - struct inode *inode; - loff_t pos, end; - umode_t mode; + struct inode *dir_inode; + const char *basename; int ret; - /* Create dentry for the parent directory */ + if (!ext4l_sb) + return -ENODEV; + + if (!path) + return -EINVAL; + + /* Check if filesystem is mounted read-write */ + if (ext4l_sb->s_flags & SB_RDONLY) + return -EROFS; + + /* Parse path to get parent directory and basename */ + path_copy = strdup(path); + if (!path_copy) + return -ENOMEM; + + last_slash = strrchr(path_copy, '/'); + if (last_slash) { + *last_slash = '\0'; + dir_path = path_copy; + basename = last_slash + 1; + if (*dir_path == '\0') + dir_path = "/"; + } else { + dir_path = "/"; + basename = path; + } + + /* Resolve parent directory */ + ret = ext4l_resolve_path(dir_path, &dir_inode); + if (ret) { + free(path_copy); + return ret; + } + + if (!S_ISDIR(dir_inode->i_mode)) { + free(path_copy); + return -ENOTDIR; + } + + /* Create dentry for parent directory */ dir_dentry = kzalloc(sizeof(struct dentry), GFP_KERNEL); - if (!dir_dentry) + if (!dir_dentry) { + free(path_copy); return -ENOMEM; - dir_dentry->d_inode = dir; - dir_dentry->d_sb = dir->i_sb; + } + dir_dentry->d_inode = dir_inode; + dir_dentry->d_sb = dir_inode->i_sb; - /* Create dentry for the filename */ + /* Create dentry for the file */ dentry = kzalloc(sizeof(struct dentry), GFP_KERNEL); if (!dentry) { kfree(dir_dentry); + free(path_copy); return -ENOMEM; } - - /* Initialize dentry (kzalloc already zeros memory) */ - dentry->d_name.name = filename; - dentry->d_name.len = strlen(filename); - dentry->d_sb = dir->i_sb; + dentry->d_name.name = basename; + dentry->d_name.len = strlen(basename); + dentry->d_sb = dir_inode->i_sb; dentry->d_parent = dir_dentry; - /* Lookup file */ - result = ext4_lookup(dir, dentry, 0); - + /* Look up the file */ + result = ext4_lookup(dir_inode, dentry, 0); if (IS_ERR(result)) { - ret = PTR_ERR(result); - goto out_dentry; + kfree(dentry); + kfree(dir_dentry); + free(path_copy); + return PTR_ERR(result); } - if (result && result->d_inode) { + *dir_dentryp = dir_dentry; + *dentryp = dentry; + *path_copyp = path_copy; + + return 0; +} + +static int ext4l_write_file(struct dentry *dir_dentry, struct dentry *dentry, + void *buf, loff_t offset, loff_t len, + loff_t *actwrite) +{ + struct inode *dir = dir_dentry->d_inode; + handle_t *handle = NULL; + struct buffer_head *bh; + struct inode *inode; + loff_t pos, end; + umode_t mode; + int ret; + + if (dentry->d_inode) { /* File exists - use the existing inode for overwrite */ - inode = result->d_inode; - if (result != dentry) { - /* Use the result dentry instead */ - kfree(dentry); - dentry = result; - } + inode = dentry->d_inode; } else { - /* ext4_lookup returned NULL or a dentry with NULL inode */ - if (result && result != dentry) { - /* Free the result dentry since it doesn't have an inode */ - kfree(result); - } - /* Keep using our original dentry */ - dentry->d_inode = NULL; - /* File does not exist, create it */ /* Mode: 0644 (rw-r--r--) | S_IFREG */ mode = S_IFREG | 0644; ret = ext4_create(&nop_mnt_idmap, dir, dentry, mode, true); if (ret) - goto out_dentry; + return ret; inode = dentry->d_inode; } - if (!inode) { - ret = -EIO; - goto out_dentry; - } + if (!inode) + return -EIO; /* * Attach jinode for journaling if needed (like ext4_file_open does). @@ -950,7 +1006,7 @@ static int ext4l_write_file(struct inode *dir, const char *filename, void *buf, */ ret = ext4_inode_attach_jinode(inode); if (ret < 0) - goto out_dentry; + return ret; /* * Start a journal handle for the write operation. @@ -959,11 +1015,8 @@ static int ext4l_write_file(struct inode *dir, const char *filename, void *buf, */ handle = ext4_journal_start(inode, EXT4_HT_WRITE_PAGE, EXT4_DATA_TRANS_BLOCKS(inode->i_sb)); - if (IS_ERR(handle)) { - ret = PTR_ERR(handle); - handle = NULL; - goto out_dentry; - } + if (IS_ERR(handle)) + return PTR_ERR(handle); /* Write data to file */ pos = offset; @@ -1063,84 +1116,92 @@ out_handle: if (handle) { int stop_ret = ext4_journal_stop(handle); - if (stop_ret) { - if (!ret) - ret = stop_ret; - } + if (stop_ret && !ret) + ret = stop_ret; } -out_dentry: - /* - * Free our manually allocated dentries. In U-Boot's minimal dcache, - * these won't be cached elsewhere. - */ - kfree(dir_dentry); - kfree(dentry); return ret; } int ext4l_write(const char *filename, void *buf, loff_t offset, loff_t len, loff_t *actwrite) { - struct inode *parent_inode = NULL; - char *parent_path = NULL; - const char *basename; + struct dentry *dir_dentry, *dentry; char *path_copy; - char *last_slash; int ret; - if (!ext4l_sb) - return -ENODEV; - - if (!filename || !buf || !actwrite) + if (!buf || !actwrite) return -EINVAL; - /* Check if filesystem is mounted read-write */ - if (ext4l_sb->s_flags & SB_RDONLY) - return -EROFS; + ret = ext4l_resolve_file(filename, &dir_dentry, &dentry, &path_copy); + if (ret) + return ret; - /* Parse filename to get parent directory and basename */ - path_copy = strdup(filename); - if (!path_copy) - return -ENOMEM; + /* Call write implementation */ + ret = ext4l_write_file(dir_dentry, dentry, buf, offset, len, actwrite); - last_slash = strrchr(path_copy, '/'); + /* Sync all dirty buffers - U-Boot has no journal thread */ + if (!ret) { + int sync_ret = bh_cache_sync(); - if (last_slash) { - *last_slash = '\0'; - parent_path = path_copy; - basename = last_slash + 1; - if (*parent_path == '\0') /* Root directory */ - parent_path = "/"; - } else { - parent_path = "/"; - basename = filename; + if (sync_ret) + ret = sync_ret; } - /* Resolve parent directory inode */ - ret = ext4l_resolve_path(parent_path, &parent_inode); - if (ret) { - free(path_copy); + kfree(dentry); + kfree(dir_dentry); + free(path_copy); + return ret; +} + +int ext4l_unlink(const char *filename) +{ + struct dentry *dentry, *dir_dentry; + char *path_copy; + int ret; + + ret = ext4l_resolve_file(filename, &dir_dentry, &dentry, &path_copy); + if (ret) return ret; + + /* Check if file exists */ + if (!dentry->d_inode) { + ret = -ENOENT; + goto out; } - if (!S_ISDIR(parent_inode->i_mode)) { - free(path_copy); - return -ENOTDIR; + /* Cannot unlink directories with unlink - use rmdir */ + if (S_ISDIR(dentry->d_inode->i_mode)) { + ret = -EISDIR; + goto out; } - /* Call write implementation */ - ret = ext4l_write_file(parent_inode, basename, buf, offset, len, - actwrite); + /* Unlink the file */ + ret = __ext4_unlink(dir_dentry->d_inode, &dentry->d_name, + dentry->d_inode, dentry); - /* Sync all dirty buffers - U-Boot has no journal thread */ + /* + * Release inode - this triggers ext4_evict_inode for nlink=0 inodes, + * which frees the data blocks and inode. + */ + if (dentry->d_inode) { + iput(dentry->d_inode); + dentry->d_inode = NULL; + } + + /* Sync all dirty buffers after inode eviction */ if (!ret) { int sync_ret = bh_cache_sync(); if (sync_ret) ret = sync_ret; + /* Commit superblock with updated free counts */ + ext4_commit_super(ext4l_sb); } +out: + kfree(dentry); + kfree(dir_dentry); free(path_copy); return ret; } diff --git a/fs/fs_legacy.c b/fs/fs_legacy.c index 66545834928..1eb79b338ee 100644 --- a/fs/fs_legacy.c +++ b/fs/fs_legacy.c @@ -288,7 +288,7 @@ static struct fstype_info fstypes[] = { .opendir = ext4l_opendir, .readdir = ext4l_readdir, .closedir = ext4l_closedir, - .unlink = fs_unlink_unsupported, + .unlink = ext4l_op_ptr(ext4l_unlink, fs_unlink_unsupported), .mkdir = fs_mkdir_unsupported, .ln = fs_ln_unsupported, .rename = fs_rename_unsupported, diff --git a/include/ext4l.h b/include/ext4l.h index 5dfb671690c..abcf17f99ad 100644 --- a/include/ext4l.h +++ b/include/ext4l.h @@ -92,6 +92,15 @@ int ext4l_read(const char *filename, void *buf, loff_t offset, loff_t len, int ext4l_write(const char *filename, void *buf, loff_t offset, loff_t len, loff_t *actwrite); +/** + * ext4l_unlink() - Delete a file + * + * @filename: Path to file to delete + * Return: 0 on success, -ENOENT if file not found, -EISDIR if path is a + * directory, -EROFS if read-only, negative on other errors + */ +int ext4l_unlink(const char *filename); + /** * ext4l_get_uuid() - Get the filesystem UUID * diff --git a/test/fs/ext4l.c b/test/fs/ext4l.c index 82587a87894..dec6e3340bb 100644 --- a/test/fs/ext4l.c +++ b/test/fs/ext4l.c @@ -438,3 +438,44 @@ static int fs_test_ext4l_write_norun(struct unit_test_state *uts) } FS_TEST_ARGS(fs_test_ext4l_write_norun, UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL, { "fs_image", UT_ARG_STR }); + +/** + * fs_test_ext4l_unlink_norun() - Test ext4l_unlink function + * + * Verifies that ext4l can delete files from the filesystem. + * + * Arguments: + * fs_image: Path to the ext4 filesystem image + */ +static int fs_test_ext4l_unlink_norun(struct unit_test_state *uts) +{ + const char *fs_image = ut_str(EXT4L_ARG_IMAGE); + const char *test_data = "unlink test\n"; + size_t test_len = strlen(test_data); + loff_t actwrite; + + 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)); + + /* Create a new file to unlink */ + ut_assertok(ext4l_write("/unlinkme.txt", (void *)test_data, 0, + test_len, &actwrite)); + ut_asserteq(test_len, actwrite); + + /* Verify file exists (same mount) */ + ut_asserteq(1, ext4l_exists("/unlinkme.txt")); + + /* Unlink the file */ + ut_assertok(ext4l_unlink("/unlinkme.txt")); + + /* Verify file no longer exists */ + ut_asserteq(0, ext4l_exists("/unlinkme.txt")); + + /* Verify unlinking non-existent file returns -ENOENT */ + ut_asserteq(-ENOENT, ext4l_unlink("/nonexistent")); + + return 0; +} +FS_TEST_ARGS(fs_test_ext4l_unlink_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 e953be379eb..edea38f7faf 100644 --- a/test/py/tests/test_fs/test_ext4l.py +++ b/test/py/tests/test_fs/test_ext4l.py @@ -123,3 +123,8 @@ class TestExt4l: """Test that ext4l can write file contents.""" with ubman.log.section('Test ext4l write'): ubman.run_ut('fs', 'fs_test_ext4l_write', fs_image=ext4_image) + + def test_unlink(self, ubman, ext4_image): + """Test that ext4l can delete files.""" + with ubman.log.section('Test ext4l unlink'): + ubman.run_ut('fs', 'fs_test_ext4l_unlink', fs_image=ext4_image) From patchwork Fri Jan 2 00:50:55 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1189 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=1767315175; bh=5VI6fEqVr03mL4kqkt+xNKbOV3/eGUZuvSIEj+0rw9o=; 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=gV6fWg6w/xrOF8wO5PL/7Rs3y8/5RT86p+YVjwzAuxwUFU7HsmlMh88iVXYPNrDn1 IzEUGfzX8wKg0bV15QvE5brjvGvoifkuL/87rlIDTR3XZ2j4zBlwG/bhVWu+e5saou 0/esr4wZBtF98VS9bK5DmYm+9li+99tuUhGjoQEJtfG/AEvNBzyDIpJQsZa0q0ppwi ZtUa/0qhKGXaDHSCG/KD+yld3jj2KSJnUZkNWd/Q/mL0hfWivUD0vbLdgRJaPb/dsQ 3BY9UkwrBzp9EBew40fhMgRzYWOMrSMp8HrYwE2eoTPtdfotJ3hSI2vscG5O9iXEO/ v8UHJfxQps69w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EFE0B69031 for ; Thu, 1 Jan 2026 17:52:55 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id rXC--gVKeFIs for ; Thu, 1 Jan 2026 17:52:55 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315174; bh=5VI6fEqVr03mL4kqkt+xNKbOV3/eGUZuvSIEj+0rw9o=; 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=VTRd2DB1X3bQJS+ryLBn3gFnQFRgN6gJXOjvXrfzZ8Th0JLrE5XJN5os++1j5Rm2T LizKfpEfDc5d50Ut9XWU+ZNqSENxSFTVwC8DI1pfvSQw0KK1ceIju92axLboZG57Jk vXHWCm4rlKx4uFKQeYcsot7GDks/o3nsACwq//AyDR3Ik+fLv5Y1p/X6c//whsQSQ5 rsBd/nElr80GGAMr7kYUs0q3Gel4kl7FafSRM44E46GaDEqAmzbLAl/k2ZgN1rpa5h tEqsUBnbU/i5xPT8r1JX0LwgxFuMLwExQEMnCkWIh0nXztxExe4hk/XmHBmuI0gjGK Xr5WAcJUfXFCQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 00D216902A for ; Thu, 1 Jan 2026 17:52:54 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315171; bh=mrpi9uQWsGmk+866eETjC9gQ/PSL1J8jBT133UcvOkQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qxR/NID6uJF8Hx0pWEZoDwKYI9OW/9nquPguj5fPcU+cyLGh8YiX/S8vgsaChwY+p Xyzi2uxTOecMD8ukszyUv1RvIc9JIgITbJTeX2Mlc4Q40cafBiufC40nudFRGyHMbh 9A1maDE1RSmzuwlvPdtqJy5A+RzCrEnLMQP1X1dV2X+7cq+mGydrO9TcYqGzo/pGPL 4kmQWcR28XfZazuqHIKfT3A/JEDPDzxfCvLQHHkKcRo108/WcTSe5YhqAsnTMSwZt+ 6lWg+mc884KClV9+//QYaxRh4O14gN1ac6B/Kj6/Fhsrm/yIPgjZdPhc0s92K9DYT5 HaIxdXQa/gWTw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 269EC68F53; Thu, 1 Jan 2026 17:52: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 qfAj-3BxufAD; Thu, 1 Jan 2026 17:52:51 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315170; bh=bbbLuxdRGSFbIx2pTaWKQkLBJbMP02rkvCRRXZUeiKM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WWO2LIfbZN8FZ1yPQ5Ht3BF3xSHzKevTt4i6LO9Ac34tECPk+d3FFfA3dxlu2YTU4 qdmr54ok0x9MmHlJJc2CKEiCtpEBNda3zbqkS6bWbcOfM8LX+2QXN7D2iUahkv9qcZ 9y/w4cmapLmt1f3r9W53O+0VKqDTGTXq5u3dMp2I7qxbtAFAlxb4Nihgk0FFQmOJEL W5MPuGafbvSDUeWgNV6o+Lyi8rM2q13Mz1Xl6rLKdFyJLmjwJTp7/7hHFtQKcpeRGt wvEuXm0CBskWFbeiy9Ydd9l+2GGijIdfAXmFfk5/Jo7bTAMKiB3JXB4AKwG4psI5YX WDuG3/8uar3Hw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 7889C68313; Thu, 1 Jan 2026 17:52:50 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:55 -0700 Message-ID: <20260102005112.552256-26-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: HVUGR5BCZWIU65M5YOCJ2PNILGLG22MC X-Message-ID-Hash: HVUGR5BCZWIU65M5YOCJ2PNILGLG22MC X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 25/30] ext4l: Add mkdir support for directory creation List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Implement ext4l_mkdir() to create directories on ext4 filesystems. The function parses the path to extract the parent directory and basename, resolves the parent inode, checks for existing entries, and calls the Linux ext4_mkdir() function to create the directory. Hook ext4l_mkdir into the filesystem layer via the .mkdir callback in fs_legacy.c, enabling the standard 'mkdir' command to work with ext4l filesystems. Add a unit test that verifies directory creation, duplicate detection (-EEXIST), nested directory creation, and error handling for non-existent parent directories (-ENOENT). Co-developed-by: Claude Signed-off-by: Simon Glass --- (no changes since v1) fs/ext4l/interface.c | 43 ++++++++++++++++++++++++++++++++++++++++ fs/fs_legacy.c | 2 +- include/ext4l.h | 10 ++++++++++ test/fs/ext4l.c | 47 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 101 insertions(+), 1 deletion(-) diff --git a/fs/ext4l/interface.c b/fs/ext4l/interface.c index 442617a0d3e..010db3a3631 100644 --- a/fs/ext4l/interface.c +++ b/fs/ext4l/interface.c @@ -1206,6 +1206,49 @@ out: return ret; } +int ext4l_mkdir(const char *dirname) +{ + struct dentry *dentry, *dir_dentry, *result; + char *path_copy; + int ret; + + ret = ext4l_resolve_file(dirname, &dir_dentry, &dentry, &path_copy); + if (ret) + return ret; + + if (dentry->d_inode) { + /* Directory already exists */ + ret = -EEXIST; + goto out; + } + + /* Create the directory with mode 0755 (rwxr-xr-x) */ + result = ext4_mkdir(&nop_mnt_idmap, dir_dentry->d_inode, dentry, + S_IFDIR | 0755); + if (IS_ERR(result)) { + ret = PTR_ERR(result); + goto out; + } + + ret = 0; + + /* Sync all dirty buffers */ + { + int sync_ret = bh_cache_sync(); + + if (sync_ret) + ret = sync_ret; + /* Commit superblock with updated free counts */ + ext4_commit_super(ext4l_sb); + } + +out: + kfree(dentry); + kfree(dir_dentry); + free(path_copy); + return ret; +} + void ext4l_close(void) { ext4l_close_internal(false); diff --git a/fs/fs_legacy.c b/fs/fs_legacy.c index 1eb79b338ee..b53d420f279 100644 --- a/fs/fs_legacy.c +++ b/fs/fs_legacy.c @@ -289,7 +289,7 @@ static struct fstype_info fstypes[] = { .readdir = ext4l_readdir, .closedir = ext4l_closedir, .unlink = ext4l_op_ptr(ext4l_unlink, fs_unlink_unsupported), - .mkdir = fs_mkdir_unsupported, + .mkdir = ext4l_op_ptr(ext4l_mkdir, fs_mkdir_unsupported), .ln = fs_ln_unsupported, .rename = fs_rename_unsupported, .statfs = ext4l_statfs, diff --git a/include/ext4l.h b/include/ext4l.h index abcf17f99ad..1a12ba1ac1c 100644 --- a/include/ext4l.h +++ b/include/ext4l.h @@ -101,6 +101,16 @@ int ext4l_write(const char *filename, void *buf, loff_t offset, loff_t len, */ int ext4l_unlink(const char *filename); +/** + * ext4l_mkdir() - Create a directory + * + * @dirname: Path of directory to create + * Return: 0 on success, -EEXIST if directory already exists, + * -ENOTDIR if parent is not a directory, -EROFS if read-only, + * negative on other errors + */ +int ext4l_mkdir(const char *dirname); + /** * ext4l_get_uuid() - Get the filesystem UUID * diff --git a/test/fs/ext4l.c b/test/fs/ext4l.c index dec6e3340bb..5930e4234ba 100644 --- a/test/fs/ext4l.c +++ b/test/fs/ext4l.c @@ -479,3 +479,50 @@ static int fs_test_ext4l_unlink_norun(struct unit_test_state *uts) } FS_TEST_ARGS(fs_test_ext4l_unlink_norun, UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL, { "fs_image", UT_ARG_STR }); + +/** + * fs_test_ext4l_mkdir_norun() - Test ext4l_mkdir function + * + * Verifies that ext4l can create directories on the filesystem. + * + * Arguments: + * fs_image: Path to the ext4 filesystem image + */ +static int fs_test_ext4l_mkdir_norun(struct unit_test_state *uts) +{ + const char *fs_image = ut_str(EXT4L_ARG_IMAGE); + static int test_counter; + char dir_name[32]; + char subdir_name[64]; + int ret; + + 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)); + + /* Use unique directory names to avoid issues with test re-runs */ + snprintf(dir_name, sizeof(dir_name), "/testdir%d", test_counter); + snprintf(subdir_name, sizeof(subdir_name), "%s/subdir", dir_name); + test_counter++; + + /* Create a new directory */ + ret = ext4l_mkdir(dir_name); + ut_assertok(ret); + + /* Verify directory exists */ + ut_asserteq(1, ext4l_exists(dir_name)); + + /* Verify creating duplicate returns -EEXIST */ + ut_asserteq(-EEXIST, ext4l_mkdir(dir_name)); + + /* Create nested directory */ + ut_assertok(ext4l_mkdir(subdir_name)); + ut_asserteq(1, ext4l_exists(subdir_name)); + + /* Verify creating directory in non-existent parent returns -ENOENT */ + ut_asserteq(-ENOENT, ext4l_mkdir("/nonexistent/dir")); + + return 0; +} +FS_TEST_ARGS(fs_test_ext4l_mkdir_norun, UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL, + { "fs_image", UT_ARG_STR }); From patchwork Fri Jan 2 00:50:56 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1190 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=1767315176; bh=mD4Qi+/fz5l5vE2HBPMJDAW95dP6RsMmcOF0psIH8ss=; 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=qrmKJIcQFUs9QxZNp52qodoRVoDk3hIEfl5psZu2e5X9vuS8klOUWzuJSK4HQzwna OJkNGc9tBEyUXC3zAeuvSjefohahM8pA9oawY1eXbNN30HJWlVN/Ev2kBxAAgKrQqV qRxmstkNsl3QbVWLMnlN109DrAKA+9+VW0FXBJz7xdmqBpBd+6k4GYBD6tgmMwCxIY PceqRnG55g5vXZG5zRcD63yn17+ZCcHYDgYYQaeZ26XpqQ65b3WecxujihMxO/t7vV PI/ZikMEav6uJxBPkuUyea9OSoy8Sl6ToTwdHrExh0WW4Hy6W5tw0EgTPNuyZlMtH1 UPJm+IRBLy/HQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 42E4768F53 for ; Thu, 1 Jan 2026 17:52: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 m0v6lQAGRCMx for ; Thu, 1 Jan 2026 17:52:56 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315174; bh=mD4Qi+/fz5l5vE2HBPMJDAW95dP6RsMmcOF0psIH8ss=; 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=E4thrcNKZSBl7/4SvO2/SYypBTgzDE8M56d+tmCXvPzmyHIysaN4848WEd9ZLJ6JQ 1CONhV5+Zvr2MR16uR4iRSrdiYPLu9478KrXxKXhnt2qfAG/z4GeDgUi3pvumJr64z CrRHMj00x1ljRlJ7XaZPuKmR2XfcNBfmfk+lB+F2yMwYhaUI49ZwybaiVWYpAZKz1S lj53BM2QBdC+3ROjGWkmb5Qgf9xYr7DWSk3XBXlsz/+J+tBKGFOg/Nxh+Fj7rpmS+m grAHCEHdz897enStSaf88Uov4K5clnniacvPu1G0Ic1974ygSBf/Kilol+L7QU6r4A duCD1+cCgf5rA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E4C7869035 for ; Thu, 1 Jan 2026 17:52:54 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315172; bh=Z9+tqAn85Jf41sUshstwVjfYmZgV/1HzFSxoiuwd1CY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pPqHrzil1bb/zpMxP5R3zVUXK/jXpJuX1kxhlB9XQ+QGG3Y1QuNzCCH40WR5LYvxc o++7n85MN8ljXLyCEyWomWkHAIM5yLm3YmvkklJrvPkJ+ojfMqq5qjx8ktMN8Dyj4p p5uLgF+ERfQenx9CArEaFq0vjz/a7PTjQt2J1NfBjEyjzPoErs4N7rHzcCgGP2cApU 1opf+7eWt8mgCD6L1i5NeygxUySxqZiLrOf0O/RyvHnABrudJHffkLD/Iq1LOGwKiL qG+SjxsyOQYxfhju6j21eAigZHgKDB2oZm5BVkav1MDhYLDlldC0nPaDI2V+iigQBr jooFDCeDr9alA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1C33B68F56; Thu, 1 Jan 2026 17:52:52 -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 nDwi8l0sUoru; Thu, 1 Jan 2026 17:52:52 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315171; bh=rjRInDPryzA0EqsPnejK/20gPPDCSdmWi2FI83rNxnM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=svu9So63RbX3GdQwq6Os7UcgArgS+MJgPuUJt/2smcLLGljru5M3k3fP40ByJKaqF 8Em12d8nN/DaN+kt5kBUKSJqiQE+rUTc0UZ4SrNPhijGgxjmafXoFshVu19jm1mSf/ lXo1gSl8+HUk1mhxg5jMuJfadArNIHP21UB8Z/qQvUB1t5ZPtgx6TfqRhVP9JFecNm VqdB8hoIAZkdHoqSmXG5HivYXrnob8SI+Ya0/f6hhpYs5xfnKqIPNnhSD9Opyw6HKL 9DBHOgayeOy6GOsEiMLb0WE3dBUqvdl5eh3Is29F9MHD/EKBFwChu1zqIRHQCbGGyz tT3wwZq8yxIAw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 65D3068313; Thu, 1 Jan 2026 17:52:51 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:56 -0700 Message-ID: <20260102005112.552256-27-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: R2ZME6WD7BYN3Y5RGAOA6VXXFPK3LVER X-Message-ID-Hash: R2ZME6WD7BYN3Y5RGAOA6VXXFPK3LVER X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 26/30] ext4l: Add symlink support List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add ext4l_ln() to create symbolic links. This uses the Linux ext4_symlink() function which supports both fast symlinks (stored in inode) and regular symlinks (stored in data blocks). Fix the fscrypt_prepare_symlink() stub to properly init the disk_link structure with the symlink target, which is required for symlink creation to work correctly. Add some notes about U-Boot's argument ordering with symlinks. Co-developed-by: Claude Signed-off-by: Simon Glass --- (no changes since v1) fs/ext4l/ext4_uboot.h | 2 +- fs/ext4l/interface.c | 48 ++++++++++++++++++++++++++++++++++ fs/fs_legacy.c | 2 +- include/ext4l.h | 11 ++++++++ test/fs/ext4l.c | 60 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 121 insertions(+), 2 deletions(-) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index c29f582b1e0..b3da5bfa002 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -1589,7 +1589,7 @@ static inline char *d_path(const struct path *path, char *buf, int buflen) #define fscrypt_dio_supported(i) (1) #define fscrypt_has_permitted_context(p, c) ({ (void)(p); (void)(c); 1; }) #define fscrypt_is_nokey_name(d) ({ (void)(d); 0; }) -#define fscrypt_prepare_symlink(d, s, l, m, dl) ({ (void)(d); (void)(s); (void)(l); (void)(m); (void)(dl); 0; }) +#define fscrypt_prepare_symlink(d, s, l, m, dl) ({ (void)(d); (void)(m); (dl)->name = (unsigned char *)(s); (dl)->len = (l) + 1; 0; }) #define fscrypt_encrypt_symlink(i, s, l, d) ({ (void)(i); (void)(s); (void)(l); (void)(d); 0; }) #define fscrypt_prepare_link(o, d, n) ({ (void)(o); (void)(d); (void)(n); 0; }) #define fscrypt_prepare_rename(od, ode, nd, nde, f) ({ (void)(od); (void)(ode); (void)(nd); (void)(nde); (void)(f); 0; }) diff --git a/fs/ext4l/interface.c b/fs/ext4l/interface.c index 010db3a3631..c9dd25dd7b4 100644 --- a/fs/ext4l/interface.c +++ b/fs/ext4l/interface.c @@ -1249,6 +1249,54 @@ out: return ret; } +int ext4l_ln(const char *filename, const char *linkname) +{ + struct dentry *dentry, *dir_dentry; + char *path_copy; + int ret; + + /* + * Note: The parameter naming follows U-Boot's convention: + * - filename: the target file the link should point to + * - linkname: the path of the symlink to create + */ + if (!filename) + return -EINVAL; + + ret = ext4l_resolve_file(linkname, &dir_dentry, &dentry, &path_copy); + if (ret) + return ret; + + if (dentry->d_inode) { + /* File already exists */ + ret = -EEXIST; + goto out; + } + + /* Create the symlink - filename is what the link points to */ + ret = ext4_symlink(&nop_mnt_idmap, dir_dentry->d_inode, dentry, + filename); + if (ret) + goto out; + + /* Sync all dirty buffers */ + { + int sync_ret = bh_cache_sync(); + + if (sync_ret) + ret = sync_ret; + /* Commit superblock with updated free counts */ + ext4_commit_super(ext4l_sb); + } + +out: + kfree(dentry); + kfree(dir_dentry); + free(path_copy); + + return ret; +} + void ext4l_close(void) { ext4l_close_internal(false); diff --git a/fs/fs_legacy.c b/fs/fs_legacy.c index b53d420f279..a325c2631d4 100644 --- a/fs/fs_legacy.c +++ b/fs/fs_legacy.c @@ -290,7 +290,7 @@ static struct fstype_info fstypes[] = { .closedir = ext4l_closedir, .unlink = ext4l_op_ptr(ext4l_unlink, fs_unlink_unsupported), .mkdir = ext4l_op_ptr(ext4l_mkdir, fs_mkdir_unsupported), - .ln = fs_ln_unsupported, + .ln = ext4l_op_ptr(ext4l_ln, fs_ln_unsupported), .rename = fs_rename_unsupported, .statfs = ext4l_statfs, }, diff --git a/include/ext4l.h b/include/ext4l.h index 1a12ba1ac1c..d0e420c8da2 100644 --- a/include/ext4l.h +++ b/include/ext4l.h @@ -111,6 +111,17 @@ int ext4l_unlink(const char *filename); */ int ext4l_mkdir(const char *dirname); +/** + * ext4l_ln() - Create a symbolic link + * + * @filename: Path of symlink to create + * @target: Target path the symlink points to + * Return: 0 on success, -EEXIST if file already exists, + * -ENOTDIR if parent is not a directory, -EROFS if read-only, + * negative on other errors + */ +int ext4l_ln(const char *filename, const char *target); + /** * ext4l_get_uuid() - Get the filesystem UUID * diff --git a/test/fs/ext4l.c b/test/fs/ext4l.c index 5930e4234ba..1d46a752f32 100644 --- a/test/fs/ext4l.c +++ b/test/fs/ext4l.c @@ -526,3 +526,63 @@ static int fs_test_ext4l_mkdir_norun(struct unit_test_state *uts) } FS_TEST_ARGS(fs_test_ext4l_mkdir_norun, UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL, { "fs_image", UT_ARG_STR }); + +/** + * fs_test_ext4l_ln_norun() - Test ext4l_ln function + * + * Verifies that ext4l can create symbolic links on the filesystem. + * + * Arguments: + * fs_image: Path to the ext4 filesystem image + */ +static int fs_test_ext4l_ln_norun(struct unit_test_state *uts) +{ + const char *fs_image = ut_str(EXT4L_ARG_IMAGE); + static int test_counter; + char link_name[32]; + const char *target = "/testfile.txt"; + loff_t size; + loff_t actread; + char buf[32]; + + ut_assertnonnull(fs_image); + ut_assertok(run_commandf("host bind 0 %s", fs_image)); + ut_assertok(fs_set_blk_dev("host", "0", FS_TYPE_ANY)); + + /* Use unique symlink names to avoid issues with test re-runs */ + snprintf(link_name, sizeof(link_name), "/testlink%d", test_counter); + test_counter++; + + /* + * Create a symbolic link. ext4l_ln follows U-Boot's ln command + * convention: ext4l_ln(target, linkname) creates linkname pointing + * to target. + */ + ut_assertok(ext4l_ln(target, link_name)); + + /* Verify symlink exists */ + ut_asserteq(1, ext4l_exists(link_name)); + + /* + * Size through symlink should be target file's size (12 bytes), + * since ext4l_resolve_path follows symlinks (like stat, not lstat) + */ + ut_assertok(ext4l_size(link_name, &size)); + ut_asserteq(12, size); + + /* Verify we can read through the symlink */ + memset(buf, '\0', sizeof(buf)); + ut_assertok(ext4l_read(link_name, buf, 0, 0, &actread)); + ut_asserteq(12, actread); + ut_asserteq_str("hello world\n", buf); + + /* Verify creating duplicate returns -EEXIST */ + ut_asserteq(-EEXIST, ext4l_ln(target, link_name)); + + /* Verify creating symlink in non-existent parent returns -ENOENT */ + ut_asserteq(-ENOENT, ext4l_ln(target, "/nonexistent/link")); + + return 0; +} +FS_TEST_ARGS(fs_test_ext4l_ln_norun, UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL, + { "fs_image", UT_ARG_STR }); From patchwork Fri Jan 2 00:50:57 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1191 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=1767315180; bh=Xka6npl9HOhwNJKd9FT0bU+i3BVD1wHwCCqJcpNAPak=; 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=CWY1EWC/d+G9tSJJluz/Bl0AccrCOH01L4XTNLj7JQdNRokLERqp2aVRXijy/cpun 0Lobkw7TD/dv5XtjUkjuBmAaBNM1g3KCa1Z5E9r2D0VV5/xTUi8IgEoE4yVyCNF3od HdUUU4ES1nUkFRTWk8grvXI0ZIfLoyQLlIr5y4xejySdY4r4z4flMKSdItGZw29VO6 1ujw3YooOwLekd9LauWqznTiVXyJwo2fjNsZE/7o+a1copPPs0XLnF7ndnv97I4Pnc QG0/DEa2prCwFm2uxZcfLO+Ub+VT87Zg4y2qxh0aumNS8/wftL4j1Q3I0pjUlPNo0e iDJUmd/frqITw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C261A69004 for ; Thu, 1 Jan 2026 17:53: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 10024) with ESMTP id aLug64ckJhyX for ; Thu, 1 Jan 2026 17:53:00 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315180; bh=Xka6npl9HOhwNJKd9FT0bU+i3BVD1wHwCCqJcpNAPak=; 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=CWY1EWC/d+G9tSJJluz/Bl0AccrCOH01L4XTNLj7JQdNRokLERqp2aVRXijy/cpun 0Lobkw7TD/dv5XtjUkjuBmAaBNM1g3KCa1Z5E9r2D0VV5/xTUi8IgEoE4yVyCNF3od HdUUU4ES1nUkFRTWk8grvXI0ZIfLoyQLlIr5y4xejySdY4r4z4flMKSdItGZw29VO6 1ujw3YooOwLekd9LauWqznTiVXyJwo2fjNsZE/7o+a1copPPs0XLnF7ndnv97I4Pnc QG0/DEa2prCwFm2uxZcfLO+Ub+VT87Zg4y2qxh0aumNS8/wftL4j1Q3I0pjUlPNo0e iDJUmd/frqITw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A811D68F53 for ; Thu, 1 Jan 2026 17:53:00 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315178; bh=z4J0kIQeMUc0jUnUtZxslvoAPDIgfK3EV5bWV8O8hR4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hAunLodLYZxWFt8QMmngroHH39w9IO5msefN97P09yDxFv+Kruz3MUHfdHKm4+5KV NJwZ0FhKpzjNDg6CMwheijOTU4Jo7xpfMM4kHDYJJ6jhMq06uhlF7+GihzHhTpqIm+ cZBDmZCqsJp2QwkDk+fCMXHt/Fe6xVddFFFjvLFKELbpyiV5UBNAuYDoBCllbd8C46 XyQ55DV/mYXnnMhpJBYjCAo8G5rw8m6fKvlUk4QeJJfV3Ss8udWtnm1QdjPgGMNLUh Um6/wiKx5CD/6f18WKDxISwVAsWMmXbV/5+XhQ5Iu5QzqqMJifuDZtmlOhF983+WX6 0JYhxr1WjasVw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8896268F58; Thu, 1 Jan 2026 17:52: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 10026) with ESMTP id nLGBvTaJquh3; Thu, 1 Jan 2026 17:52:58 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315172; bh=GBvQCiQojHiX3AwDMt/bqOJZ+Kep8VqGvy74tBPITPc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eAo7IFKQT1zokjC4A8y9DazPooQiQZC6CPuWVXm8jVHW/VpE4eXdHBeI5u8GmoiaG D+/w1TxFGokgafG6XEiVCurhEzFnlfrhNib4DDE76pp7BX19oORdatsWEGAj9lRQJ0 q4A//tp5+W0Npt6sqEHme0slbxZtgl/YAZu3deCu90Dheo6szEWiUzD7GNo7ZJCE5y LxepFxv8NpBum0qoACWvG4y4mz4UaNRf/nIUmsR8xJ97Ij9QevhnkQCoaWXwb6Nc4X f1L2XWFSRyQTtsewddqPHGJ+FRXsIjE/6++dz3sPei8XWHHicuqra4BQg3hcdbqtw1 T8+iXmFmqxhKg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 5C54F68313; Thu, 1 Jan 2026 17:52:52 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:57 -0700 Message-ID: <20260102005112.552256-28-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: LQL3OVA7LDM27AYNQ6NLPRCPC2OWDU3H X-Message-ID-Hash: LQL3OVA7LDM27AYNQ6NLPRCPC2OWDU3H X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 27/30] ext4l: Update symlink to replace existing files 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 ext4l_ln() function returned -EEXIST when creating a symlink where a file already exists. This differs from the old ext4 implementation which deletes any existing file before creating the symlink (like ln -sf behaviour). Update ext4l_ln() to match this behaviour by calling __ext4_unlink() to remove any existing non-directory file before creating the symlink. Directories cannot be replaced with symlinks and return -EISDIR. This allows test_symlink3 to pass. Co-developed-by: Claude Signed-off-by: Simon Glass --- (no changes since v1) fs/ext4l/interface.c | 18 +++++++++++++++--- include/ext4l.h | 5 ++++- test/fs/ext4l.c | 4 ++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/fs/ext4l/interface.c b/fs/ext4l/interface.c index c9dd25dd7b4..acd9ba5511e 100644 --- a/fs/ext4l/interface.c +++ b/fs/ext4l/interface.c @@ -1268,9 +1268,21 @@ int ext4l_ln(const char *filename, const char *linkname) return ret; if (dentry->d_inode) { - /* File already exists */ - ret = -EEXIST; - goto out; + /* File already exists - delete it first (like ln -sf) */ + if (S_ISDIR(dentry->d_inode->i_mode)) { + /* Cannot replace a directory with a symlink */ + ret = -EISDIR; + goto out; + } + + ret = __ext4_unlink(dir_dentry->d_inode, &dentry->d_name, + dentry->d_inode, dentry); + if (ret) + goto out; + + /* Release inode to free data blocks */ + iput(dentry->d_inode); + dentry->d_inode = NULL; } /* Create the symlink - filename is what the link points to */ diff --git a/include/ext4l.h b/include/ext4l.h index d0e420c8da2..882a27dad42 100644 --- a/include/ext4l.h +++ b/include/ext4l.h @@ -114,9 +114,12 @@ int ext4l_mkdir(const char *dirname); /** * ext4l_ln() - Create a symbolic link * + * Creates the symlink, replacing any existing file (like ln -sf). + * Refuses to replace a directory. + * * @filename: Path of symlink to create * @target: Target path the symlink points to - * Return: 0 on success, -EEXIST if file already exists, + * Return: 0 on success, -EISDIR if target is a directory, * -ENOTDIR if parent is not a directory, -EROFS if read-only, * negative on other errors */ diff --git a/test/fs/ext4l.c b/test/fs/ext4l.c index 1d46a752f32..c1d10dcc816 100644 --- a/test/fs/ext4l.c +++ b/test/fs/ext4l.c @@ -576,8 +576,8 @@ static int fs_test_ext4l_ln_norun(struct unit_test_state *uts) ut_asserteq(12, actread); ut_asserteq_str("hello world\n", buf); - /* Verify creating duplicate returns -EEXIST */ - ut_asserteq(-EEXIST, ext4l_ln(target, link_name)); + /* Verify creating duplicate succeeds (like ln -sf) */ + ut_assertok(ext4l_ln(target, link_name)); /* Verify creating symlink in non-existent parent returns -ENOENT */ ut_asserteq(-ENOENT, ext4l_ln(target, "/nonexistent/link")); From patchwork Fri Jan 2 00:50:58 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1192 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=1767315181; bh=KrKFtJFmNrayMaQGZxN1qojBkzQFKJp5AdWtlBMZwTQ=; 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=NcvA23gcSgvcDTJ41yxKwehI4AVqyA+wjNDhcMhyO4iJMiyOU+fgXvXU2tEpFQxFJ 8gwjBfNf54QZd4cM9sqO02s+4mC+zsMeXVZveSc2VlZq6TrwYlu14cdpRqAD5mct/d kZJCEC4fx0kzcJ4aVoatmk/FlWIuRBDMhQhqVRVxseoiVGFOAzun62xrERcKsIIXZ8 eOYuJYH0LSv9aFBDeQw3JlPs4k/Bs04P6PJvE8zhzu1Sv/Stug3DHBXunUk3ajy07E rJFnoOUvATRISKvsIwC8+yjHfbn1VEcgemudzISMOwNQ+3TlOA8fPZwNGDTfZgBFSO FZIlzAgrOrZZQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 637526902F for ; Thu, 1 Jan 2026 17:53:01 -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 gsurgoLNU1V7 for ; Thu, 1 Jan 2026 17:53:01 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315181; bh=KrKFtJFmNrayMaQGZxN1qojBkzQFKJp5AdWtlBMZwTQ=; 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=NcvA23gcSgvcDTJ41yxKwehI4AVqyA+wjNDhcMhyO4iJMiyOU+fgXvXU2tEpFQxFJ 8gwjBfNf54QZd4cM9sqO02s+4mC+zsMeXVZveSc2VlZq6TrwYlu14cdpRqAD5mct/d kZJCEC4fx0kzcJ4aVoatmk/FlWIuRBDMhQhqVRVxseoiVGFOAzun62xrERcKsIIXZ8 eOYuJYH0LSv9aFBDeQw3JlPs4k/Bs04P6PJvE8zhzu1Sv/Stug3DHBXunUk3ajy07E rJFnoOUvATRISKvsIwC8+yjHfbn1VEcgemudzISMOwNQ+3TlOA8fPZwNGDTfZgBFSO FZIlzAgrOrZZQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4B6EE68F58 for ; Thu, 1 Jan 2026 17:53:01 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315178; bh=coR5jgDHiItRfejaCIJM4IxAJF6OGGg8k/pfUrggXZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oc3imjUXO37fT3fX7eDpf9LcxlB85ZuxrZ65EW0KJ/804drSaDH22KFFVxaph4tRN nSH44z4ZAm6XkAHs+9yr6NsWOlforud4yEzoptmuLtgIStpRQKXWKnpadP8hEclba4 sUyLgeGmpmr6EA2hTJ9WXsCY5iOPJRl0Kvp5ZjETCNggpU6wnJZ3dPSLPgbJunBvW8 rZgzMQ0/Pvx6LRq/hKBfDeOgjqyqkw67lGF4NnW1lTAibsBD6dh340lusG2Bh+oWrb NkH4yCXwGTDu0luCDRy5MitHRT0TaWogLMfB1hUs6O8CvkHC7pf15IrtglxIYeG1pV 5Ga3tQdyRReCg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9EEAA68313; Thu, 1 Jan 2026 17:52: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 10026) with ESMTP id UiKAtygkoEHY; Thu, 1 Jan 2026 17:52:58 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315177; bh=SzVW3SBtLHYTiY7xqMq84FDBEjonIw01aPmkOAQMbI4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nXFe4H5hF2/OFfewxvPWcsEwjKGPwWP64yz8U0huP7l2E10TGXKgC7f8PI5WBjwNR Q39Udi3BYb9NVRzlz75JC1UE99DrP5Rr6GgYWyOGfMzfuAjvDkuATQu1mn6zQT5gtL QzoB4IDaIy4ESKgcfK5sm8CJpx0M/tLws3BdNId5WS1ihbjdXoiLfhcHFD2CQ3VUXy NvunNBKEUdHfMsQGOCmNjnCivHRK8jwhu0EwXo0dMPJkGl838eXbg4rP/7LB7Dc/lL MlEypxEWkNvWfarPcC4JxHoCewIbzxnmzec408Nmvk/PAb8vKVq8w+wxIKoPicLg2C 6IpkJ0mYsRbxw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 0ED4B68F53; Thu, 1 Jan 2026 17:52:56 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:58 -0700 Message-ID: <20260102005112.552256-29-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 3OJCAUDETJTQEGYOK3C4HDBGRERVCJQJ X-Message-ID-Hash: 3OJCAUDETJTQEGYOK3C4HDBGRERVCJQJ X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 28/30] ext4l: Add rename support List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add ext4l_rename() to rename files and directories, including moves across directories. This uses the Linux ext4_rename() function. Also fix the symlink test to verify reading through symlinks works correctly, since ext4l_resolve_path follows symlinks (stat behavior). Add Python test wrappers for mkdir, ln, and rename tests. Co-developed-by: Claude Signed-off-by: Simon Glass --- (no changes since v1) fs/ext4l/interface.c | 54 +++++++++++++++++++++++++ fs/fs_legacy.c | 2 +- include/ext4l.h | 11 ++++++ test/fs/ext4l.c | 61 +++++++++++++++++++++++++++++ test/py/tests/test_fs/test_ext4l.py | 15 +++++++ 5 files changed, 142 insertions(+), 1 deletion(-) diff --git a/fs/ext4l/interface.c b/fs/ext4l/interface.c index acd9ba5511e..f581c32359e 100644 --- a/fs/ext4l/interface.c +++ b/fs/ext4l/interface.c @@ -1309,6 +1309,60 @@ out: return ret; } +int ext4l_rename(const char *old_path, const char *new_path) +{ + struct dentry *old_dentry, *new_dentry; + struct dentry *old_dir_dentry, *new_dir_dentry; + char *old_path_copy, *new_path_copy; + int ret; + + /* Check new_path before ext4l_resolve_file checks old_path */ + if (!new_path) + return -EINVAL; + + ret = ext4l_resolve_file(old_path, &old_dir_dentry, &old_dentry, + &old_path_copy); + if (ret) + return ret; + + if (!old_dentry->d_inode) { + /* Source file doesn't exist */ + ret = -ENOENT; + goto out_old; + } + + ret = ext4l_resolve_file(new_path, &new_dir_dentry, &new_dentry, + &new_path_copy); + if (ret) + goto out_old; + + /* Perform the rename */ + ret = ext4_rename(&nop_mnt_idmap, old_dir_dentry->d_inode, old_dentry, + new_dir_dentry->d_inode, new_dentry, 0); + if (ret) + goto out_new; + + /* Sync all dirty buffers */ + { + int sync_ret = bh_cache_sync(); + + if (sync_ret) + ret = sync_ret; + /* Commit superblock with updated free counts */ + ext4_commit_super(ext4l_sb); + } + +out_new: + kfree(new_dentry); + kfree(new_dir_dentry); + free(new_path_copy); +out_old: + kfree(old_dentry); + kfree(old_dir_dentry); + free(old_path_copy); + return ret; +} + void ext4l_close(void) { ext4l_close_internal(false); diff --git a/fs/fs_legacy.c b/fs/fs_legacy.c index a325c2631d4..6e1bb449410 100644 --- a/fs/fs_legacy.c +++ b/fs/fs_legacy.c @@ -291,7 +291,7 @@ static struct fstype_info fstypes[] = { .unlink = ext4l_op_ptr(ext4l_unlink, fs_unlink_unsupported), .mkdir = ext4l_op_ptr(ext4l_mkdir, fs_mkdir_unsupported), .ln = ext4l_op_ptr(ext4l_ln, fs_ln_unsupported), - .rename = fs_rename_unsupported, + .rename = ext4l_op_ptr(ext4l_rename, fs_rename_unsupported), .statfs = ext4l_statfs, }, #endif diff --git a/include/ext4l.h b/include/ext4l.h index 882a27dad42..59990a3a6f4 100644 --- a/include/ext4l.h +++ b/include/ext4l.h @@ -125,6 +125,17 @@ int ext4l_mkdir(const char *dirname); */ int ext4l_ln(const char *filename, const char *target); +/** + * ext4l_rename() - Rename a file or directory + * + * @old_path: Current path of file or directory + * @new_path: New path for file or directory + * Return: 0 on success, -ENOENT if source not found, + * -ENOTDIR if parent is not a directory, -EROFS if read-only, + * negative on other errors + */ +int ext4l_rename(const char *old_path, const char *new_path); + /** * ext4l_get_uuid() - Get the filesystem UUID * diff --git a/test/fs/ext4l.c b/test/fs/ext4l.c index c1d10dcc816..0843ba1d5ba 100644 --- a/test/fs/ext4l.c +++ b/test/fs/ext4l.c @@ -586,3 +586,64 @@ static int fs_test_ext4l_ln_norun(struct unit_test_state *uts) } FS_TEST_ARGS(fs_test_ext4l_ln_norun, UTF_SCAN_FDT | UTF_CONSOLE | UTF_MANUAL, { "fs_image", UT_ARG_STR }); + +/** + * fs_test_ext4l_rename_norun() - Test ext4l_rename function + * + * Verifies that ext4l can rename files and directories on the filesystem. + * + * Arguments: + * fs_image: Path to the ext4 filesystem image + */ +static int fs_test_ext4l_rename_norun(struct unit_test_state *uts) +{ + const char *fs_image = ut_str(EXT4L_ARG_IMAGE); + const char *test_data = "rename test\n"; + size_t test_len = strlen(test_data); + static int test_counter; + char old_name[32], new_name[32], subdir_name[32], moved_name[64]; + loff_t actwrite, size; + + ut_assertnonnull(fs_image); + ut_assertok(run_commandf("host bind 0 %s", fs_image)); + ut_assertok(fs_set_blk_dev("host", "0", FS_TYPE_ANY)); + + /* Use unique names to avoid issues with test re-runs */ + snprintf(old_name, sizeof(old_name), "/renameme%d.txt", test_counter); + snprintf(new_name, sizeof(new_name), "/renamed%d.txt", test_counter); + snprintf(subdir_name, sizeof(subdir_name), "/renamedir%d", test_counter); + snprintf(moved_name, sizeof(moved_name), "%s/moved.txt", subdir_name); + test_counter++; + + /* Create a file to rename */ + ut_assertok(ext4l_write(old_name, (void *)test_data, 0, + test_len, &actwrite)); + ut_asserteq(test_len, actwrite); + + /* Verify file exists */ + ut_asserteq(1, ext4l_exists(old_name)); + + /* Rename the file */ + ut_assertok(ext4l_rename(old_name, new_name)); + + /* Verify old name no longer exists, new name does */ + ut_asserteq(0, ext4l_exists(old_name)); + ut_asserteq(1, ext4l_exists(new_name)); + + /* Verify file size is preserved */ + ut_assertok(ext4l_size(new_name, &size)); + ut_asserteq(test_len, size); + + /* Verify renaming non-existent file returns -ENOENT */ + ut_asserteq(-ENOENT, ext4l_rename("/nonexistent", "/newname")); + + /* Test cross-directory rename */ + ut_assertok(ext4l_mkdir(subdir_name)); + ut_assertok(ext4l_rename(new_name, moved_name)); + ut_asserteq(0, ext4l_exists(new_name)); + ut_asserteq(1, ext4l_exists(moved_name)); + + return 0; +} +FS_TEST_ARGS(fs_test_ext4l_rename_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 edea38f7faf..0930ebd01ea 100644 --- a/test/py/tests/test_fs/test_ext4l.py +++ b/test/py/tests/test_fs/test_ext4l.py @@ -128,3 +128,18 @@ class TestExt4l: """Test that ext4l can delete files.""" with ubman.log.section('Test ext4l unlink'): ubman.run_ut('fs', 'fs_test_ext4l_unlink', fs_image=ext4_image) + + def test_mkdir(self, ubman, ext4_image): + """Test that ext4l can create directories.""" + with ubman.log.section('Test ext4l mkdir'): + ubman.run_ut('fs', 'fs_test_ext4l_mkdir', fs_image=ext4_image) + + def test_ln(self, ubman, ext4_image): + """Test that ext4l can create symbolic links.""" + with ubman.log.section('Test ext4l ln'): + ubman.run_ut('fs', 'fs_test_ext4l_ln', fs_image=ext4_image) + + def test_rename(self, ubman, ext4_image): + """Test that ext4l can rename files and directories.""" + with ubman.log.section('Test ext4l rename'): + ubman.run_ut('fs', 'fs_test_ext4l_rename', fs_image=ext4_image) From patchwork Fri Jan 2 00:50:59 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1193 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=1767315187; bh=1Aky3t/LUOD6Ctsrb3UVGBMQVXlpYrz1SlEIcCxK0oo=; 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=ZoQs7Zafi4mceL7BAa9Qg0TSGBmYafoG3HU+Ptw4Bd/9rVar689+sG+1eJIZgCCz1 UOSR0vmVtIgAPve/7DSubmvtilfzQ3YMiVJiuIW4/mXOvLg9lcItxY2Eo5oB0U29Ud 8xpiIFp/mf8/wKboKzZezVh2+C96Btfi2ttJ11rSw5HWkZ2XZR9jTUUfTdwcf/y+Pd fm97dx+afXmBSLcY3MkAffXtNzJMI0a5W1r6zN3GjQJzYINSmMPprih5FB4eqW203Y i/J0xA+TMsOJ1jNujGEuHOKnRfKBNdCTw3rLwjnzMUdcgz4y0btF+MdIaBKcPSK0gP cDEyOCD8fwOoA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0BE9C6902E for ; Thu, 1 Jan 2026 17:53: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 10024) with ESMTP id SM9WItgfS7aY for ; Thu, 1 Jan 2026 17:53:06 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315186; bh=1Aky3t/LUOD6Ctsrb3UVGBMQVXlpYrz1SlEIcCxK0oo=; 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=ML1b2fIaMhnz8EWq5OAE3+dE6Yi47yY873T2PN2jxCAh0z/zz8jsIzBfpTSk2zFi/ /BOmneHclxx5Hz8ZDvbcdobnnsnyLM/ov78jZSmIr5IVd7W3bXgfG++n7m7tWe6CLr LU5DJjiz/365hZcBgTLvONMd+j9bkjHz+mzryCG0xtLN6feenvSTvCcJXz0KxVqAGt LVfOxbclZiRXvpDiWh1Rtte9IRaspjLZfJ+ej8hyx0JiWbP2DDWXiI5QiozGQ0coyV DGEmWmxqL64fUv6nZ0yGK92lKlVmRWJyauzH9mniL2bEcYLxLeFWde8GLBKl2so0J6 g7gSoL6DuW5Xg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E7ABB68F58 for ; Thu, 1 Jan 2026 17:53:06 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315186; bh=zKWtHgGdsGHGfx7yOLEMVzi9f/Qbmha3m8BqQqkoSt0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=grs9UmicZB3txt3VeZF7syddr7EZnlotVl6WLYk5WQLUVmRUf0dQ4F97Voac5/9IQ siXfa2JYXIQpFVrzkUazKwk58c0m1Rp+cBapbPyxrHs4NGeNf2OJ1Bpk+vs2YKWLWm 3sLXucsy0L4DT9dc//QietiSCTMehSHT5pipDdieEsIXM9+oHWdd/uxQhUp4zYe/Gy lbI+HxcK+CB9Pum2+Sx62oXHNtZPKKnV6/Iv/cNj0KRdh5myHAA35kD1RaM9wjyGa4 KBPdRgGaXGof+OdExrJk9z2BVbm57hJIHWa2GxEKvv4DyTRHq8PRvXiTiVokW8WpYS jDnCcjK47KfbA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2673868F53; Thu, 1 Jan 2026 17:53:06 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id n9ybt5fv9SAQ; Thu, 1 Jan 2026 17:53:06 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315178; bh=Nw14O8+Mrz62+78aPIzd7wZbuccyep4X75qpEQHmSkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kccilsias+DDzsZ9+ewd7GWiNopXODcTd117A80s7b19kC+oe7S9BVnYnF8407LKL BdiEPMhEQBl4EIDo/7IY239Rovl2ZHXF18mK5VrYW735IXxdLK8gdOOzZhu43VD34v ZrHaaAhD2t/N3WLZe0eiVOPcxRn+ofkrJgTh/EJd4xHpvF2wME/nNaBijV5vW0IGd4 0cec3G1gYzbL2J3SXumpv40VrnEfBIuJXspqVZdvrGaaevY9JJ8UenCM7s7QOFiGWo CyE731VOThsITQs0lSIMkGE/hNjrZQZeNMU2RX3oZKQtAtqFWUjMpPLODkLPJacZpK UxJgmSF4bVaNA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 1325568F56; Thu, 1 Jan 2026 17:52:58 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:50:59 -0700 Message-ID: <20260102005112.552256-30-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 3GLORDTYSKGUADTNELAKKFLAPJNCH75O X-Message-ID-Hash: 3GLORDTYSKGUADTNELAKKFLAPJNCH75O X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 29/30] test: fs_helper: Keep metadata_csum enabled for ext4l 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 ext4l driver supports metadata_csum checksums, unlike the old ext4 driver. Only disable metadata_csum when CONFIG_FS_EXT4L is not enabled, allowing ext4l to use modern ext4 filesystem features. Co-developed-by: Claude Signed-off-by: Simon Glass --- (no changes since v1) test/py/tests/fs_helper.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/test/py/tests/fs_helper.py b/test/py/tests/fs_helper.py index 3c4c6e2df6f..ccde6683534 100644 --- a/test/py/tests/fs_helper.py +++ b/test/py/tests/fs_helper.py @@ -174,10 +174,15 @@ class FsHelper: stdout=DEVNULL if self.quiet else None) if self.fs_type.startswith('ext'): - sb_content = check_output(f'tune2fs -l {fs_img}', - shell=True).decode() - if 'metadata_csum' in sb_content: - check_call(f'tune2fs -O ^metadata_csum {fs_img}', shell=True) + # ext4l supports metadata_csum; the old ext4 driver does not. + # Only disable metadata_csum when using the old driver. + if self.config and self.config.buildconfig.get( + 'config_fs_ext4l', 'n') != 'y': + sb_content = check_output(f'tune2fs -l {fs_img}', + shell=True).decode() + if 'metadata_csum' in sb_content: + check_call(f'tune2fs -O ^metadata_csum {fs_img}', + shell=True) elif fs_lnxtype == 'exfat': check_call(f'fattools cp {self.srcdir}/* {fs_img}', shell=True) elif self.srcdir and os.listdir(self.srcdir): From patchwork Fri Jan 2 00:51:00 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1194 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=1767315189; bh=GXFiQVuF0YbYgwgh5Ukl5l5gg19UYpQzdO343DWWSPE=; 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=k6ljLdczGP3wE+kczHIls4O9BXmbicp/dEqsSBK+BcPIaKaUVt5W6TsQvqcrRbZHd HHEAsrBKc5nZXF4fyun5o3Gx0X3/8rbpXsMdqrHdF5bjvzv4Ce74GgbDaWi153m+Fp l1E8f4JGhUJ1sCjbACS1cIxumV/sqyk0vEVWpeVy1uGUDX8xXKP/cx6Yh9ze7H+SLG CCYfciOiotXGu7mF9fC4wtOUywrILB1jgdSSTpNc2QfZ+B/4VfoaK6dBDTjAwZqJdo FZ37LYpJZme4dc/G0xNiZPox2xVFbsQhtuBLuUvP5Kt9xc13OYhK5svMQQLO80277+ RvX9W+ZgR07Cg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 734C45FF82 for ; Thu, 1 Jan 2026 17:53:09 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id RVbsP9UaHWn6 for ; Thu, 1 Jan 2026 17:53:09 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315188; bh=GXFiQVuF0YbYgwgh5Ukl5l5gg19UYpQzdO343DWWSPE=; 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=ZFodeG3fzMzMtugJX9yFkr2v6UoQ+u8lbujpSw7yj9Li3g4vnraqQoUCX7NC0cQsE JIjn/pxl9JRcdWExhXMKDa/HspJYFZFz8EZ/nMCDkR5+rK/I7cE2dxJ+2Uxu8KCypu NfRyXeDIf9YuExeU7XedYPuWhL97eK9Fpq9YGWseNF6xwi7qhR2KVrWatDv25RPNIQ L9xg2UIC6YHZXQG7SNSwFzjERmc29etnymaDSEPVFqJPXxJOOzMnv635bdXfcrmi// izk1f75WMDQkYXAurKOt9c4XmQcOBPV1Gfjel+O3qMyLQR+Yw5ndoIY4uKg5zytbRy ndjp/rZoPGFQQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AB3C468F53 for ; Thu, 1 Jan 2026 17:53:08 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315187; bh=nxsFwcipUWkTYObJW4BW5J+nrckI65MRwLLz/JL7o6Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S6urvb2V3FAHCIatw05ryD85urOGlntdsQwTVnaEWgdssoGORuZqWBO230vZLP64a 1+ZGl8Syt4d6o4wnWALTNMD2YZr3UGkuekFDzF0a3efuNHonGUxkh90f5k/DGSb454 CFvf4OQuCv/mNXvDhJKqIHGSp6YjsuLlY/RTCHkVYZBSHr2etLbUxqTqOMoHKRVa2g 6W8eROguEytWC4FZruSVtr0ULWMwkz++ol1P2tOSATPz58EFbhXHMETMlOQ6su851g 4uNyWLH8rAhVAGmwWe3c7hmQ2F7pge8GumvguC3tBeuwslP6vjld8e+dMrFiz1t5rQ R10fR/12mDg+A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2B1DD69035; Thu, 1 Jan 2026 17:53: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 jzi_WvaNl2kK; Thu, 1 Jan 2026 17:53:07 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767315183; bh=2GZZRRfhB8WAxrF5f5xO+w2WvULarZvJ/4cTS+rUHac=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tsvecVQ7tX3wemLQnLEzVu9Q5SdCB/FnJggDrJ77s/khvjbOgh49wUQFGcYQcZXVL Xn5FY/qqAmg5bEWN7VtN3CHL7Xj2TtuVJZ0CwPavMSiCh+ClZVhO4e6bIfOuZwoXZ9 WE2Xik/gUZGhwTce41OpslEY+uNJbCQVU2XXYjf6dlyjGd2b6rgVWu+cRJvYL+3Ipv NtlzvPGWW0zN+jetSp+xWkfZsFZM8ck9zjXdjiNiug3ny5yGrXu0sxWRprPCIZ/OIs kEDxM+dU5usRJi/BYK/BntJOlIR5mmnzb6ToAdClsW1bTFRRGcN+Sw35eiHOgpVzrS 6r5ugROVVDwPg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B24995FF82; Thu, 1 Jan 2026 17:53:02 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Thu, 1 Jan 2026 17:51:00 -0700 Message-ID: <20260102005112.552256-31-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260102005112.552256-1-sjg@u-boot.org> References: <20260102005112.552256-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 567QPDP2RXCHRV3HQFGOC4MBI3PFDYVG X-Message-ID-Hash: 567QPDP2RXCHRV3HQFGOC4MBI3PFDYVG X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 30/30] sandbox: Enable CONFIG_FS_EXT4L 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 the new ext4l filesystem (Linux ext4 port) for sandbox testing. Co-developed-by: Claude Signed-off-by: Simon Glass --- (no changes since v1) configs/sandbox_defconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index e9ac6894d1a..e55aef8e7f9 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -358,6 +358,8 @@ CONFIG_WDT_FTWDT010=y CONFIG_FS_CBFS=y CONFIG_FS_EXFAT=y CONFIG_FS_CRAMFS=y +CONFIG_FS_EXT4L=y +CONFIG_EXT4_WRITE=y CONFIG_ADDR_MAP=y CONFIG_PANIC_HANG=y CONFIG_CMD_DHRYSTONE=y