提交 7e99e14d 编写于 作者: M Michael Heimpold 提交者: Tom Rini

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: NMichael Heimpold <mhei@heimpold.de>
上级 aae6f016
......@@ -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",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册