diff --git a/os/src/fs/inode.rs b/os/src/fs/inode.rs index 172b6cc4..04ccb45f 100644 --- a/os/src/fs/inode.rs +++ b/os/src/fs/inode.rs @@ -10,7 +10,6 @@ use alloc::vec::Vec; use spin::Mutex; use super::File; use crate::mm::UserBuffer; -use core::any::Any; pub struct OSInode { readable: bool, @@ -157,5 +156,4 @@ impl File for OSInode { } total_write_size } - fn as_any_ref(&self) -> &dyn Any { self } } \ No newline at end of file diff --git a/os/src/fs/mod.rs b/os/src/fs/mod.rs index 5f1f7aa6..c015702d 100644 --- a/os/src/fs/mod.rs +++ b/os/src/fs/mod.rs @@ -3,21 +3,12 @@ mod stdio; mod inode; use crate::mm::UserBuffer; -use core::any::Any; -pub trait File : Any + Send + Sync { +pub trait File : Send + Sync { fn readable(&self) -> bool; fn writable(&self) -> bool; fn read(&self, buf: UserBuffer) -> usize; fn write(&self, buf: UserBuffer) -> usize; - fn as_any_ref(&self) -> &dyn Any; -} - -impl dyn File { - #[allow(unused)] - pub fn downcast_ref(&self) -> Option<&T> { - self.as_any_ref().downcast_ref::() - } } pub use pipe::{Pipe, make_pipe}; diff --git a/os/src/fs/pipe.rs b/os/src/fs/pipe.rs index ce3dd2ad..1027b472 100644 --- a/os/src/fs/pipe.rs +++ b/os/src/fs/pipe.rs @@ -5,7 +5,6 @@ use crate::mm::{ UserBuffer, }; use crate::task::suspend_current_and_run_next; -use core::any::Any; pub struct Pipe { readable: bool, @@ -165,5 +164,4 @@ impl File for Pipe { } } } - fn as_any_ref(&self) -> &dyn Any { self } } \ No newline at end of file diff --git a/os/src/fs/stdio.rs b/os/src/fs/stdio.rs index 3af40cc0..e8df7950 100644 --- a/os/src/fs/stdio.rs +++ b/os/src/fs/stdio.rs @@ -2,7 +2,6 @@ use super::File; use crate::mm::{UserBuffer}; use crate::sbi::console_getchar; use crate::task::suspend_current_and_run_next; -use core::any::Any; pub struct Stdin; @@ -31,7 +30,6 @@ impl File for Stdin { fn write(&self, _user_buf: UserBuffer) -> usize { panic!("Cannot write to stdin!"); } - fn as_any_ref(&self) -> &dyn Any { self } } impl File for Stdout { @@ -46,5 +44,4 @@ impl File for Stdout { } user_buf.len() } - fn as_any_ref(&self) -> &dyn Any { self } } \ No newline at end of file