Reuse errno_from_ioerror to simplify error handling

This commit is contained in:
Marcin Mielniczuk
2019-08-08 17:30:19 +02:00
committed by Jakub Konka
parent e18175c556
commit 92c2b563fc
8 changed files with 31 additions and 55 deletions

View File

@@ -1,5 +1,5 @@
use crate::fdentry::Descriptor;
use crate::sys::errno_from_host;
use crate::sys::{errno_from_host, errno_from_ioerror};
use crate::{host, Result};
use std::io;
use std::os::unix::prelude::{AsRawFd, FileTypeExt, FromRawFd, RawFd};
@@ -53,7 +53,7 @@ pub(crate) fn determine_type_rights<Fd: AsRawFd>(
std::mem::ManuallyDrop::new(unsafe { std::fs::File::from_raw_fd(fd.as_raw_fd()) });
let ft = file
.metadata()
.map_err(|err| err.raw_os_error().map_or(host::__WASI_EIO, errno_from_host))?
.map_err(errno_from_ioerror)?
.file_type();
if ft.is_block_device() {
(