Discussion:
Listing a directory using the file system session
Martijn Verschoor
2016-12-15 12:42:45 UTC
Permalink
Dear Genode community,

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?

Any help is appreciated!

Met vriendelijke groet / kind regards,

Martijn Verschoor

Cyber Security Labs B.V. | Gooimeer 6-31 | 1411 DD Naarden | The Netherlands
+31 35 631 3253 (office) | +31 616 014 087 (mobile)
Christian Helmuth
2016-12-15 14:02:56 UTC
Permalink
Hello Martijn,
Post by Martijn Verschoor
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

https://www.genode-labs.com/ · https://genode.org/
https://twitter.com/GenodeLabs · /ˈdʒiː.nəʊd/

Genode Labs GmbH · Amtsgericht Dresden · HRB 28424 · Sitz Dresden
Geschäftsführer: Dr.-Ing. Norman Feske, Christian Helmuth
Emery Hemingway
2016-12-15 14:32:06 UTC
Permalink
Hello Martijn,

The File_system client in the VFS library is the only example that I can think of
for reading directory entries. I would recommend using the VFS library rather than
using a File_system session directly, the library is easier to use and this would
give you a lot more power for free, such as merging the same directory present in
multiple File_system sessions.

https://github.com/genodelabs/genode/blob/master/repos/os/src/lib/vfs/fs_file_system.h#L279

Cheers,
Emery Hemingway
Post by Martijn Verschoor
Dear Genode community,
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?
Any help is appreciated!
Met vriendelijke groet / kind regards,
Martijn Verschoor
Cyber Security Labs B.V. | Gooimeer 6-31 | 1411 DD Naarden | The Netherlands
+31 35 631 3253 (office) | +31 616 014 087 (mobile)
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
genode-main mailing list
https://lists.sourceforge.net/lists/listinfo/genode-main
Nobody III
2016-12-15 20:23:12 UTC
Permalink
I have written a file manager for Genode, so that could be useful if you
don't want to use the VFS system. It's part of my work on a desktop
environment, and it's not entirely complete, but it should be fairly usable
still. If you want to use that as a starting point, here's a link:
https://github.com/NobodyIII/genode-desktop-environment

Here's the specific file with the _dir() function:
https://github.com/NobodyIII/genode-desktop-environment/blob/master/src/app/file_manager/genodefs.cpp
Post by Christian Helmuth
Hello Martijn,
The File_system client in the VFS library is the only example that I can think of
for reading directory entries. I would recommend using the VFS library rather than
using a File_system session directly, the library is easier to use and this would
give you a lot more power for free, such as merging the same directory present in
multiple File_system sessions.
https://github.com/genodelabs/genode/blob/master/repos/os/
src/lib/vfs/fs_file_system.h#L279
Cheers,
Emery Hemingway
Post by Martijn Verschoor
Dear Genode community,
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?
Post by Martijn Verschoor
Any help is appreciated!
Met vriendelijke groet / kind regards,
Martijn Verschoor
Cyber Security Labs B.V. | Gooimeer 6-31 | 1411 DD Naarden | The
Netherlands
Post by Martijn Verschoor
+31 35 631 3253 (office) | +31 616 014 087 (mobile)
------------------------------------------------------------
------------------
Post by Martijn Verschoor
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
genode-main mailing list
https://lists.sourceforge.net/lists/listinfo/genode-main
------------------------------------------------------------
------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
genode-main mailing list
https://lists.sourceforge.net/lists/listinfo/genode-main
Martijn Verschoor
2016-12-16 11:18:21 UTC
Permalink
Dear Genode community,

Christian, Emery, NobodyIII, thanks for your suggestions.

I see the benefit for using the VFS library, but for the component I’m working on right now, using a file system session directly is more appropriate. Therefore I implemented the functionality of listing the directory entries similar to the dirent() implementation for VFS as hinted by Christian. This works like a charm.

Met vriendelijke groet / kind regards,

Martijn Verschoor

Cyber Security Labs B.V. | Gooimeer 6-31 | 1411 DD Naarden | The Netherlands
+31 35 631 3253 (office) | +31 616 014 087 (mobile)

Loading...