[libubootenv,v2,1/8] uboot_env: report fsync errors when writing to a file

Message ID 20261113171737.470894-2-dario.binacchi@amarulasolutions.com
State New
Headers
Series Add the FWU metadata storage format |

Commit Message

Dario Binacchi Nov. 13, 2026, 5:17 p.m. UTC
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 <dario.binacchi@amarulasolutions.com>
---
(no changes since v1)

 src/uboot_env.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

-- 
2.43.0
  

Patch

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