Skip to content

Commit e41e233

Browse files
committed
fallback to procfs
1 parent a552dd9 commit e41e233

File tree

1 file changed

+10
-0
lines changed
  • library/std/src/sys/pal/unix

1 file changed

+10
-0
lines changed

library/std/src/sys/pal/unix/fs.rs

+10
Original file line numberDiff line numberDiff line change
@@ -1498,6 +1498,16 @@ impl fmt::Debug for File {
14981498
let mut buf = vec![0; libc::PATH_MAX as usize];
14991499
let n = unsafe { libc::fcntl(fd, libc::F_GETPATH, buf.as_ptr()) };
15001500
if n == -1 {
1501+
cfg_if::cfg_if! {
1502+
if #[cfg(target_os = "netbsd")] {
1503+
// fallback to procfs as last resort
1504+
let mut p = PathBuf::from("/proc/self/fd");
1505+
p.push(&fd.to_string());
1506+
if p.exists() {
1507+
return readlink(&p).ok();
1508+
}
1509+
}
1510+
}
15011511
return None;
15021512
}
15031513
let l = buf.iter().position(|&c| c == 0).unwrap();

0 commit comments

Comments
 (0)