I have a database file which is about 1GB and it is synced to disk. I want to update a little piece of 20 bytes in the middle of the file. I want to do this using classical syscalls (open/lseek/write/close). The operation must be atomic in case of a power cut. A journal file can be used.
I see the problem when calling write(fd, buf, 20) to update the db file. I think there is no guarantee that other parts than the 20 bytes will not be damaged in case of a power cut. For example the beginning of the file may be damaged. There's simply no guarantee.
MySQL or SQLite claim to be able to perform such operations.