Does fwrite() write entire file on jffs2?
I am working on an embedded system with a jffs2 partition that will be used for storing and modifying non-volatile data. If I do an fopen() on a file that is in this jffs2 file system, then do an fwrite() on some portion of this file, and then do an fclose() does the entire file get re-written to flash or does just the portion that I wrote to? I am wondering about this because I am worried about flash write cycle lifetime. I realize that jffs2 has wear-leveling, but will that really help if say there are many writes to a small portion of a large file?
Also say that instead of writing directly to this jffs2 file every time I want to write to a file in a tmpfs file system that mirrors that jffs2 file. If I want to update the jffs2 file with the updated tmpfs file, what is the fastest way to do this? I realize that I could just open the tmpfs file for reading and open the jffs2 file for writing and copy byte by byte, but that just doesn't seem very feasible to me. Is there a fast way to compare the two binary files and just write the changes to the jffs2 file?
I hope someone can answer these questions, it would help a lot.