title: How to tell whether two NFS mounts are on the same remote filesystem?
body: <p>My Linux-based system displays statistics for NFS-mounted filesystems, something like this:</p>
  
  <pre><code>   Remote Path              Mounted-on  Stats
     server1:/some/path/name  /path1      100 GB free
     server2:/other/path/name /path2      100 GB free
     Total:                               200 GB free
  </code></pre>
  
  <p>That works fine.  The problem is when the same filesystem on the NFS server has been mounted twice on my client:</p>
  
  <pre><code>   Remote Path              Mounted-on  Stats
     server1:/some/path/name  /path1      100 GB free
     server1:/some/path/name2 /path2      100 GB free
     Total:                               200 GB free
  </code></pre>
  
  <p><code>server1</code>'s <code>/some/path/name</code> and <code>/some/path/name2</code> are actually on the same filesystem, which has 100 GB free, but I erroneously add them up and report 200 GB free.</p>
  
  <p>Is there any way to detect that they're on the same partition?</p>
  
  <p>Approaches that won't work:</p>
  
  <ul>
  <li>"Use <code>statfs()</code>": <code>statfs()</code> returns a <code>struct statfs</code>, which has a "file system ID" field, <code>f_fsid</code>.  Unfortunately it's undefined and gets zeroed out over NFS.</li>
  <li>"Don't mount the same partion multiple times."  This is outside of my control.</li>
  <li>"Use a heuristic based on available space." The method has to definitively work.  Also, <code>statfs()</code> caches its output so it would be difficult to get this right in the face of large data movement.</li>
  </ul>
  
  <p>If there's no solution I'll have to generate a config file in every potential mount point on the server side, but it would be a lot nicer if there was
   some clean way to avoid that.</p>
  
  <p>Thanks!</p>