title: Linux stat(2) call gives non-existing device ID
body: <p>My test program is calling <a href="http://man7.org/linux/man-pages/man2/stat.2.html" rel="nofollow">stat(2)</a> to obtain a device the file resides on.</p>
  
  <p><code>stat.c</code>  (built with <code>cc stat.c -o stat</code>)</p>
  
  <pre><code>#include &lt;sys/types.h&gt;
  #include &lt;sys/stat.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;sys/sysmacros.h&gt;
  #include &lt;errno.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  int main()
  {
      char *path = "/home/smoku/test.txt";
      unsigned int maj, min;
      struct stat sb;
      if (stat(path, &amp;sb) &lt; 0) {
          fprintf(stderr, "Error getting stat for '%s': %d %s\n", path, errno, strerror(errno));
          return 1;
      }
      maj = major(sb.st_dev);
      min = minor(sb.st_dev);
      fprintf(stderr, "Found '%s' =&gt; %u:%u\n", path, maj, min);
      return 0;
  }
  </code></pre>
  
  <p>Got <code>0:44</code></p>
  
  <pre><code>$ ls -l /home/smoku/test.txt
  -rw-r--r-- 1 smoku smoku 306 08-30 09:33 /home/smoku/test.txt
  
  $ ./stat
  Found '/home/smoku/test.txt' =&gt; 0:44
  
  $ /usr/bin/stat -c "%d" /home/smoku/test.txt
  44
  </code></pre>
  
  <p>But... there is no such device in my system and <code>/home</code> is <code>0:35</code></p>
  
  <pre><code>$ grep /home /proc/self/mountinfo
  75 59 0:35 /home /home rw,relatime shared:30 - btrfs /dev/bcache0 rw,ssd,space_cache,subvolid=258,subvol=/home
  </code></pre>
  
  <p>Why do I get a device ID that does not exist in my system?</p>