Skip to content

fs::copy: Cannot copy special/device files (ex: /dev/null) into a file #79390

Open
@sylvestre

Description

@sylvestre

I tried this code:

use std::fs;

fn main() {
    match fs::copy("/dev/null", "bar.txt") {
        Ok(_n) => (),
        Err(e) => {
            println!("{}", e);
            ()
        }
    }
}

I expected to see this happen:
I agree that the use case isn't super useful. But I would expect this to work and create an empty file.

Instead, this happened:

the source path is not an existing regular file

Don't hesitate to wontfix this bug...

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-unixOperating system: Unix-likeT-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