Generally speaking...

Updated: April 19, 2023

Generally speaking, returning directory entries is just like returning raw data, with the exceptions listed here.

The first point means that you cannot return, for example, seven and a half struct dirent entries. If eight of these structures don't fit into the allotted space, then you must return only seven.

The second point is fairly obvious; it's mentioned here only because filling in the struct dirent can be a little tricky compared to the “raw data” approach for a “normal” read I/O function handler.