mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-25 02:13:24 +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 Null;
|
||||
|
||||
@ -22,6 +27,13 @@ impl Device for Null {
|
||||
}
|
||||
}
|
||||
|
||||
impl Pollable for Null {
|
||||
fn poll(&self, mask: IoEvents, poller: Option<&mut Poller>) -> IoEvents {
|
||||
let events = IoEvents::IN | IoEvents::OUT;
|
||||
events & mask
|
||||
}
|
||||
}
|
||||
|
||||
impl FileIo for Null {
|
||||
fn read(&self, _writer: &mut VmWriter) -> Result<usize> {
|
||||
Ok(0)
|
||||
@ -30,9 +42,4 @@ impl FileIo for Null {
|
||||
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