| Message ID | 20260102005112.552256-3-sjg@u-boot.org |
|---|---|
| State | New |
| Headers |
Return-Path: <concept-bounces+u-boot-concept=u-boot.org@u-boot.org> 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 <u-boot-concept@u-boot.org>; 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 <u-boot-concept@u-boot.org>; 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 <u-boot-concept@u-boot.org>; 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 <sjg@u-boot.org> To: U-Boot Concept <concept@u-boot.org> 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 <xypron.glpk@gmx.de>, Simon Glass <simon.glass@canonical.com>, "Claude Opus 4 . 5" <noreply@anthropic.com> 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 <concept.u-boot.org> Archived-At: <https://lists.u-boot.org/archives/list/concept@u-boot.org/message/4PRMU4H555WHDOL5PKCUWSE2YCEPLPI5/> List-Archive: <https://lists.u-boot.org/archives/list/concept@u-boot.org/> List-Help: <mailto:concept-request@u-boot.org?subject=help> List-Owner: <mailto:concept-owner@u-boot.org> List-Post: <mailto:concept@u-boot.org> List-Subscribe: <mailto:concept-join@u-boot.org> List-Unsubscribe: <mailto:concept-leave@u-boot.org> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit |
| Series |
ext4l: Add write support (part L)
|
|
Commit Message
Simon Glass
Jan. 2, 2026, 12:50 a.m. UTC
From: Simon Glass <simon.glass@canonical.com> 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 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- (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 <assert.h> #include <dirent.h> #include <errno.h> #include <fcntl.h> @@ -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)