@@ -31,9 +31,10 @@ use core::marker::PhantomData;
3131use core:: num:: NonZeroU32 ;
3232use core:: ops:: { Deref , DerefMut } ;
3333use core:: time:: Duration ;
34- use ext4plus:: {
35- AsyncIterator , AsyncSkip , Dir , DirEntryName , Ext4 , Ext4Read , Ext4Write , File , FollowSymlinks ,
36- InodeCreationOptions , InodeFlags , InodeMode , Metadata , ReadDir , write_at,
34+ use ext4plus:: prelude:: {
35+ AsyncIterator , AsyncSkip , Dir , DirEntryName , Ext4 , Ext4Error , Ext4Read , Ext4Write , File ,
36+ FollowSymlinks , Inode as ExtInode , InodeCreationOptions , InodeFlags , InodeMode , Metadata ,
37+ PathBuf as ExtPathBuf , ReadDir , write_at,
3738} ;
3839use log:: error;
3940
@@ -59,13 +60,13 @@ impl Ext4Write for BlockBuffer {
5960 }
6061}
6162
62- impl From < ext4plus :: Ext4Error > for KernelError {
63- fn from ( err : ext4plus :: Ext4Error ) -> Self {
63+ impl From < Ext4Error > for KernelError {
64+ fn from ( err : Ext4Error ) -> Self {
6465 match err {
65- ext4plus :: Ext4Error :: NotFound => KernelError :: Fs ( FsError :: NotFound ) ,
66- ext4plus :: Ext4Error :: NotADirectory => KernelError :: Fs ( FsError :: NotADirectory ) ,
67- ext4plus :: Ext4Error :: AlreadyExists => KernelError :: Fs ( FsError :: AlreadyExists ) ,
68- ext4plus :: Ext4Error :: Corrupt ( c) => {
66+ Ext4Error :: NotFound => KernelError :: Fs ( FsError :: NotFound ) ,
67+ Ext4Error :: NotADirectory => KernelError :: Fs ( FsError :: NotADirectory ) ,
68+ Ext4Error :: AlreadyExists => KernelError :: Fs ( FsError :: AlreadyExists ) ,
69+ Ext4Error :: Corrupt ( c) => {
6970 error ! ( "Corrupt EXT4 filesystem: {c}, likely a bug" ) ;
7071 KernelError :: Fs ( FsError :: InvalidFs )
7172 }
@@ -143,34 +144,33 @@ impl DirStream for ReadDirWrapper {
143144 }
144145}
145146
146- #[ expect( clippy:: large_enum_variant) ]
147147enum InodeInner {
148148 Regular ( File ) ,
149149 Directory ( Dir ) ,
150- Other ( ext4plus :: Inode ) ,
150+ Other ( ExtInode ) ,
151151}
152152
153153impl InodeInner {
154- async fn new ( inode : ext4plus :: Inode , fs : & Ext4 ) -> Self {
154+ async fn new ( inode : ExtInode , fs : & Ext4 ) -> Self {
155155 match inode. file_type ( ) {
156156 ext4plus:: FileType :: Regular => {
157157 InodeInner :: Regular ( File :: open_inode ( fs, inode) . unwrap ( ) )
158158 }
159159 ext4plus:: FileType :: Directory => {
160- InodeInner :: Directory ( Dir :: open ( fs. clone ( ) , inode) . await . unwrap ( ) )
160+ InodeInner :: Directory ( Dir :: open_inode ( fs, inode) . await . unwrap ( ) )
161161 }
162162 _ => InodeInner :: Other ( inode) ,
163163 }
164164 }
165165}
166166
167167impl Deref for InodeInner {
168- type Target = ext4plus :: Inode ;
168+ type Target = ExtInode ;
169169
170170 fn deref ( & self ) -> & Self :: Target {
171171 match self {
172172 InodeInner :: Regular ( f) => f. inode ( ) ,
173- InodeInner :: Directory ( d) => d. as_ref ( ) ,
173+ InodeInner :: Directory ( d) => d. inode ( ) ,
174174 InodeInner :: Other ( i) => i,
175175 }
176176 }
@@ -180,7 +180,7 @@ impl DerefMut for InodeInner {
180180 fn deref_mut ( & mut self ) -> & mut Self :: Target {
181181 match self {
182182 InodeInner :: Regular ( f) => f. inode_mut ( ) ,
183- InodeInner :: Directory ( d) => d. as_mut ( ) ,
183+ InodeInner :: Directory ( d) => d. inode_mut ( ) ,
184184 InodeInner :: Other ( i) => i,
185185 }
186186 }
@@ -190,7 +190,7 @@ pub struct Ext4Inode<CPU: CpuOps> {
190190 fs_ref : Weak < Ext4Filesystem < CPU > > ,
191191 id : NonZeroU32 ,
192192 inner : Mutex < InodeInner , CPU > ,
193- path : ext4plus :: PathBuf ,
193+ path : ExtPathBuf ,
194194}
195195
196196#[ async_trait]
@@ -311,6 +311,7 @@ where
311311 name : & str ,
312312 file_type : FileType ,
313313 permissions : FilePermissions ,
314+ time : Option < Duration > ,
314315 ) -> Result < Arc < dyn Inode > > {
315316 let fs = self . fs_ref . upgrade ( ) . unwrap ( ) ;
316317 let mut inner = self . inner . lock ( ) . await ;
@@ -326,14 +327,14 @@ where
326327 mode : InodeMode :: S_IFREG | InodeMode :: from_bits ( permissions. bits ( ) ) . unwrap ( ) ,
327328 uid : 0 ,
328329 gid : 0 ,
329- time : Default :: default ( ) ,
330+ time : time . unwrap_or_default ( ) ,
330331 flags : InodeFlags :: empty ( ) ,
331332 } )
332333 . await ?;
333334 InodeInner :: Regular ( File :: open_inode ( & fs. inner , inode) ?)
334335 } else if matches ! ( file_type, FileType :: Directory ) {
335- let old_links_count = inner_dir. as_ref ( ) . links_count ( ) ;
336- inner_dir. as_mut ( ) . set_links_count ( old_links_count + 1 ) ;
336+ let old_links_count = inner_dir. inode ( ) . links_count ( ) ;
337+ inner_dir. inode_mut ( ) . set_links_count ( old_links_count + 1 ) ;
337338 let inode = fs
338339 . inner
339340 . create_inode ( InodeCreationOptions {
@@ -377,7 +378,7 @@ where
377378 if inode. id ( ) . fs_id ( ) != fs. id ( ) {
378379 return Err ( KernelError :: Fs ( FsError :: CrossDevice ) ) ;
379380 }
380- let mut other_inode = ext4plus :: Inode :: read (
381+ let mut other_inode = ExtInode :: read (
381382 & fs. inner ,
382383 ( inode. id ( ) . inode_id ( ) as u32 ) . try_into ( ) . unwrap ( ) ,
383384 )
@@ -445,12 +446,12 @@ where
445446 let old_parent_id = old_parent. id ( ) ;
446447 let fs = self . fs_ref . upgrade ( ) . unwrap ( ) ;
447448
448- let old_parent_inode = ext4plus :: Inode :: read (
449+ let old_parent_inode = ExtInode :: read (
449450 & fs. inner ,
450451 ( old_parent_id. inode_id ( ) as u32 ) . try_into ( ) . unwrap ( ) ,
451452 )
452453 . await ?;
453- let old_parent_dir = Dir :: open ( fs. inner . clone ( ) , old_parent_inode) . await ?;
454+ let old_parent_dir = Dir :: open_inode ( & fs. inner , old_parent_inode) . await ?;
454455
455456 let inner = self . inner . lock ( ) . await ;
456457 let inner_dir = match & * inner {
@@ -548,7 +549,7 @@ where
548549 . symlink (
549550 inner_dir,
550551 DirEntryName :: try_from ( name. as_bytes ( ) ) . unwrap ( ) ,
551- ext4plus :: PathBuf :: new ( target. as_str ( ) . as_bytes ( ) ) ,
552+ ExtPathBuf :: new ( target. as_str ( ) . as_bytes ( ) ) ,
552553 0 ,
553554 0 ,
554555 Duration :: from_secs ( 0 ) ,
@@ -618,7 +619,7 @@ where
618619 fs_ref : self . this . clone ( ) ,
619620 id : root. index ,
620621 inner : Mutex :: new ( InodeInner :: new ( root, & self . inner ) . await ) ,
621- path : ext4plus :: PathBuf :: new ( "/" ) ,
622+ path : ExtPathBuf :: new ( "/" ) ,
622623 } ) )
623624 }
624625
0 commit comments