(f: &File)
| 722 | |
| 723 | impl DiskTopology { |
| 724 | fn is_block_device(f: &File) -> std::io::Result<bool> { |
| 725 | let mut stat = std::mem::MaybeUninit::<libc::stat>::uninit(); |
| 726 | // SAFETY: FFI call with a valid fd and buffer |
| 727 | let ret = unsafe { libc::fstat(f.as_raw_fd(), stat.as_mut_ptr()) }; |
| 728 | if ret != 0 { |
| 729 | return Err(std::io::Error::last_os_error()); |
| 730 | } |
| 731 | |
| 732 | // SAFETY: stat is valid at this point |
| 733 | let is_block = unsafe { (*stat.as_ptr()).st_mode & S_IFMT == S_IFBLK }; |
| 734 | Ok(is_block) |
| 735 | } |
| 736 | |
| 737 | // libc::ioctl() takes different types on different architectures |
| 738 | fn query_block_size(f: &File, block_size_type: BlockSize) -> std::io::Result<u64> { |
no test coverage detected