mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-26 19:03:27 +00:00
Make FileIo
pollable
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
c7b3a596dd
commit
bbfc2cd12d
@ -3,7 +3,12 @@
|
||||
#![allow(unused_variables)]
|
||||
|
||||
use super::*;
|
||||
use crate::{events::IoEvents, fs::inode_handle::FileIo, prelude::*, process::signal::Poller};
|
||||
use crate::{
|
||||
events::IoEvents,
|
||||
fs::inode_handle::FileIo,
|
||||
prelude::*,
|
||||
process::signal::{Pollable, Poller},
|
||||
};
|
||||
|
||||
pub struct Zero;
|
||||
|
||||
@ -22,6 +27,13 @@ impl Device for Zero {
|
||||
}
|
||||
}
|
||||
|
||||
impl Pollable for Zero {
|
||||
fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents {
|
||||
let events = IoEvents::IN | IoEvents::OUT;
|
||||
events & mask
|
||||
}
|
||||
}
|
||||
|
||||
impl FileIo for Zero {
|
||||
fn read(&self, writer: &mut VmWriter) -> Result<usize> {
|
||||
let read_len = writer.fill_zeros(writer.avail())?;
|
||||
@ -31,9 +43,4 @@ impl FileIo for Zero {
|
||||
fn write(&self, reader: &mut VmReader) -> Result<usize> {
|
||||
Ok(reader.remain())
|
||||
}
|
||||
|
||||
fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents {
|
||||
let events = IoEvents::IN | IoEvents::OUT;
|
||||
events & mask
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user