From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mark Jackson Date: Wed, 22 May 2013 16:33:52 +0100 Subject: [U-Boot] [PATCH] tools/fw_env: use fsync to ensure that data is physically stored In-Reply-To: <456389491.x65y6Gi2JO@kerker> References: <1369078482-5863-1-git-send-email-mhei@heimpold.de> <20130521124723.D2F42384809@gemini.denx.de> <456389491.x65y6Gi2JO@kerker> Message-ID: <519CE560.50105@newflow.co.uk> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 21/05/13 18:34, Michael Heimpold wrote: > 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 Not sure what final "OS" environment you're running, but I would think that "reboot" would sync for you ? For instance, under BusyBox, we have:- # reboot --help BusyBox v1.14.0 (2012-02-15 10:28:26 GMT) multi-call binary Usage: reboot [-d delay] [-n] [-f] Reboot the system Options: -d Delay interval for rebooting -n No call to sync() -f Force reboot (don't go through init) ... and under Ubuntu, we have ... $ reboot --help Usage: reboot [OPTION]... Reboot the system. Options: -n, --no-sync don't sync before reboot or halt ... So by default, reboot would (should ?) call sync automatically. This might point to some other issue ? Mark J.