Make FileIo pollable

This commit is contained in:
Ruihan Li
2024-09-02 14:31:20 +08:00
committed by Tate, Hongliang Tian
parent c7b3a596dd
commit bbfc2cd12d
13 changed files with 112 additions and 74 deletions

View File

@ -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
}
}