Sha256: 88e90b1ddef0a5e32eb24ad824580b62ab6b457b85d27d94038727739feabfb3

Contents?: true

Size: 717 Bytes

Versions: 39

Compression:

Stored size: 717 Bytes

Contents

use super::procfs::get_path_from_proc_self_fd;
use std::fs;
use std::path::PathBuf;

pub(crate) fn file_path(file: &fs::File) -> Option<PathBuf> {
    use std::os::unix::fs::MetadataExt;

    // Ignore paths that don't start with '/', which are things like
    // `socket:[3556564]` or similar.
    let path = get_path_from_proc_self_fd(file)
        .ok()
        .filter(|path| path.starts_with("/"))?;

    // Linux appends the string " (deleted)" when a file is deleted; avoid
    // treating that as the actual name. Check this after doing the `readlink`
    // above so that we're conservative about concurrent deletions.
    if file.metadata().ok()?.nlink() == 0 {
        return None;
    }

    Some(path)
}

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
wasmtime-30.0.2 ./ext/cargo-vendor/cap-primitives-3.4.2/src/rustix/linux/fs/file_path.rs
wasmtime-29.0.0 ./ext/cargo-vendor/cap-primitives-3.4.2/src/rustix/linux/fs/file_path.rs
wasmtime-28.0.0 ./ext/cargo-vendor/cap-primitives-3.4.2/src/rustix/linux/fs/file_path.rs
wasmtime-27.0.0 ./ext/cargo-vendor/cap-primitives-3.4.1/src/rustix/linux/fs/file_path.rs
wasmtime-26.0.0 ./ext/cargo-vendor/cap-primitives-3.3.0/src/rustix/linux/fs/file_path.rs
wasmtime-25.0.2 ./ext/cargo-vendor/cap-primitives-3.2.0/src/rustix/linux/fs/file_path.rs
wasmtime-25.0.1 ./ext/cargo-vendor/cap-primitives-3.2.0/src/rustix/linux/fs/file_path.rs
wasmtime-25.0.0 ./ext/cargo-vendor/cap-primitives-3.2.0/src/rustix/linux/fs/file_path.rs
wasmtime-24.0.0 ./ext/cargo-vendor/cap-primitives-3.2.0/src/rustix/linux/fs/file_path.rs
wasmtime-23.0.2 ./ext/cargo-vendor/cap-primitives-3.1.0/src/rustix/linux/fs/file_path.rs
wasmtime-22.0.0 ./ext/cargo-vendor/cap-primitives-3.1.0/src/rustix/linux/fs/file_path.rs
wasmtime-21.0.1 ./ext/cargo-vendor/cap-primitives-3.1.0/src/rustix/linux/fs/file_path.rs
wasmtime-20.0.2 ./ext/cargo-vendor/cap-primitives-3.1.0/src/rustix/linux/fs/file_path.rs
wasmtime-20.0.0 ./ext/cargo-vendor/cap-primitives-3.0.0/src/rustix/linux/fs/file_path.rs
wasmtime-18.0.3 ./ext/cargo-vendor/cap-primitives-2.0.1/src/rustix/linux/fs/file_path.rs
wasmtime-17.0.1 ./ext/cargo-vendor/cap-primitives-2.0.1/src/rustix/linux/fs/file_path.rs
wasmtime-17.0.0 ./ext/cargo-vendor/cap-primitives-2.0.1/src/rustix/linux/fs/file_path.rs
wasmtime-16.0.0 ./ext/cargo-vendor/cap-primitives-2.0.1/src/rustix/linux/fs/file_path.rs
wasmtime-15.0.1 ./ext/cargo-vendor/cap-primitives-2.0.1/src/rustix/linux/fs/file_path.rs
wasmtime-15.0.0 ./ext/cargo-vendor/cap-primitives-2.0.1/src/rustix/linux/fs/file_path.rs