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