Skip to content

List directory entries #371

@cceckman

Description

@cceckman

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions