-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
fs::read_dir()
fails with error 0 on Linux if directory is on NTFS and contains file with filename > 255 bytes
#86649
Comments
So NTFS has a limit of 255 UTF-16 code units. However, something here is interpreting that as being a UTF-8 byte limit of 255. I think this error originates outside of Rust? If |
Note that the screenshots in ogham/exa#893 (comment) shows that I guess it reported strange errors because this is not correct: rust/library/std/src/sys/unix/fs.rs Line 501 in 543ab99
According to https://manpages.debian.org/unstable/manpages-dev/readdir_r.3.en.html#RETURN_VALUE, readdir_r "returns a positive error number" on error. It does not mention that it'll set errno , so I think Error::last_os_error() might not return the correct error.
However, the code does check the return value |
Ah, I was already wondering why the error message says |
POSIX says: > If successful, the readdir_r() function shall return zero; otherwise, > an error number shall be returned to indicate the error. But we were previously using errno instead of the return value. This led to issue rust-lang#86649.
Use the return value of readdir_r() instead of errno POSIX says: > If successful, the readdir_r() function shall return zero; otherwise, > an error number shall be returned to indicate the error. But we were previously using errno instead of the return value. This led to issue rust-lang#86649.
So this should no longer say "success". It should say something like "file name too long" instead now. A complete fix is just replacing readdir_r() with readdir() on LInux, which I'll do unless someone beats me to it. See #40021 for some historical details. |
readdir() is preferred over readdir_r() on Linux and many other platforms because it more gracefully supports long file names. Both glibc and musl (and presumably all other Linux libc implementations) guarantee that readdir() is thread-safe as long as a single DIR* is not accessed concurrently, which is enough to make a readdir()-based implementation of ReadDir safe. This implementation is already used for some other OSes including Fuchsia, Redox, and Solaris. See rust-lang#40021 for more details. Fixes rust-lang#86649.
…shtriplett fs: Use readdir() instead of readdir_r() on Linux readdir() is preferred over readdir_r() on Linux and many other platforms because it more gracefully supports long file names. Both glibc and musl (and presumably all other Linux libc implementations) guarantee that readdir() is thread-safe as long as a single DIR* is not accessed concurrently, which is enough to make a readdir()-based implementation of ReadDir safe. This implementation is already used for some other OSes including Fuchsia, Redox, and Solaris. See rust-lang#40021 for more details. Fixes rust-lang#86649.
readdir() is preferred over readdir_r() on Linux and many other platforms because it more gracefully supports long file names. Both glibc and musl (and presumably all other Linux libc implementations) guarantee that readdir() is thread-safe as long as a single DIR* is not accessed concurrently, which is enough to make a readdir()-based implementation of ReadDir safe. This implementation is already used for some other OSes including Fuchsia, Redox, and Solaris. See rust-lang#40021 for more details. Fixes rust-lang#86649.
…shtriplett fs: Use readdir() instead of readdir_r() on Linux readdir() is preferred over readdir_r() on Linux and many other platforms because it more gracefully supports long file names. Both glibc and musl (and presumably all other Linux libc implementations) guarantee that readdir() is thread-safe as long as a single DIR* is not accessed concurrently, which is enough to make a readdir()-based implementation of ReadDir safe. This implementation is already used for some other OSes including Fuchsia, Redox, and Solaris. See rust-lang#40021 for more details. Fixes rust-lang#86649.
…shtriplett fs: Use readdir() instead of readdir_r() on Linux and Android See rust-lang#40021 for more details. Fixes rust-lang#86649. Fixes rust-lang#34668.
一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十
.I expected to see this happen: the code works until it panics on
todo!()
Instead, this happened:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 0, kind: Other, message: "Success" }', test.rs:11:42
. Note that in exa, it fails withBad address (os error 14)
.Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: