title: What is the difference between fsync and syncfs?
body: <p>What is the difference between fsync and syncfs ?</p>
  
  <pre><code>int syncfs(int fd);
  int fsync(int fd);
  </code></pre>
  
  <p>The manpage for fync says the following :</p>
  
  <blockquote>
    <p>fsync()  transfers  ("flushes")  all modified in-core data of (i.e., modified buffer cache pages
           for) the file referred to by the file descriptor fd to the disk device (or other permanent stor‐
           age  device)  so  that all changed information can be retrieved even after the system crashed or
           was rebooted.  This includes writing through or flushing a disk  cache  if  present.   The  call
           blocks  until  the  device  reports  that  the transfer has completed.  It also flushes metadata
           information associated with the file (see stat(2)).</p>
  </blockquote>
  
  <p>The manpage for syncfs says the following:</p>
  
  <blockquote>
    <p>sync() causes all buffered modifications to file metadata and data to be written to the underly‐
           ing filesystems.</p>
    
    <p>syncfs() is like sync(), but synchronizes just the filesystem containing file referred to by the
           open file descriptor fd.</p>
  </blockquote>
  
  <p>For me both seem equal. They are sychronizing the file referred by the filedescriptor and the associated metadata.</p>