Skip to content

std::fs::canonicalize failed to process path mounted with cppcryptfs/dokan under windows #129237

Open
@9-2-1

Description

@9-2-1

I tried this code:

use std::fs::canonicalize;

pub fn main() {
    println!("{}", canonicalize("F:\\gofs").unwrap().display());
    // Where F:\gofs is a path mounted with cppcryptfs which use Dokan library.
}

I expected to see this happen:
print \\?\F:\gofs.

Instead, this happened:

thread 'main' panicked at src/main.rs:5:45:
called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "系统找不到指定的文件。" }

I have double checked that F:\gofs is exist and accessible.

Meta

rustc --version --verbose:

rustc 1.80.1 (3f5fd8dd4 2024-08-06)
binary: rustc
commit-hash: 3f5fd8dd41153bc5fdca9427e9e05be2c767ba23
commit-date: 2024-08-06
host: x86_64-pc-windows-msvc
release: 1.80.1
LLVM version: 18.1.7
Backtrace

stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\std\src\panicking.rs:652
   1: core::panicking::panic_fmt
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\core\src\panicking.rs:72
   2: core::result::unwrap_failed
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23/library\core\src\result.rs:1679
   3: enum2$<core::result::Result<std::path::PathBuf,std::io::error::Error> >::unwrap
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\core\src\result.rs:1102
   4: test_dunce::main
             at .\src\main.rs:5
   5: core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\core\src\ops\function.rs:250
   6: core::hint::black_box
             at /rustc/3f5fd8dd41153bc5fdca9427e9e05be2c767ba23\library\core\src\hint.rs:338

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ioArea: `std::io`, `std::fs`, `std::net` and `std::path`C-bugCategory: This is a bug.O-windowsOperating system: WindowsT-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