graphics/fbbootlogd: Get rid of fevent and tracking handles
Fbbootlogd doesn't do non-blocking operations, so fevent isn't needed. And the kernel shouldn't pass closed handles to us and even if it does due to a bug, it is harmless to silently ignore the fact that the handle was closed.
This commit is contained in:
@@ -1,20 +1,13 @@
|
||||
use std::collections::{BTreeMap, VecDeque};
|
||||
use std::collections::VecDeque;
|
||||
|
||||
use redox_scheme::Scheme;
|
||||
use syscall::{Error, EventFlags, Result, EBADF, EINVAL, ENOENT};
|
||||
use syscall::{Error, Result, EINVAL, ENOENT};
|
||||
|
||||
use crate::display::Display;
|
||||
|
||||
pub struct Handle {
|
||||
pub events: EventFlags,
|
||||
pub notified_read: bool,
|
||||
}
|
||||
|
||||
pub struct FbbootlogScheme {
|
||||
display: Display,
|
||||
text_screen: console_draw::TextScreen,
|
||||
next_id: usize,
|
||||
pub handles: BTreeMap<usize, Handle>,
|
||||
}
|
||||
|
||||
impl FbbootlogScheme {
|
||||
@@ -22,8 +15,6 @@ impl FbbootlogScheme {
|
||||
FbbootlogScheme {
|
||||
display: Display::open_first_vt().expect("Failed to open display for vt"),
|
||||
text_screen: console_draw::TextScreen::new(),
|
||||
next_id: 0,
|
||||
handles: BTreeMap::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,32 +25,10 @@ impl Scheme for FbbootlogScheme {
|
||||
return Err(Error::new(ENOENT));
|
||||
}
|
||||
|
||||
let id = self.next_id;
|
||||
self.next_id += 1;
|
||||
|
||||
self.handles.insert(
|
||||
id,
|
||||
Handle {
|
||||
events: EventFlags::empty(),
|
||||
notified_read: false,
|
||||
},
|
||||
);
|
||||
|
||||
Ok(id)
|
||||
Ok(0)
|
||||
}
|
||||
|
||||
fn fevent(&mut self, id: usize, flags: syscall::EventFlags) -> Result<syscall::EventFlags> {
|
||||
let handle = self.handles.get_mut(&id).ok_or(Error::new(EBADF))?;
|
||||
|
||||
handle.notified_read = false;
|
||||
|
||||
handle.events = flags;
|
||||
Ok(syscall::EventFlags::empty())
|
||||
}
|
||||
|
||||
fn fpath(&mut self, id: usize, buf: &mut [u8]) -> Result<usize> {
|
||||
let _handle = self.handles.get(&id).ok_or(Error::new(EBADF))?;
|
||||
|
||||
fn fpath(&mut self, _id: usize, buf: &mut [u8]) -> Result<usize> {
|
||||
let path = b"fbbootlog:";
|
||||
|
||||
let mut i = 0;
|
||||
@@ -71,27 +40,21 @@ impl Scheme for FbbootlogScheme {
|
||||
Ok(i)
|
||||
}
|
||||
|
||||
fn fsync(&mut self, id: usize) -> Result<usize> {
|
||||
let _handle = self.handles.get(&id).ok_or(Error::new(EBADF))?;
|
||||
|
||||
return Ok(0);
|
||||
fn fsync(&mut self, _id: usize) -> Result<usize> {
|
||||
Ok(0)
|
||||
}
|
||||
|
||||
fn read(
|
||||
&mut self,
|
||||
id: usize,
|
||||
_id: usize,
|
||||
_buf: &mut [u8],
|
||||
_offset: u64,
|
||||
_fcntl_flags: u32,
|
||||
) -> Result<usize> {
|
||||
let _handle = self.handles.get(&id).ok_or(Error::new(EBADF))?;
|
||||
|
||||
Err(Error::new(EINVAL))
|
||||
}
|
||||
|
||||
fn write(&mut self, id: usize, buf: &[u8], _offset: u64, _fcntl_flags: u32) -> Result<usize> {
|
||||
let _handle = self.handles.get(&id).ok_or(Error::new(EBADF))?;
|
||||
|
||||
fn write(&mut self, _id: usize, buf: &[u8], _offset: u64, _fcntl_flags: u32) -> Result<usize> {
|
||||
let mut map = self.display.map.lock().unwrap();
|
||||
let damage = self.text_screen.write(
|
||||
&mut console_draw::DisplayMap {
|
||||
@@ -109,8 +72,7 @@ impl Scheme for FbbootlogScheme {
|
||||
Ok(buf.len())
|
||||
}
|
||||
|
||||
fn close(&mut self, id: usize) -> Result<usize> {
|
||||
self.handles.remove(&id).ok_or(Error::new(EBADF))?;
|
||||
fn close(&mut self, _id: usize) -> Result<usize> {
|
||||
Ok(0)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user