@@ -4,7 +4,6 @@ use core::{
4
4
fmt:: { self , Display , Write } ,
5
5
} ;
6
6
7
- use hyperion_scheduler:: lock:: Once ;
8
7
use hyperion_vfs:: {
9
8
device:: { DirectoryDevice , FileDevice } ,
10
9
error:: { IoError , IoResult } ,
@@ -26,17 +25,17 @@ pub fn init(root: impl IntoNode) {
26
25
27
26
pub struct ProcFs < Mut > {
28
27
// TODO: doesnt have to be sync, use Option instead of Once
29
- cmdline : Once < Node < Mut > > ,
30
- version : Once < Node < Mut > > ,
31
- cpuinfo : Once < Node < Mut > > ,
28
+ cmdline : Option < Node < Mut > > ,
29
+ version : Option < Node < Mut > > ,
30
+ cpuinfo : Option < Node < Mut > > ,
32
31
}
33
32
34
33
impl < Mut : AnyMutex > ProcFs < Mut > {
35
34
pub const fn new ( ) -> Self {
36
35
Self {
37
- cmdline : Once :: new ( ) ,
38
- version : Once :: new ( ) ,
39
- cpuinfo : Once :: new ( ) ,
36
+ cmdline : None ,
37
+ version : None ,
38
+ cpuinfo : None ,
40
39
}
41
40
}
42
41
@@ -50,15 +49,15 @@ impl<Mut: AnyMutex> ProcFs<Mut> {
50
49
} ) )
51
50
}
52
51
53
- fn cmdline ( & self ) -> Node < Mut > {
52
+ fn cmdline ( & mut self ) -> Node < Mut > {
54
53
self . cmdline
55
- . call_once ( || Node :: new_file ( DisplayFile ( hyperion_boot:: args:: get ( ) . cmdline ) ) )
54
+ . get_or_insert_with ( || Node :: new_file ( DisplayFile ( hyperion_boot:: args:: get ( ) . cmdline ) ) )
56
55
. clone ( )
57
56
}
58
57
59
- fn version ( & self ) -> Node < Mut > {
58
+ fn version ( & mut self ) -> Node < Mut > {
60
59
self . version
61
- . call_once ( || {
60
+ . get_or_insert_with ( || {
62
61
Node :: new_file ( DisplayFile ( format ! (
63
62
"{} version {} #{} {}" ,
64
63
hyperion_kernel_info:: NAME ,
@@ -70,7 +69,7 @@ impl<Mut: AnyMutex> ProcFs<Mut> {
70
69
. clone ( )
71
70
}
72
71
73
- fn uptime ( & self ) -> Node < Mut > {
72
+ fn uptime ( & mut self ) -> Node < Mut > {
74
73
Node :: new_file ( DisplayFile ( Uptime {
75
74
system_s : ( hyperion_clock:: get ( ) . nanosecond_now ( ) / 10_000_000 ) as f32 / 100.0 ,
76
75
cpu_idle_sum_s : hyperion_scheduler:: idle ( )
@@ -79,9 +78,9 @@ impl<Mut: AnyMutex> ProcFs<Mut> {
79
78
} ) )
80
79
}
81
80
82
- fn cpuinfo ( & self ) -> Node < Mut > {
81
+ fn cpuinfo ( & mut self ) -> Node < Mut > {
83
82
self . cpuinfo
84
- . call_once ( || {
83
+ . get_or_insert_with ( || {
85
84
let mut buf = String :: new ( ) ;
86
85
for n in 0 ..hyperion_boot:: cpu_count ( ) {
87
86
_ = writeln ! ( & mut buf, "processor : {n}" ) ;
0 commit comments