@@ -7,14 +7,15 @@ mod pipe;
77pub mod signalfd;
88
99use alloc:: { borrow:: Cow , sync:: Arc } ;
10- use core:: { any :: Any , ffi:: c_int, time:: Duration } ;
10+ use core:: { ffi:: c_int, time:: Duration } ;
1111
1212use axerrno:: { AxError , AxResult } ;
1313use axfs:: { FS_CONTEXT , OpenOptions } ;
1414use axfs_ng_vfs:: DeviceId ;
1515use axio:: prelude:: * ;
1616use axpoll:: Pollable ;
1717use axtask:: current;
18+ use downcast_rs:: { DowncastSync , impl_downcast} ;
1819use flatten_objects:: FlattenObjects ;
1920use linux_raw_sys:: general:: { RLIMIT_NOFILE , stat, statx, statx_timestamp} ;
2021use spin:: RwLock ;
@@ -133,7 +134,7 @@ impl<T: Read + IoBuf> ReadBuf for T {}
133134pub type IoSrc < ' a > = dyn ReadBuf + ' a ;
134135
135136#[ allow( dead_code) ]
136- pub trait FileLike : Pollable + Send + Sync {
137+ pub trait FileLike : Pollable + DowncastSync {
137138 fn read ( & self , _dst : & mut IoDst ) -> AxResult < usize > {
138139 Err ( AxError :: InvalidInput )
139140 }
@@ -146,8 +147,6 @@ pub trait FileLike: Pollable + Send + Sync {
146147 Ok ( Kstat :: default ( ) )
147148 }
148149
149- fn into_any ( self : Arc < Self > ) -> Arc < dyn Any + Send + Sync > ;
150-
151150 fn path ( & self ) -> Cow < ' _ , str > ;
152151
153152 fn ioctl ( & self , _cmd : u32 , _arg : usize ) -> AxResult < usize > {
@@ -167,8 +166,7 @@ pub trait FileLike: Pollable + Send + Sync {
167166 Self : Sized + ' static ,
168167 {
169168 get_file_like ( fd) ?
170- . into_any ( )
171- . downcast :: < Self > ( )
169+ . downcast_arc ( )
172170 . map_err ( |_| AxError :: InvalidInput )
173171 }
174172
@@ -179,6 +177,7 @@ pub trait FileLike: Pollable + Send + Sync {
179177 add_file_like ( Arc :: new ( self ) , cloexec)
180178 }
181179}
180+ impl_downcast ! ( sync FileLike ) ;
182181
183182#[ derive( Clone ) ]
184183pub struct FileDescriptor {
0 commit comments