|
|
|
|
|
by romka2
2630 days ago
|
|
The real implementation of ListDir accepts the descriptor of the directory it needs to list (not parent_fd plus dirname like it's done in the article) and doesn't close it. This is fairly straightforward. You still have to pass Arena as an extra parameter though, which adds inconvenience, and d_type is still at -1 offset -- a rather unusual thing for an API. The biggest downside from the API perspective is that directory listing and sorting are bundled in a single function. The insight of v5 in the article is that this bundling allows us to achieve higher performance than what we can get if we have a separate API for listing which we can compose with sorting. So it's a far cry from the cleanest API you can imagine. Levels of abstractions often have to give way when maximum performance is the goal. |
|
I also agree, the parent_fd is trivial but it isn't as easy to use as no parameter.