From 31450e577047d93fee6eca6c7160b00fccf1b09d Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sat, 22 Feb 2025 16:32:56 +0100 Subject: [PATCH] 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. --- graphics/fbbootlogd/src/scheme.rs | 56 +++++-------------------------- 1 file changed, 9 insertions(+), 47 deletions(-) diff --git a/graphics/fbbootlogd/src/scheme.rs b/graphics/fbbootlogd/src/scheme.rs index 1e9f408ef8..3447a91466 100644 --- a/graphics/fbbootlogd/src/scheme.rs +++ b/graphics/fbbootlogd/src/scheme.rs @@ -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, } 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 { - 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 { - let _handle = self.handles.get(&id).ok_or(Error::new(EBADF))?; - + fn fpath(&mut self, _id: usize, buf: &mut [u8]) -> Result { 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 { - let _handle = self.handles.get(&id).ok_or(Error::new(EBADF))?; - - return Ok(0); + fn fsync(&mut self, _id: usize) -> Result { + Ok(0) } fn read( &mut self, - id: usize, + _id: usize, _buf: &mut [u8], _offset: u64, _fcntl_flags: u32, ) -> Result { - 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 { - 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 { 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 { - self.handles.remove(&id).ok_or(Error::new(EBADF))?; + fn close(&mut self, _id: usize) -> Result { Ok(0) } }