Proper way to sync an SD card prior to reboot

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Jun 20 07:27:52 UTC 2014


On 2014-06-19 00:25, Jim Panetta wrote:
>
> To prevent any data loss due to non-flushed buffers at a commanded reboot, we
> would like to sync a multi-partition SD card during our reboot procedure.
>
> Is it enough to issue rtems_disk_fd_sync(fd) for each mounted partition?

No, this is the wrong function.  File systems may have stale data in their data 
structures.

For FAT you can use fsync() or fdatasync() on the root directory.  You can also 
unmount the file system, but for this all open nodes must be closed (including 
working directories, etc.).

>
> Or should we be using unlink(path) as Sebastion Huber mentioned in his
> correspondence with Ali Nasir this April?
> (http://article.gmane.org/gmane.os.rtems.user/22186)
>
> Environment RTEMS 4.11, Zynq (ARM Cortex-A9)
>
>    --Jim Panetta
>


-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.


More information about the users mailing list