Skip to content
Snippets Groups Projects
Commit 7e99e14d authored by Michael Heimpold's avatar Michael Heimpold Committed by Tom Rini
Browse files

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: default avatarMichael Heimpold <mhei@heimpold.de>
parent aae6f016
No related branches found
No related tags found
No related merge requests found
...@@ -1088,7 +1088,19 @@ static int flash_io (int mode) ...@@ -1088,7 +1088,19 @@ static int flash_io (int mode)
rc = flash_write (fd_current, fd_target, dev_target); 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 (HaveRedundEnv) {
if (fsync (fd_target)) {
fprintf (stderr,
"fsync failed on %s: %s\n",
DEVNAME (dev_current), strerror (errno));
}
if (close (fd_target)) { if (close (fd_target)) {
fprintf (stderr, fprintf (stderr,
"I/O error on %s: %s\n", "I/O error on %s: %s\n",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment