mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-18 13:11:31 +00:00
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>
This commit is contained in:
parent
aae6f016a7
commit
7e99e14d4b
1 changed files with 12 additions and 0 deletions
12
tools/env/fw_env.c
vendored
12
tools/env/fw_env.c
vendored
|
@ -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",
|
||||
|
|
Loading…
Add table
Reference in a new issue