Hello Martijn,
On Thu, Dec 15, 2016 at 01:42:45PM +0100, Martijn Verschoor wrote:
I’m looking for a way to list the files (nodes) in a directory using a file system session. Amongst other, I studied the File_system::Session and file_system/utils.h but cannot find a hook to get started. I see that reading the directory nodes is supported -> this returns the Directory_entry struct with information about the directory itself, but not about the nodes the directory contains (right?). Is there a way retrieve the latter?
You are on the right track, that reading directory entries (like in dirent()) is provided as read operation on directory nodes. Please have a look at os/src/lib/vfs/fs_file_system.h for an implementation of dirent(). The trick is to use n * sizeof(::File_system::Directory_entry) as file_offset parameter to read the n-th entry.
Hope this helps