From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Heimpold Date: Tue, 21 May 2013 19:34:06 +0200 Subject: [U-Boot] [PATCH] tools/fw_env: use fsync to ensure that data is physically stored In-Reply-To: <20130521124723.D2F42384809@gemini.denx.de> References: <1369078482-5863-1-git-send-email-mhei@heimpold.de> <20130521124723.D2F42384809@gemini.denx.de> Message-ID: <456389491.x65y6Gi2JO@kerker> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Wolfgang Denx, > > Closing a file descriptor does not guarantee that the data has been > > successfully saved to disk, as the kernel might defer the write. > > What is the exact problem you are trying to fix? > > I mean, when exactly does adding the sync play a role? I'm using fw_setenv during system update process. The sequence of such a shell script is something like (much simplified): ... fw_setenv state=2 dd if=... of=/dev/mmcblk0... fw_setenv state=1 ... reboot The (redundant) environment is stored in a eMMC flash. The env var 'state' gives a hint to U-Boot whether/where the process was interrupted. So my intension is to be absolutely sure, that when fw_setenv returns, the environment is written out to disk. Best regards, Michael