(index: IfIndex, vm: &VirtualMachine)
| 3096 | #[cfg(not(target_os = "redox"))] |
| 3097 | #[pyfunction] |
| 3098 | fn if_indextoname(index: IfIndex, vm: &VirtualMachine) -> PyResult<String> { |
| 3099 | let mut buf = [0; c::IF_NAMESIZE + 1]; |
| 3100 | // in case 'if_indextoname' does not set errno |
| 3101 | crate::common::os::set_errno(libc::ENXIO); |
| 3102 | let ret = unsafe { c::if_indextoname(index, buf.as_mut_ptr()) }; |
| 3103 | if ret.is_null() { |
| 3104 | Err(vm.new_last_errno_error()) |
| 3105 | } else { |
| 3106 | let buf = unsafe { ffi::CStr::from_ptr(buf.as_ptr() as _) }; |
| 3107 | Ok(buf.to_string_lossy().into_owned()) |
| 3108 | } |
| 3109 | } |
| 3110 | |
| 3111 | #[cfg(any( |
| 3112 | windows, |
no test coverage detected