sync( ) problem on SD card
Hi we have a customer designed arm9 board,
it has a software reset button.
when i press it, it'll trigger a configuration backup function,
which will save all my running configuration from ram disk to SD/EMMC card, using "cp" command.
In the end of the cp commands, i run "sync()" to make sure all stuff put back to SD or EMMC. Then board reboots.
Now after i reboot, i copy my original config from SD/EMMC to ram disk.
Every once a while it says inode problem, asking me to run e2fsck.
If i put several sync() in the code back to back, problem happens less but still happens.
my guess is it didn't write info to SD/EMMC completely during soft reset.
so how to make sure sync() can really flush info to the SD ?
Any help appreciated.
If you run sync from the command line, it waits for all writes to disk before it returns.
If you run the sync() C library procedure, then according to the documentation:
thanks for reply 1st,
check code again, we are doing system call actually,
my understanding is system() will guarantee "sync" completes and then return back.
system() executes a command specified in command by calling /bin/sh -c command, and returns after the command has been completed.
If the filesystem is still mounted read/write there is no assurance that the filesystem metadata has been written to the device. If the filesystem cannot be unmounted, you should at least remount it read-only before rebooting.
|All times are GMT -5. The time now is 04:39 AM.|