[packages] new package uboot-env-mmc: hacked in support for reading/writing an uboot...
[openwrt/svn-archive/archive.git] / utils / uboot-envtools-mmc / patches / 007-fsync.patch
1 From 9ef3d800d08dd673ccb5b7a12a69e94394cf2167 Mon Sep 17 00:00:00 2001
2 From: Michael Heimpold <mhei@heimpold.de>
3 Date: Sat, 11 Aug 2012 21:33:46 +0200
4 Subject: [PATCH] Ensure that data is written to disk
5
6 ---
7 fw_env.c | 12 ++++++++++++
8 1 files changed, 12 insertions(+), 0 deletions(-)
9
10 diff --git a/fw_env.c b/fw_env.c
11 index bed8fae..ee15f33 100644
12 --- a/fw_env.c
13 +++ b/fw_env.c
14 @@ -849,7 +849,19 @@ static int flash_io (int mode)
15
16 rc = flash_write (fd_current, fd_target, dev_target);
17
18 + if (fsync (fd_current)) {
19 + fprintf (stderr,
20 + "fsync failed on %s: %s\n",
21 + DEVNAME (dev_current), strerror (errno));
22 + }
23 +
24 if (HaveRedundEnv) {
25 + if (fsync (fd_target)) {
26 + fprintf (stderr,
27 + "fsync failed on %s: %s\n",
28 + DEVNAME (dev_current), strerror (errno));
29 + }
30 +
31 if (close (fd_target)) {
32 fprintf (stderr,
33 "I/O error on %s: %s\n",
34 --
35 1.7.2.5
36