Notes on supporting directory creation, deletion and listing.

Directory Objects

Employ fs_open on a directory path to obtain a reference to a filesystem resource representing the directory.

The directory resource supports reading and thus provides the listing details in a special format.


In the directory resource, the listing is initiated using the ext2fs_dir_iterate function, with the iterator function populating the memory used to communicate directory information.

Upon filling the available memory, a message is dispatched indicating the presence of directory entries. This dispatching occurs from within the iterator function, specifically inside a method invoked by the iterator function which is able to reply to the client.

Once iteration has begun, incoming messages to the resource therefore always present themselves within the iterator function and its invocations. Where a message merely requests the next results, iteration would continue until the memory buffer is full or no more results are found. When a different message arrives, iteration would be aborted and an appropriate operation initiated instead.

Client Functions

Seeking to a particular location is awkward. One might consider mapping start position to entries, not byte offsets, particularly if production of listings involves the generation of complete entries from the start of a shared memory region. Under such circumstances, counting entries is predictable.

However, where paging is involved, the need to provide contiguous data across page boundaries means that partial entries need to be generated at the limits of pages so that gaps do not appear in the data. Consequently, byte offsets have some significance under these circumstances.