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

@@ -42,12 +42,12 @@ pub(crate) fn fd_pread(
offset: host::__wasi_filesize_t,
) -> Result<usize> {
read_at(file, buf, offset)
.map_err(|err| err.raw_os_error().map_or(host::__WASI_EIO, errno_from_host))
.map_err(errno_from_ioerror)
}
pub(crate) fn fd_pwrite(file: &File, buf: &[u8], offset: host::__wasi_filesize_t) -> Result<usize> {
write_at(file, buf, offset)
.map_err(|err| err.raw_os_error().map_or(host::__WASI_EIO, errno_from_host))
.map_err(errno_from_ioerror)
}
pub(crate) fn fd_fdstat_get(fd: &File) -> Result<host::__wasi_fdflags_t> {