-
Notifications
You must be signed in to change notification settings - Fork 675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support fdopendir + readdir operations #915
Comments
Merged
bors bot
added a commit
that referenced
this issue
Aug 31, 2018
916: new dir module r=asomers a=scottlamb Fixes #915 This is a lower-level interface than `std::fs::ReadDir`. Notable differences: * can be opened from a file descriptor (as returned by `openat`, perhaps before knowing if the path represents a file or directory). Uses `fdopendir` for this, available on all Unix platforms as of rust-lang/libc#1018. * implements `AsRawFd`, so it can be passed to `fstat`, `openat`, etc. * can be iterated through multiple times without closing and reopening the file descriptor. Each iteration rewinds when finished. * returns entries for `.` (current directory) and `..` (parent directory). * returns entries' names as a `CStr` (no allocation or conversion beyond whatever libc does). Co-authored-by: Scott Lamb <slamb@slamb.org>
bors bot
added a commit
that referenced
this issue
Sep 2, 2018
916: new dir module r=Susurrus a=scottlamb Fixes #915 This is a lower-level interface than `std::fs::ReadDir`. Notable differences: * can be opened from a file descriptor (as returned by `openat`, perhaps before knowing if the path represents a file or directory). Uses `fdopendir` for this, available on all Unix platforms as of rust-lang/libc#1018. * implements `AsRawFd`, so it can be passed to `fstat`, `openat`, etc. * can be iterated through multiple times without closing and reopening the file descriptor. Each iteration rewinds when finished. * returns entries for `.` (current directory) and `..` (parent directory). * returns entries' names as a `CStr` (no allocation or conversion beyond whatever libc does). Co-authored-by: Scott Lamb <slamb@slamb.org>
bors bot
added a commit
that referenced
this issue
Sep 4, 2018
916: new dir module r=Susurrus a=scottlamb Fixes #915 This is a lower-level interface than `std::fs::ReadDir`. Notable differences: * can be opened from a file descriptor (as returned by `openat`, perhaps before knowing if the path represents a file or directory). Uses `fdopendir` for this, available on all Unix platforms as of rust-lang/libc#1018. * implements `AsRawFd`, so it can be passed to `fstat`, `openat`, etc. * can be iterated through multiple times without closing and reopening the file descriptor. Each iteration rewinds when finished. * returns entries for `.` (current directory) and `..` (parent directory). * returns entries' names as a `CStr` (no allocation or conversion beyond whatever libc does). Co-authored-by: Scott Lamb <slamb@slamb.org>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm writing some static file serving code for a webserver. It opens paths using
openat
, determines what type they are (plain file, directory, ...), then tries to serve them. So I want to pass my existing file descriptor tofdopendir
rather than pass a path tostd::fs::read_dir
.I have a prototype implementation which I'll open a pull request for shortly. This is my first contribution to nix. Apologies if I didn't match style well.
One particular point: I wasn't sure if it'd be better to add a new module or put this into an existing one such as
fcntl
. I went with the former for the moment.The text was updated successfully, but these errors were encountered: