| Message ID | 20251231223008.3251711-2-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=1767220237; bh=VJRoA0R0roMb4gAggk1HXePXYH3Gf/JaE0Mp33Y2VEk=; 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=A+ur736AGbgVFAJPsR00z04CRhc3p65eF5oToKXwQJ7NSbyEQWJeogS5Vs83LhoOm XdQUKCDoBnR6PfqStJ74lnLOXTA5iov/U786e2OCHtg73I9HhWCxPddjmNDXp0xCwi +kgTfOur2/5o/FcXfyaY+zAeLUsRCSM6/lEn3QN6H7LQsjWk/hoj8lpGMNxwx8vPQW vIt8ysfYqKqxGwQOkht0ALD3ceECZIToFi5yCu87KG158AKirrEpXwxRm/eo13gMwJ wNselcAPgqm9k9Fbt/CPmTOYetFcPWc1VxZX+9vAI9JDqpv7bJu6tjQMi4rQORPHTp YWIcwqu2WUHcg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9025068FCD for <u-boot-concept@u-boot.org>; Wed, 31 Dec 2025 15:30: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 3rJz63XDUZ45 for <u-boot-concept@u-boot.org>; Wed, 31 Dec 2025 15:30:37 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767220237; bh=VJRoA0R0roMb4gAggk1HXePXYH3Gf/JaE0Mp33Y2VEk=; 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=A+ur736AGbgVFAJPsR00z04CRhc3p65eF5oToKXwQJ7NSbyEQWJeogS5Vs83LhoOm XdQUKCDoBnR6PfqStJ74lnLOXTA5iov/U786e2OCHtg73I9HhWCxPddjmNDXp0xCwi +kgTfOur2/5o/FcXfyaY+zAeLUsRCSM6/lEn3QN6H7LQsjWk/hoj8lpGMNxwx8vPQW vIt8ysfYqKqxGwQOkht0ALD3ceECZIToFi5yCu87KG158AKirrEpXwxRm/eo13gMwJ wNselcAPgqm9k9Fbt/CPmTOYetFcPWc1VxZX+9vAI9JDqpv7bJu6tjQMi4rQORPHTp YWIcwqu2WUHcg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7C4C568FC4 for <u-boot-concept@u-boot.org>; Wed, 31 Dec 2025 15:30:37 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767220235; bh=Eglq/O2e/daTjEgfUWIvBpfrRMUhY3i4L5L6Sr0LCkU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=poMfhcOr3U/p/HFMyWnDQYE4yH6ciHspcEkpdkeRcUy2Ga3pyHgNQldSPj9xTMKNV 7QSIFu/bj4HhUb/u4o2Zz/YhMWTys1hX4dXiY6ccpYkii2K/+1VJlglcQ+MulzDvSe ygeYc3LCdqX2nZohXLCjTjL5yh8lUkp85AyvQobdM9kqlldnCjCQFdHOMhj8dEZ2/Z NnVkn5DtoDtuvkrlJvlD6JIrLjknHGTueOmFQ1ewTpYpEl4E28MLgJ3AsLHHg8LbKp ukxQnXut3T0iLp/nZF5rmF8U8AR1IEAJ1Mdo3f7DCWOzcHUcZGXSMzqXmZQSQVpDRe JT8n9xGNUyC0g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AB86268F65; Wed, 31 Dec 2025 15:30: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 FfDKz2ItX-PR; Wed, 31 Dec 2025 15:30:35 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767220231; bh=mVK0/+O8rAn9aOLKliyDF6AALjSSkXdM1QrfCSSWwqs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BBXAU/uVUA1rPT+edXZdmdVTWtnMOldPSw8HE81fVBxgxZOyowxC1nAaf4f+lKuzU k7IuQzYJang02HdQj+A++p1mjRRYEo6Tve3q3dXBDyMgywmqubHPW5nWOf+G9r/fGn BD/whhmnEgyU/UH6jZlijViW+QIDsGNOWjUlM6mR5jWbLqpk3Ye1l/V0EqnLU94hx/ zxdCZ7lWvq0YnIRMu/BA+fCEfFbyeahvxQjqMsbJFWXJrz62USa2Z5RIExxHlkEYpq dWS+4/0kRfPu5TF1Wl9/mg1toSCBc1je+wVy504WM6fFYHr0JaMa72SKkc5kZffdhB C7y9wXuw+mjfQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 4AC3968C5D; Wed, 31 Dec 2025 15:30:31 -0700 (MST) From: Simon Glass <sjg@u-boot.org> To: U-Boot Concept <concept@u-boot.org> Date: Wed, 31 Dec 2025 15:29:34 -0700 Message-ID: <20251231223008.3251711-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251231223008.3251711-1-sjg@u-boot.org> References: <20251231223008.3251711-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: KUPZNT6J22JDOAU4OTBCD7XLXM4LRPBC X-Message-ID-Hash: KUPZNT6J22JDOAU4OTBCD7XLXM4LRPBC 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 01/26] 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/KUPZNT6J22JDOAU4OTBCD7XLXM4LRPBC/> 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
Dec. 31, 2025, 10:29 p.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> --- 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)