-
Notifications
You must be signed in to change notification settings - Fork 19
Description
I'm trying to use this crate for a change in the Fuchsia repo that allows me to traverse a virtual file system starting with the raw file descriptor.
On Fuchsia, access rights (O_RDONLY, O_RDWR, etc.) for directories are hierarchical, i.e. they must be a subset of the rights of the parent and must be explicitly supplied when opening a subdirectory. The file system implementation I have just happens to have only read-only entries.
Since file descriptors are opened using O_PATH, no access is granted by default which causes file descriptors returned by openat using this file descriptor to be useless for reading directory entries.
For example, the following sequence produces PermissionDenied errors:
let fd = ... // some fd with read permission.
let dir = unsafe { Dir::from_raw_fd(fd) };
println!("{:?}", dir.list_dir(".")?); // Works
let subdir = dir.sub_dir("sounds")?;
println!("{:?}", subdir.list_dir(".")?); // Panics with OS: PermissionDenied
I saw there was a proposal to add functionality for open_flags, sub_dir_flags, etc.
Is this something that would be reasonable to add to this library for this use case?
Alternatively, we could use fcntl(fd, F_GETFD) and propogate the flags automatically in sub_dir and the like but I don't know how portable that is.