I use UBIFS for rootfs on NAND. When I edited a file like /etc/rc.local with nano command and saveed it, "cat /etc/rc.local" shows the editted content, of course. However after removing power supply (without reboot or poweroff command) and supply power again, the content of /etc/rc.local becomes empty.
I found that written data is not written to NAND straight away in UBIFS and written to cache. (refer: http://www.linux-mtd.infradead.org/faq/ubifs.html#L_empty_file)
I want to sync to NAND straightly after editting. Only solution I found is fsync, but this should be called in C program and it requires file descripter. Nano command and so on does not give us file descripter. So I can not solve this sync problem.
How can I solve this not syncing to NAND problem? Are there any command to sync? Do I have to edit files with C program and use fsync if I want to edit and save a file in UBIFS?
You can use the 'sync' command. the system will flush all the cache to the disk.