I'd like to know if there any guarantees on the order of the operations on file/file system.
Consider I have a file foo.dat
and I update it as following:
lseek(fd,pos_a,SEEK_SET);
write(fd,data_a,size_a); //< - Operation A
lseek(fd,pos_b,SEEK_SET);
write(fd,data_b,size_b); //< - Operation B
lseek(fd,pos_c,SEEK_SET);
write(fd,data_c,size_c); //< - Operation C
Such that I do updates in file A, B, C. And some fault may occur - software crash or for example power failure.
Is there any guarantees that the operations if they are executed are done in same order.
i.e. That there would be either nothing or "A" or "A and B" or "A and B and C"
But not situations like "A and C" or "B" only.
I know that if I call between A and B fsync(fd)
and same between A and C but it
also guarantees that is actually on file system.
I less care about loose of data but rather about its consistency.
Does POSIX standard guarantees that there will be no out-of-order execution?
So:
- As there any such guarantees?
- On POSIX platform?
- On Windows platform?
- If not what guarantees (besides
fsync
) I can have?