You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fs::read_dir() fails with error 0 on Linux if directory is on NTFS and contains file with filename > 255 bytes #86649
Create a filename on an NTFS partition with a name > 255 bytes, e.g. 一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十.
Run this code with the path to the directory containing the file with the very long filename:
use std::env;use std::fs::{self,ReadDir};fnmain(){test().unwrap();}fntest() -> std::io::Result<ReadDir>{let args:Vec<String> = env::args().collect();for result in fs::read_dir(&args[1])? {
result.map(|entry| entry.path()).unwrap();}todo!()}
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 with Bad address (os error 14).
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.
Activity
ChrisDenton commentedon Jun 26, 2021
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
libc::opendiris returning a null pointer then I'm not sure what Rust can do?RalfJung commentedon Jul 3, 2021
Ah, I was already wondering why the error message says
Success. 😂Use the return value of readdir_r() instead of errno
Rollup merge of rust-lang#88542 - tavianator:readdir_r-errno, r=jyn514
tavianator commentedon Sep 1, 2021
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.
fs: Use readdir() instead of readdir_r() on Linux
Rollup merge of rust-lang#92778 - tavianator:linux-readdir-no-r, r=jo…
fs: Use readdir() instead of readdir_r() on Linux
Rollup merge of rust-lang#92778 - tavianator:linux-readdir-no-r, r=jo…
Rollup merge of rust-lang#92778 - tavianator:linux-readdir-no-r, r=jo…