mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-22 00:43:24 +00:00
Remove the as_any_ref() function for trait
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
902b0421c3
commit
b34dc85e7e
@ -341,10 +341,6 @@ impl FileLike for EpollFile {
|
|||||||
.unregister_observer(observer)
|
.unregister_observer(observer)
|
||||||
.ok_or_else(|| Error::with_message(Errno::ENOENT, "observer is not registered"))
|
.ok_or_else(|| Error::with_message(Errno::ENOENT, "observer is not registered"))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_any_ref(&self) -> &dyn Any {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An epoll entry contained in an epoll file. Each epoll entry is added, modified,
|
/// An epoll entry contained in an epoll file. Each epoll entry is added, modified,
|
||||||
|
@ -63,12 +63,10 @@ pub trait FileLike: Send + Sync + Any {
|
|||||||
) -> Result<Weak<dyn Observer<IoEvents>>> {
|
) -> Result<Weak<dyn Observer<IoEvents>>> {
|
||||||
return_errno_with_message!(Errno::EINVAL, "unregister_observer is not supported")
|
return_errno_with_message!(Errno::EINVAL, "unregister_observer is not supported")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_any_ref(&self) -> &dyn Any;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl dyn FileLike {
|
impl dyn FileLike {
|
||||||
pub fn downcast_ref<T: FileLike>(&self) -> Option<&T> {
|
pub fn downcast_ref<T: FileLike>(&self) -> Option<&T> {
|
||||||
self.as_any_ref().downcast_ref::<T>()
|
(self as &dyn Any).downcast_ref::<T>()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,8 +88,4 @@ impl FileLike for InodeHandle<Rights> {
|
|||||||
// Close does not guarantee that the data has been successfully saved to disk.
|
// Close does not guarantee that the data has been successfully saved to disk.
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_any_ref(&self) -> &dyn Any {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -57,10 +57,6 @@ impl FileLike for PipeReader {
|
|||||||
) -> Result<Weak<dyn Observer<IoEvents>>> {
|
) -> Result<Weak<dyn Observer<IoEvents>>> {
|
||||||
self.consumer.unregister_observer(observer)
|
self.consumer.unregister_observer(observer)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_any_ref(&self) -> &dyn Any {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct PipeWriter {
|
pub struct PipeWriter {
|
||||||
@ -116,10 +112,6 @@ impl FileLike for PipeWriter {
|
|||||||
) -> Result<Weak<dyn Observer<IoEvents>>> {
|
) -> Result<Weak<dyn Observer<IoEvents>>> {
|
||||||
self.producer.unregister_observer(observer)
|
self.producer.unregister_observer(observer)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_any_ref(&self) -> &dyn Any {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn should_io_return(res: &Result<usize>, is_nonblocking: bool) -> bool {
|
fn should_io_return(res: &Result<usize>, is_nonblocking: bool) -> bool {
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
use alloc::string::{String, ToString};
|
|
||||||
use core::any::Any;
|
|
||||||
use core::sync::atomic::{AtomicUsize, Ordering};
|
use core::sync::atomic::{AtomicUsize, Ordering};
|
||||||
|
|
||||||
use crate::events::Observer;
|
use crate::events::Observer;
|
||||||
@ -66,10 +64,6 @@ impl FileSystem for ProcFS {
|
|||||||
fn flags(&self) -> FsFlags {
|
fn flags(&self) -> FsFlags {
|
||||||
FsFlags::NO_PAGECACHE
|
FsFlags::NO_PAGECACHE
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_any_ref(&self) -> &dyn Any {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents the inode at `/proc`.
|
/// Represents the inode at `/proc`.
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
use alloc::string::String;
|
|
||||||
use core::any::Any;
|
|
||||||
use core::time::Duration;
|
use core::time::Duration;
|
||||||
use jinux_frame::vm::VmFrame;
|
use jinux_frame::vm::VmFrame;
|
||||||
use jinux_util::slot_vec::SlotVec;
|
use jinux_util::slot_vec::SlotVec;
|
||||||
@ -211,10 +209,6 @@ impl<D: DirOps + 'static> Inode for ProcDir<D> {
|
|||||||
fn is_dentry_cacheable(&self) -> bool {
|
fn is_dentry_cacheable(&self) -> bool {
|
||||||
!self.info.is_volatile()
|
!self.info.is_volatile()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_any_ref(&self) -> &dyn Any {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait DirOps: Sync + Send {
|
pub trait DirOps: Sync + Send {
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
use alloc::string::String;
|
|
||||||
use core::any::Any;
|
|
||||||
use core::time::Duration;
|
use core::time::Duration;
|
||||||
use jinux_frame::vm::VmFrame;
|
use jinux_frame::vm::VmFrame;
|
||||||
|
|
||||||
@ -125,10 +123,6 @@ impl<F: FileOps + 'static> Inode for ProcFile<F> {
|
|||||||
fn is_dentry_cacheable(&self) -> bool {
|
fn is_dentry_cacheable(&self) -> bool {
|
||||||
!self.info.is_volatile()
|
!self.info.is_volatile()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_any_ref(&self) -> &dyn Any {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait FileOps: Sync + Send {
|
pub trait FileOps: Sync + Send {
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
use alloc::string::String;
|
|
||||||
use core::any::Any;
|
|
||||||
use core::time::Duration;
|
use core::time::Duration;
|
||||||
use jinux_frame::vm::VmFrame;
|
use jinux_frame::vm::VmFrame;
|
||||||
|
|
||||||
@ -120,10 +118,6 @@ impl<S: SymOps + 'static> Inode for ProcSym<S> {
|
|||||||
fn is_dentry_cacheable(&self) -> bool {
|
fn is_dentry_cacheable(&self) -> bool {
|
||||||
!self.info.is_volatile()
|
!self.info.is_volatile()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_any_ref(&self) -> &dyn Any {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait SymOps: Sync + Send {
|
pub trait SymOps: Sync + Send {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use alloc::str;
|
use alloc::str;
|
||||||
use alloc::string::String;
|
use alloc::string::String;
|
||||||
use core::any::Any;
|
|
||||||
use core::sync::atomic::{AtomicUsize, Ordering};
|
use core::sync::atomic::{AtomicUsize, Ordering};
|
||||||
use core::time::Duration;
|
use core::time::Duration;
|
||||||
use jinux_frame::vm::VmFrame;
|
use jinux_frame::vm::VmFrame;
|
||||||
@ -67,10 +66,6 @@ impl FileSystem for RamFS {
|
|||||||
fn flags(&self) -> FsFlags {
|
fn flags(&self) -> FsFlags {
|
||||||
FsFlags::DENTRY_UNEVICTABLE
|
FsFlags::DENTRY_UNEVICTABLE
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_any_ref(&self) -> &dyn Any {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RamInode(RwLock<Inode_>);
|
struct RamInode(RwLock<Inode_>);
|
||||||
@ -643,10 +638,6 @@ impl Inode for RamInode {
|
|||||||
fn ioctl(&self, cmd: &IoctlCmd) -> Result<()> {
|
fn ioctl(&self, cmd: &IoctlCmd) -> Result<()> {
|
||||||
return_errno!(Errno::ENOSYS);
|
return_errno!(Errno::ENOSYS);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_any_ref(&self) -> &dyn Any {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_lock_two_inodes<'a>(
|
fn write_lock_two_inodes<'a>(
|
||||||
|
@ -69,10 +69,6 @@ impl FileLike for Stdin {
|
|||||||
rdev: 0,
|
rdev: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_any_ref(&self) -> &dyn Any {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
impl FileLike for Stdout {
|
impl FileLike for Stdout {
|
||||||
fn ioctl(&self, cmd: super::utils::IoctlCmd, arg: usize) -> Result<i32> {
|
fn ioctl(&self, cmd: super::utils::IoctlCmd, arg: usize) -> Result<i32> {
|
||||||
@ -114,10 +110,6 @@ impl FileLike for Stdout {
|
|||||||
rdev: 0,
|
rdev: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_any_ref(&self) -> &dyn Any {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FileLike for Stderr {
|
impl FileLike for Stderr {
|
||||||
@ -160,10 +152,6 @@ impl FileLike for Stderr {
|
|||||||
rdev: 0,
|
rdev: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_any_ref(&self) -> &dyn Any {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Stdin {
|
impl Stdin {
|
||||||
|
@ -55,12 +55,10 @@ pub trait FileSystem: Any + Sync + Send {
|
|||||||
fn sb(&self) -> SuperBlock;
|
fn sb(&self) -> SuperBlock;
|
||||||
|
|
||||||
fn flags(&self) -> FsFlags;
|
fn flags(&self) -> FsFlags;
|
||||||
|
|
||||||
fn as_any_ref(&self) -> &dyn Any;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl dyn FileSystem {
|
impl dyn FileSystem {
|
||||||
pub fn downcast_ref<T: FileSystem>(&self) -> Option<&T> {
|
pub fn downcast_ref<T: FileSystem>(&self) -> Option<&T> {
|
||||||
self.as_any_ref().downcast_ref::<T>()
|
(self as &dyn Any).downcast_ref::<T>()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -204,8 +204,6 @@ pub trait Inode: Any + Sync + Send {
|
|||||||
|
|
||||||
fn fs(&self) -> Arc<dyn FileSystem>;
|
fn fs(&self) -> Arc<dyn FileSystem>;
|
||||||
|
|
||||||
fn as_any_ref(&self) -> &dyn Any;
|
|
||||||
|
|
||||||
/// Returns whether a VFS dentry for this inode should be put into the dentry cache.
|
/// Returns whether a VFS dentry for this inode should be put into the dentry cache.
|
||||||
///
|
///
|
||||||
/// The dentry cache in the VFS layer can accelerate the lookup of inodes. So usually,
|
/// The dentry cache in the VFS layer can accelerate the lookup of inodes. So usually,
|
||||||
@ -229,6 +227,6 @@ pub trait Inode: Any + Sync + Send {
|
|||||||
|
|
||||||
impl dyn Inode {
|
impl dyn Inode {
|
||||||
pub fn downcast_ref<T: Inode>(&self) -> Option<&T> {
|
pub fn downcast_ref<T: Inode>(&self) -> Option<&T> {
|
||||||
self.as_any_ref().downcast_ref::<T>()
|
(self as &dyn Any).downcast_ref::<T>()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#![feature(fn_traits)]
|
#![feature(fn_traits)]
|
||||||
#![feature(linked_list_remove)]
|
#![feature(linked_list_remove)]
|
||||||
#![feature(register_tool)]
|
#![feature(register_tool)]
|
||||||
|
#![feature(trait_upcasting)]
|
||||||
#![register_tool(component_access_control)]
|
#![register_tool(component_access_control)]
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -79,8 +79,4 @@ impl FileLike for BusyBoxTraceFile {
|
|||||||
debug!("ASH TRACE: {}", core::str::from_utf8(buf)?);
|
debug!("ASH TRACE: {}", core::str::from_utf8(buf)?);
|
||||||
Ok(buf.len())
|
Ok(buf.len())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_any_ref(&self) -> &dyn Any {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -129,10 +129,6 @@ impl FileLike for Tty {
|
|||||||
rdev: 0,
|
rdev: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_any_ref(&self) -> &dyn Any {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// FIXME: should we maintain a static console?
|
/// FIXME: should we maintain a static console?
|
||||||
|
Reference in New Issue
Block a user