From patchwork Fri Nov 13 17:17:30 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 5018 Delivered-To: michael@amarulasolutions.com Received: by 2002:a05:7301:4187:b0:36a:3487:1c26 with SMTP id ph7csp545372dyb; Fri, 13 Nov 2026 09:17:47 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErH98ZoorHIRE0mZ6kReXsxrFkKbsVB/o0apzbKhrtvv8IVpsYzSNtFjRN98/fbpF3Ka4w3VtGVX@amarulasolutions.com X-Received: by 2002:a05:600c:c167:b0:4ad:181a:4348 with SMTP id 5b1f17b1804b1-4bb55a9b4bcmr68358915e9.18.1794590267534; Fri, 13 Nov 2026 09:17:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1794590267; cv=none; d=google.com; s=arc-20260327; b=ekp5arxDMi9ADbLhVhHR7eWrtmvgG1ceCu8tdoLjSNhDCtlij+uZskUmz7CCtxoE7g QCyKA3pXU4IQJyGN1miMBWFfef+d5QXbKwvUwZSMwJ4Mxmm13HUTFWF5IH2g6iRz6tof oCeZxjgRSDLCchPiaqLnXy7Lbsk+U9ojO4DP3h5PowVm9DTdyEBrHaSKbsP/fSIvMDgB ECJTZ9/TXoFoXCxBLAz4KejjfTPbtu3GrPxrGniBOZu0NY47qE72ny4aSbe+UVJ0saH4 KN+BBLyE3UAoyZFYypTM3O03kz+l/+x2n81eWn/ZjjMUCpkH9tTfCZ0NAukvgQUrMQuC 9wOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Yk88JRFOd5guNYtxV+kB0Ey1gu5Z4zPmdMpfV3/j9ek=; fh=HyJ8Q/p+CiKTbTS9qrJ/lf01/XUY58VurtCgYJrUhaw=; b=Xaq2ZtlX+HTqxRmzMZRxHYh8QwP9HwmP8BsxYnHkN/VLyUOl2Vdvotv1vX5pRBN570 bbVslX+LNgbc3hq8pgmWZWH5eHlnKtu5mCYw1mpQ7ZAP21IE+ek3EmM5WILrEQs8CHQe lP5WDQHUTwB/3CmbFD1raC+AhlDGBib/RgqBX0iYEZvQkiyp/0VBtBnpnoGBvdLVOTig y9cNVLQGVbOTxda1IahWjIjS/XV64xJbhPc28dWg0W2jyAQ/mtoQH41wPOaEaiDgpngj FdzKE8XtAnGu5X7BN85Asl+El8whC3oX2ADJTAI+DDJa4w7gaejICBPGFpGwu+1szKDe gDhw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Y3fjYCIr; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=neutral header.i=@amarulasolutions.com Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id 5b1f17b1804b1-4bb55b305b9sor4339765e9.12.2026.11.13.09.17.47 for (Google Transport Security); Fri, 13 Nov 2026 09:17:47 -0800 (PST) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Y3fjYCIr; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=neutral header.i=@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1794590267; x=1795195067; darn=amarulasolutions.com; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Yk88JRFOd5guNYtxV+kB0Ey1gu5Z4zPmdMpfV3/j9ek=; b=Y3fjYCIr8Hz50n2yUIbKIktzcgcbSgZmg0JVmakE/8Zb0j8P3S6CMXw1gLn7cUPnxh Gi0zpNM4Ys9dWHsEAdrq0uHboV8LNK25cDF0SdZWqAjWqYFVKYQCxxzBG6LF2fYNvI55 uQhOlfb5/pRzMpboJXb1EgzZ52DQhXMuPPBqE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794590267; x=1795195067; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Yk88JRFOd5guNYtxV+kB0Ey1gu5Z4zPmdMpfV3/j9ek=; b=Vgs5ASx8p5unoAWGfO5/KZ5Af+alkeJTliSlAzTSYPl6VeXkXhUKp0izmEXbxzMDw5 FkcayvES7CbiqqPSeALEsEvfJNP4OKxjSxbIKn8dt5JAIoMe0ydaTWhxoAEACY+Pjt+K CryvSQ0WLGqgw6ouaV5kMjNV4DTQTrHWTWHKtjBz5hxO9GxcvEkPkE2ZntFVhoLRApx2 1m2RU7EgJfav+dubbCgAC/GmhLaX0hAV3Whu3SCth7IKlnraeRUQKdaq6BI20B3feAsb ZXjL6p5WHK44FczS4By2jYHBhWktPXpGdLpBxNqSZPd/IWmZ1PvDAhRPG7aMh/M96+at vswA== X-Forwarded-Encrypted: i=1; AL+hErHIUD0KlTTtDwUZbw72txsW+EAAyHFjiIIi9FYQz5AoZiv1rDT60E5SikGK8JpoO6aRFjOPGqQo@amarulasolutions.com X-Gm-Message-State: APuU4Z+03PcQF2qPb8QoMgTbb2XqMtyWN0ug18J61zud/YZ0pf+Iktb3 vEkXmOKQRSM0tjYPARW0/NbL+fLLz90tdUrcWuppics77akLkSnMvuOdkswwaTrqYvgAjg== X-Gm-Gg: AYBFou0y0lmPBFyQDTZLXDLfFtlZuTxlpOcvs7fskvBxLKpGvqpM7UgWiXXF7/lvHf1 9NpORBu4/dTl2bl8UO48LeTvJ7pfUrqWyK77niHUKWAJij8jBRpNP8oDV9sRu0AxUp1+RlkI8b4 u5vksTaBntH4XnwOLnC0pc0exkLvu7yHFgt3SccGjCQexY2b1FWX11yHTV2s0HsxWo3piQEgEQb C6PwoF70oEaQax+1AWFHvU4pREc39uDoA8zrSnHiRYljvOsDnr0npClFSDuy0A7LRhTz4q4nza6 ZTyJoYLZ1VgT5P7NLa88tc6XZysNrvHnkkhxPZShJOnJi5bBTVgqkTnlUDu7K9ydPB6yZYjBFXf hW4G3GAXxvdWZQD7nLUaJUgQlA9OpxyO2iBnE99axlupRWKPx4utLWrpw6wq0VWznz1UlvlHKUS +KXpiL1j3OXkNQ/oTQgtrRfO+GgtSJM2DA+jg+654diaZFOSBGpk1hrReRgqtR6ZjfL5mESeESZ pw7Nv8+Sk2e2+zh8uoE2d0cKO8CKqPK0CcUUOScP0tBc4yuJwW4svblik2L2mxwMs9rtdKYLZMQ o8SiO57eyRcVv0KDm8Ec/i5L5+y+1jtHXHrqLP0muxxLh9BDACXusx4RAttBqmxDiONVnuTsScq 2fokRf6gHB3bHWJ+VeIAivNBd/SuDv26uBPpQsDm44uA8Nrr4DP4aV8bPTEEPKB9dEmtvBefK9O 59ce/3p8f/6tym9cbnFwER/QQ8KQqn/go3EuX8bPkUHbV8v40= X-Received: by 2002:a05:600c:1c17:b0:4ba:4395:56c9 with SMTP id 5b1f17b1804b1-4bb55abc204mr79595835e9.26.1794590266847; Fri, 13 Nov 2026 09:17:46 -0800 (PST) Return-Path: Received: from dario-ThinkPad-P14s-Gen-5.homenet.telecomitalia.it (host-79-14-29-58.business.telecomitalia.it. [79.14.29.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb55ac0e1esm68545935e9.3.2026.11.13.09.17.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2026 09:17:46 -0800 (PST) From: Dario Binacchi To: swupdate@googlegroups.com Cc: stefano.babic@swupdate.org, linux-amarula@amarulasolutions.com, michael@amarulasolutions.com, Dario Binacchi Subject: [libubootenv][PATCH v2 1/8] uboot_env: report fsync errors when writing to a file Date: Fri, 13 Nov 2026 18:17:30 +0100 Message-ID: <20261113171737.470894-2-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261113171737.470894-1-dario.binacchi@amarulasolutions.com> References: <20261113171737.470894-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 filewrite() ignores the result of fsync(), so an environment that never reached the storage is reported as stored. Return the error instead. Signed-off-by: Dario Binacchi --- (no changes since v1) src/uboot_env.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.43.0 diff --git a/src/uboot_env.c b/src/uboot_env.c index c6eeb67b607c..d09cb8ead142 100644 --- a/src/uboot_env.c +++ b/src/uboot_env.c @@ -467,7 +467,8 @@ static int filewrite(struct uboot_flash_env *dev, void *data) } } - fsync(dev->fd); + if (fsync(dev->fd) < 0 && ret >= 0) + ret = -errno; fileprotect(dev, true); // no error handling, keep ret from write