简体   繁体   中英

UBIFS: editted files are not saved. how to sync them to NAND?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM