0

I am trying to define data structures for a filesystem. I understand that both files and directories are represented by inodes, with one bit to differentiate between the two.

However, I am not able to understand how to get files present under a particular directory. In Unix Filesystem, I am not seeing any structure to point to child inodes? Is there a structure which does that? If not, how do I get files present under a directory? And if both are represented by same data structure (inode), what does child inodes in directories point to?

Yellowjacket
  • 548
  • 2
  • 7
  • 19

1 Answers1

1

struct dirent is used to represent directory entry which can be a file or another directory, check it's definition in the manual (http://linux.die.net/man/3/readdir for instance). You can see this structure contains inode number, type of file and so on. By using functions opendir and readdir one can traverse filesystem, check How can I get the list of files in a directory using C or C++?.

Community
  • 1
  • 1
karastojko
  • 1,156
  • 9
  • 14