Listing a directory using the file system session

Christian Helmuth christian.helmuth at ...1...
Thu Dec 15 15:02:56 CET 2016

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
Christian Helmuth
Genode Labs · · /ˈdʒiː.nəʊd/

Genode Labs GmbH · Amtsgericht Dresden · HRB 28424 · Sitz Dresden
Geschäftsführer: Dr.-Ing. Norman Feske, Christian Helmuth

More information about the users mailing list