title: fstat() st_nlink=1 even after linking more files
body: <pre><code>#include &lt;sys/types.h&gt;
  #include &lt;sys/stat.h&gt;
  #include &lt;fcntl.h&gt;
  #include &lt;unistd.h&gt;
  
  int main(int argc, char const *argv[])
  {
      struct stat buf;
      int fd;
  
      if (fd = open(argv[1], O_RDWR | O_CREAT)&lt;0)
      {
          printf("file open error\n");
          return 1;
      }
      if (link(argv[1], "link1") + link(argv[1], "link2")&lt;0)
      {
          printf("error link\n");
          return 1;
      }
      if (fstat(fd, &amp;buf)&lt;0)
      {
          printf("error fstat\n");
          return 1;
      }
      printf("nlinks before = %d \n", buf.st_nlink);
      if (unlink("link2") + unlink("link1") + unlink(argv[1])&lt;0)
      {
          printf("unlink error\n");
          return 1;
      }
      if (fstat(fd, &amp;buf)&lt;0)
      {
          printf("error fstat\n");
          return 1;
      }
      printf("nlinks after = %d \n", buf.st_nlink);
      return 0;
  }
  </code></pre>
  
  <p>Output:
      nlinks before = 1
      nlinks after = 1</p>
  
  <p>Why is st_nlink always = 1 even though the are at least 3 links to the file?
  Also, if I use <code>lstat</code> instead I get 3 st_nlinks. Why?</p>