As far as I can tell (maybe I'm missing it-- sorry!) there's no way to go from a handle to a directory and list its contents.
As the motivating example here: if I wanted to make a basic "serve files to Web" server, I want to start at the "files from this directory" root, and generate an index page of all the files / subdirectories. pathrs would be a great way to do all this safely, without exposing myself to .. paths.
But it seems like I still have to drop back to std::fs to list the entries? (Again, if I'm just missing this in the API surface, sorry!)
It seems like this can be done more-or-less safely:
getdents syscall to get directory entries
- Construct a
Handle based on the parent directory's FD for each name returned
The race "may be deleted after the Handle is constructed" applies; but if I understand correctly, that's true of any Handle.
As far as I can tell (maybe I'm missing it-- sorry!) there's no way to go from a handle to a directory and list its contents.
As the motivating example here: if I wanted to make a basic "serve files to Web" server, I want to start at the "files from this directory" root, and generate an index page of all the files / subdirectories.
pathrswould be a great way to do all this safely, without exposing myself to..paths.But it seems like I still have to drop back to
std::fsto list the entries? (Again, if I'm just missing this in the API surface, sorry!)It seems like this can be done more-or-less safely:
getdentssyscall to get directory entriesHandlebased on the parent directory's FD for each name returnedThe race "may be deleted after the
Handleis constructed" applies; but if I understand correctly, that's true of anyHandle.