title: C: <sys/stat.h> functions S_ISLNK, S_ISDIR and S_ISREG behaving oddly?
body: <p>The code this is taken from compiles fine. It prints file names in a directory with the option of a letter in front of it: either a <code>d</code>,<code>f</code>,<code>l</code>, or <code>o</code> depending on their file type (<code>o</code> for other). However, I tested it on the directory <code>/etc/network</code> which has a symbolic file called <code>run</code> and it appeared as <code>d</code>? I've tried re-arranging the order of the <code>if-statements</code> too, but that gives an unsatisfactory output too. Am I using it incorrectly?</p>
  
  <pre><code>while ((ent = readdir (dp)) != NULL) {
      lstat(ent-&gt;d_name, &amp;st);
      if (col){
              if(S_ISDIR(st.st_mode)){
                      printf("d\t");
                      }
             else if (S_ISREG(st.st_mode)){
                      printf("f\t");
                      }
              else if (S_ISLNK(st.st_mode)){
                      printf("l\t");
              }
              else {   
                       printf("o\t");   
              }
      }
  </code></pre>