summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMichael Heimpold <mhei@heimpold.de>2013-05-20 19:34:42 (GMT)
committerTom Rini <trini@konsulko.com>2017-07-22 19:36:16 (GMT)
commit7e99e14d4ba2533a07adc3d97e06cadc41d12908 (patch)
tree6f928534561fd82ad247120f1179431f07900e6a /tools
parentaae6f016a7928edc79dff78d1235103fff282a34 (diff)
downloadu-boot-fsl-qoriq-7e99e14d4ba2533a07adc3d97e06cadc41d12908.tar.xz
tools/fw_env: use fsync to ensure that data is physically stored
Closing a file descriptor does not guarantee that the data has been successfully saved to disk, as the kernel might defer the write. Signed-off-by: Michael Heimpold <mhei@heimpold.de>
Diffstat (limited to 'tools')
-rw-r--r--tools/env/fw_env.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index 2861656..c9c79e0 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -1088,7 +1088,19 @@ static int flash_io (int mode)
rc = flash_write (fd_current, fd_target, dev_target);
+ if (fsync (fd_current)) {
+ fprintf (stderr,
+ "fsync failed on %s: %s\n",
+ DEVNAME (dev_current), strerror (errno));
+ }
+
if (HaveRedundEnv) {
+ if (fsync (fd_target)) {
+ fprintf (stderr,
+ "fsync failed on %s: %s\n",
+ DEVNAME (dev_current), strerror (errno));
+ }
+
if (close (fd_target)) {
fprintf (stderr,
"I/O error on %s: %s\n",