mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-24 09:53:24 +00:00
Fix not write back error in (U)Random::read
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
42b3541dcb
commit
1fac737646
@ -47,7 +47,9 @@ impl Pollable for Random {
|
||||
impl FileIo for Random {
|
||||
fn read(&self, writer: &mut VmWriter) -> Result<usize> {
|
||||
let mut buf = vec![0; writer.avail()];
|
||||
Self::getrandom(buf.as_mut_slice())
|
||||
let size = Self::getrandom(buf.as_mut_slice());
|
||||
writer.write_fallible(&mut buf.as_slice().into())?;
|
||||
size
|
||||
}
|
||||
|
||||
fn write(&self, reader: &mut VmReader) -> Result<usize> {
|
||||
|
@ -47,7 +47,9 @@ impl Pollable for Urandom {
|
||||
impl FileIo for Urandom {
|
||||
fn read(&self, writer: &mut VmWriter) -> Result<usize> {
|
||||
let mut buf = vec![0; writer.avail()];
|
||||
Self::getrandom(buf.as_mut_slice())
|
||||
let size = Self::getrandom(buf.as_mut_slice());
|
||||
writer.write_fallible(&mut buf.as_slice().into())?;
|
||||
size
|
||||
}
|
||||
|
||||
fn write(&self, reader: &mut VmReader) -> Result<usize> {
|
||||
|
Reference in New Issue
Block a user