Skip to content

fs::read_dir() fails with error 0 on Linux if directory is on NTFS and contains file with filename > 255 bytes #86649

Closed
@ariasuni

Description

@ariasuni
  1. Create a filename on an NTFS partition with a name > 255 bytes, e.g. 一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十.
  2. 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};

fn main() {
    test().unwrap();
}

fn test() -> 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).

Meta

rustc --version --verbose:

rustc 1.53.0 (53cb7b09b 2021-06-17)
binary: rustc
commit-hash: 53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b
commit-date: 2021-06-17
host: x86_64-unknown-linux-gnu
release: 1.53.0
LLVM version: 12.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.O-linuxOperating system: LinuxT-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions