1
1
use crate :: lock:: Mtx ;
2
+ use crate :: vnode:: Vnode ;
2
3
use crate :: Kernel ;
3
- use core:: ffi:: c_char;
4
+ use core:: ffi:: { c_char, c_int} ;
5
+ use core:: mem:: MaybeUninit ;
6
+ use core:: num:: NonZero ;
4
7
use okf:: queue:: TailQueueEntry ;
5
8
6
9
/// Implementation of [`okf::mount::Mount`] for 11.00.
@@ -9,7 +12,7 @@ pub struct Mount {
9
12
mtx : Mtx ,
10
13
pad1 : [ u8 ; 0x8 ] ,
11
14
entry : TailQueueEntry < Self > ,
12
- pad2 : [ u8 ; 8 ] ,
15
+ ops : * const FsOps ,
13
16
fs : * mut Filesystem ,
14
17
pad3 : [ u8 ; 0x38 ] ,
15
18
flags : u64 ,
@@ -34,6 +37,10 @@ impl okf::mount::Mount<Kernel> for Mount {
34
37
self . fs
35
38
}
36
39
40
+ fn ops ( & self ) -> & ' static FsOps {
41
+ unsafe { & * self . ops }
42
+ }
43
+
37
44
unsafe fn flags ( & self ) -> u64 {
38
45
self . flags
39
46
}
@@ -56,6 +63,25 @@ impl okf::mount::Filesystem for Filesystem {
56
63
}
57
64
}
58
65
66
+ /// Implementation of [`okf::mount::FsOps`] for 11.00.
67
+ #[ repr( C ) ]
68
+ pub struct FsOps {
69
+ pad1 : [ u8 ; 0x18 ] ,
70
+ root : unsafe extern "C" fn ( * mut Mount , c_int , * mut * mut Vnode ) -> c_int ,
71
+ }
72
+
73
+ impl okf:: mount:: FsOps < Kernel > for FsOps {
74
+ unsafe fn root ( & self , mp : * mut Mount , flags : c_int ) -> Result < * mut Vnode , NonZero < c_int > > {
75
+ let mut vp = MaybeUninit :: uninit ( ) ;
76
+ let errno = ( self . root ) ( mp, flags, vp. as_mut_ptr ( ) ) ;
77
+
78
+ match NonZero :: new ( errno) {
79
+ Some ( v) => Err ( v) ,
80
+ None => Ok ( vp. assume_init ( ) ) ,
81
+ }
82
+ }
83
+ }
84
+
59
85
/// Implementation of [`okf::mount::FsStats`] for 11.00.
60
86
#[ repr( C ) ]
61
87
pub struct FsStats {
0 commit comments