-
Notifications
You must be signed in to change notification settings - Fork 19
Dir::list_self doesn't work #34
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
Comments
Worse than that: instead of failing with |
@Ekleog, it's a normal way of how errors work on Regarding original issue with |
I don't think that the infinite return of What I was trying to say was more that apparently rustc was clever enough to optimize out code that was essentially The point here being: I'm relatively sure that if there is no IO between two Does what I'm saying make sense? Or are there maybe some circumstances where it actually currently works properly? |
I'd like to add the background of To my understanding, both edit: or, better, write a correct implementation of |
Hmm… does FUSE actually not return the underlying folder's listing when using To clarify: with the code use std::io::BufRead;
use openat::Dir;
fn list(d: &Dir) {
println!("Contents:");
for e in d.list_dir(".").unwrap() {
println!("- {:?}", e.unwrap().file_name());
}
}
fn main() {
println!("Opening /tmp/foo");
let dir = Dir::open("/tmp/foo").unwrap();
list(&dir);
println!("Please do `mv /tmp/foo /tmp/bar; mkdir /tmp/foo/{{,baz}}` then press enter");
std::io::stdin().lock().lines().next();
list(&dir);
} I get (when starting with
Does this code behave differently on MacOS, or is there maybe some other behavior that's FUSE-specific and that cannot be emulated with |
I'm using opendir for roughly the same purpose as @ksqsf .
|
I created a simple test that clones fd's with openat(orginal_fd, ".", O_DIRECTORY) : https://gist.github.com/cehteh/ddd125e625a0fce2103ceddbfce190cf This runs in a loop and prints the first 3 entries (attention, no error handling, it'll crash when there are no entries). While running i made the following tests (Linux 5.11.15, Debian/bullseye):
These tests shown that it consistently picked up the underlaying dir's entries and not from the mount on top. Next I will try to translate that to 'openat' (did that already, but something isn't right, needs more investigation). Can anyone out there try to test/replicate this on other Operating Systems and report the outcomes? |
* With FdType/fd_type() one can determine the kind of an underlying file descriptor. Lite descriptors are implemented only in Linux (for now). When O_DIRECTORY is supported it uses fcntl() in favo over stat() * clone_dirfd() tries to do 'the right thing' for duplicating FD's * libc_ok() is a simple wraper for libc calls that return -1 on error, I will refactor the code in the next commits to make use of that more. Please test this! So far it works for me on Linux.
* With FdType/fd_type() one can determine the kind of an underlying file descriptor. Lite descriptors are implemented only in Linux (for now). When O_DIRECTORY is supported it uses fcntl() in favo over stat() * clone_dirfd() tries to do 'the right thing' for duplicating FD's * libc_ok() is a simple wraper for libc calls that return -1 on error, I will refactor the code in the next commits to make use of that more. Please test this! So far it works for me on Linux.
* With FdType/fd_type() one can determine the kind of an underlying file descriptor. Lite descriptors are implemented only in Linux (for now). When O_DIRECTORY is supported it uses fcntl() in favo over stat() * clone_dirfd() tries to do 'the right thing' for duplicating FD's * libc_ok() is a simple wraper for libc calls that return -1 on error, I will refactor the code in the next commits to make use of that more. Please test this! So far it works for me on Linux.
This up/downgrade cloning converts into normal/lite handles which was missing before. I hope this fixes tailhook#34 finally.
This up/downgrade cloning converts into normal/lite handles which was missing before. I hope this fixes tailhook#34 finally.
It calls fsync() on the file descriptor. This is necessary with some operating systems and/or file systems to ensure that changes to the contents of the directory make it to persistent storage — for the same reason it is sometimes necessary to use `std::fs::File::sync_{all,contents}`. Note that this method will fail if used on a `Dir` opened with `O_PATH`. (Same issue as `list_dir`; see tailhook#34.) Closes tailhook#47.
File descriptors opened with
O_PATH
cannot be used ingetdents64
.Dir::list_self
always fail with aBad file descriptor
errorThe text was updated successfully, but these errors were encountered: