put getrandom::Error into Error
This commit is contained in:
@@ -14,6 +14,8 @@ pub enum Error {
|
|||||||
TryFromInt(#[from] std::num::TryFromIntError),
|
TryFromInt(#[from] std::num::TryFromIntError),
|
||||||
#[error("Utf8Error: {0}")]
|
#[error("Utf8Error: {0}")]
|
||||||
Utf8(#[from] std::str::Utf8Error),
|
Utf8(#[from] std::str::Utf8Error),
|
||||||
|
#[error("GetRandom: {0}")]
|
||||||
|
GetRandom(#[from] getrandom::Error),
|
||||||
|
|
||||||
/// The host OS may return an io error that doesn't match one of the
|
/// The host OS may return an io error that doesn't match one of the
|
||||||
/// wasi errno variants we expect. We do not expose the details of this
|
/// wasi errno variants we expect. We do not expose the details of this
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use crate::wasi::wasi_snapshot_preview1::WasiSnapshotPreview1;
|
|||||||
use crate::wasi::{types, AsBytes};
|
use crate::wasi::{types, AsBytes};
|
||||||
use crate::{path, poll};
|
use crate::{path, poll};
|
||||||
use crate::{Error, Result, WasiCtx};
|
use crate::{Error, Result, WasiCtx};
|
||||||
use log::{debug, error, trace};
|
use log::{debug, trace};
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
use std::io::{self, SeekFrom};
|
use std::io::{self, SeekFrom};
|
||||||
use wiggle::{GuestPtr, GuestSlice};
|
use wiggle::{GuestPtr, GuestSlice};
|
||||||
@@ -802,10 +802,8 @@ impl<'a> WasiSnapshotPreview1 for WasiCtx {
|
|||||||
|
|
||||||
fn random_get(&self, buf: &GuestPtr<u8>, buf_len: types::Size) -> Result<()> {
|
fn random_get(&self, buf: &GuestPtr<u8>, buf_len: types::Size) -> Result<()> {
|
||||||
let mut slice = buf.as_array(buf_len).as_slice()?;
|
let mut slice = buf.as_array(buf_len).as_slice()?;
|
||||||
getrandom::getrandom(&mut *slice).map_err(|err| {
|
getrandom::getrandom(&mut *slice)?;
|
||||||
error!("getrandom failure: {:?}", err);
|
Ok(())
|
||||||
Error::Io
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sock_recv(
|
fn sock_recv(
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ impl From<Error> for Errno {
|
|||||||
Error::TryFromInt(_) => Errno::Overflow,
|
Error::TryFromInt(_) => Errno::Overflow,
|
||||||
Error::Utf8(_) => Errno::Ilseq,
|
Error::Utf8(_) => Errno::Ilseq,
|
||||||
Error::UnexpectedIo(_) => Errno::Io,
|
Error::UnexpectedIo(_) => Errno::Io,
|
||||||
|
Error::GetRandom(_) => Errno::Io,
|
||||||
Error::TooBig => Errno::TooBig,
|
Error::TooBig => Errno::TooBig,
|
||||||
Error::Acces => Errno::Acces,
|
Error::Acces => Errno::Acces,
|
||||||
Error::Badf => Errno::Badf,
|
Error::Badf => Errno::Badf,
|
||||||
|
|||||||
Reference in New Issue
Block a user