Skip to content
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

"Input/output error" while there is a long filename #181

Open
b0207191 opened this issue May 6, 2023 · 1 comment
Open

"Input/output error" while there is a long filename #181

b0207191 opened this issue May 6, 2023 · 1 comment

Comments

@b0207191
Copy link

b0207191 commented May 6, 2023

if there is a file whose filename is too long, about 190 bytes, walk will fail and report error forever.
/mnt/d/tmp/rustmp/a1 - 副本.txt
/mnt/d/tmp/rustmp/a1.txt
failed to access entry
Error 1 Err(Error { depth: 1, inner: Io { path: None, err: Os { code: 5, kind: Uncategorized, message: "Input/output error" } } })
failed to access entry
Error 2 Err(Error { depth: 1, inner: Io { path: None, err: Os { code: 5, kind: Uncategorized, message: "Input/output error" } } })
failed to access entry
Error 3 Err(Error { depth: 1, inner: Io { path: None, err: Os { code: 5, kind: Uncategorized, message: "Input/output error" } } })
failed to access entry
Error 4 Err(Error { depth: 1, inner: Io { path: None, err: Os { code: 5, kind: Uncategorized, message: "Input/output error" } } })
failed to access entry
Error 5 Err(Error { depth: 1, inner: Io { path: None, err: Os { code: 5, kind: Uncategorized, message: "Input/output error" } } })
failed to access entry
Error 6 Err(Error { depth: 1, inner: Io { path: None, err: Os { code: 5, kind: Uncategorized, message: "Input/output error" } } })

my code is just like this

`

fn walk(inpath:String, list:&mut Vec) {
let mut errv:i32 = 0;
let path = Path::new(&inpath);
for entry in WalkDir::new(path){
match &entry {
Ok(path) => {
println!("{}", path.path().display());
}
}
Err(err) => {
let errpath = err.path().unwrap_or(Path::new("")).display();
println!("failed to access entry {}", errpath);
errv = errv+1;
println!("Error {} {:?}", errv, entry);
let three_seconds = Duration::from_secs(3);
sleep(three_seconds);
continue
}
`

i guess it happens because the program running in Linux is going to read a directory in NTFS of windows, there is a limit of max 256 for filename in linux filesystem, but in windows, there is no such limit.

i wonder how to skip the error entry when it happens, in this case , the program seems to be in a loop, although in the doc it says :"If an error occurs at any point during iteration, then it is returned in place of its corresponding directory entry and iteration continues as normal. "

@BurntSushi
Copy link
Owner

Windows certainly has a limit on the length of file paths. You might try using verbatim paths. Otherwise walkdir is just surfacing OS errors. I'm not sure there's anything it can do.

In terms of dealing with the error, you haven't provided code that I can actually run. Please provide a reproducible example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants