title: Traversing a Filesystem with fts(3)
body: <p>I have a question on <code>fts(3)</code>.  I am getting a segmentation fault whenever I try to access any members of the <code>fts_children()</code> function.  When I read the man page at <a href="http://www.kernel.org/doc/man-pages/online/pages/man3/fts.3.html" rel="nofollow">http://www.kernel.org/doc/man-pages/online/pages/man3/fts.3.html</a> it claims to fill itself after the read function runs and returns a linked list linked through the <code>link</code> field in the structure.  My suspicion is that the child_function is returning nothing but I feel like that doesn't line up with the man page.  Am I supposed to be adding these files to the child buffer because I thought that was being done automatically?  My code is below,
  Thanks!</p>
  
  <pre><code>#include&lt;stdlib.h&gt;
  #include&lt;stdio.h&gt;
  #include&lt;sys/types.h&gt;
  #include&lt;sys/stat.h&gt;
  #include&lt;fts.h&gt;
  #include&lt;string.h&gt;
  
  int compare (const FTSENT**, const FTSENT**);
  
  int main(int argc, char* const argv[])
  {
  
          FTS* file_system = NULL;
          FTSENT* child = NULL;
          FTSENT* parent = NULL;
          FTSENT* temp = NULL;
  
          file_system = fts_open(argv + 1,FTS_COMFOLLOW | FTS_NOCHDIR,&amp;compare);
  
          while( (parent = fts_read(file_system)) != NULL)
          {
  
               child = fts_children(file_system,0);
               printf("%s\n", child-&gt;fts_path);
  
  
          }
  //      while (child -&gt;fts_link != NULL)
        //         child = child-&gt;fts_link;
          fts_close(file_system);
          return 0;
  }
  
  int compare(const FTSENT** one, const FTSENT** two){
          return (strcmp((*one)-&gt;fts_name, (*two)-&gt;fts_name));
  }
  "test_fs.c" 43L, 1108C  
  </code></pre>