@@ -74,6 +74,10 @@ pub enum ProcEntryType {
7474 CowInfo ,
7575 /// /proc/mounts - mounted filesystems
7676 Mounts ,
77+ /// /proc/breenix - breenix info directory
78+ BreenixDir ,
79+ /// /proc/breenix/testing - whether testing mode is active
80+ BreenixTesting ,
7781 /// /proc/[pid] - per-process directory (dynamic, not registered)
7882 PidDir ( u64 ) ,
7983 /// /proc/[pid]/status - per-process status (dynamic, not registered)
@@ -101,6 +105,8 @@ impl ProcEntryType {
101105 ProcEntryType :: Stat => "stat" ,
102106 ProcEntryType :: CowInfo => "cowinfo" ,
103107 ProcEntryType :: Mounts => "mounts" ,
108+ ProcEntryType :: BreenixDir => "breenix" ,
109+ ProcEntryType :: BreenixTesting => "testing" ,
104110 ProcEntryType :: PidDir ( _) => "pid" ,
105111 ProcEntryType :: PidStatus ( _) => "status" ,
106112 }
@@ -126,6 +132,8 @@ impl ProcEntryType {
126132 ProcEntryType :: Stat => "/proc/stat" ,
127133 ProcEntryType :: CowInfo => "/proc/cowinfo" ,
128134 ProcEntryType :: Mounts => "/proc/mounts" ,
135+ ProcEntryType :: BreenixDir => "/proc/breenix" ,
136+ ProcEntryType :: BreenixTesting => "/proc/breenix/testing" ,
129137 // Dynamic entries don't have static paths
130138 ProcEntryType :: PidDir ( _) => "/proc/<pid>" ,
131139 ProcEntryType :: PidStatus ( _) => "/proc/<pid>/status" ,
@@ -153,14 +161,19 @@ impl ProcEntryType {
153161 ProcEntryType :: Stat => 6 ,
154162 ProcEntryType :: CowInfo => 7 ,
155163 ProcEntryType :: Mounts => 8 ,
164+ ProcEntryType :: BreenixDir => 200 ,
165+ ProcEntryType :: BreenixTesting => 201 ,
156166 ProcEntryType :: PidDir ( pid) => 10000 + pid,
157167 ProcEntryType :: PidStatus ( pid) => 20000 + pid,
158168 }
159169 }
160170
161171 /// Check if this is a directory
162172 pub fn is_directory ( & self ) -> bool {
163- matches ! ( self , ProcEntryType :: TraceDir | ProcEntryType :: PidDir ( _) )
173+ matches ! (
174+ self ,
175+ ProcEntryType :: TraceDir | ProcEntryType :: BreenixDir | ProcEntryType :: PidDir ( _)
176+ )
164177 }
165178}
166179
@@ -215,6 +228,10 @@ pub fn init() {
215228 procfs. entries . push ( ProcEntry :: new ( ProcEntryType :: CowInfo ) ) ;
216229 procfs. entries . push ( ProcEntry :: new ( ProcEntryType :: Mounts ) ) ;
217230
231+ // Register /proc/breenix directory and entries
232+ procfs. entries . push ( ProcEntry :: new ( ProcEntryType :: BreenixDir ) ) ;
233+ procfs. entries . push ( ProcEntry :: new ( ProcEntryType :: BreenixTesting ) ) ;
234+
218235 // Register /proc/trace directory and entries
219236 procfs. entries . push ( ProcEntry :: new ( ProcEntryType :: TraceDir ) ) ;
220237 procfs. entries . push ( ProcEntry :: new ( ProcEntryType :: TraceEnable ) ) ;
@@ -304,6 +321,7 @@ pub fn list_entries() -> Vec<String> {
304321 | ProcEntryType :: TraceBuffer
305322 | ProcEntryType :: TraceCounters
306323 | ProcEntryType :: TraceProviders
324+ | ProcEntryType :: BreenixTesting
307325 ) )
308326 . map ( |e| String :: from ( e. entry_type . name ( ) ) )
309327 . collect ( )
@@ -341,6 +359,17 @@ pub fn list_trace_entries() -> Vec<String> {
341359 . collect ( )
342360}
343361
362+ /// List entries in the /proc/breenix directory
363+ pub fn list_breenix_entries ( ) -> Vec < String > {
364+ let procfs = PROCFS . lock ( ) ;
365+ procfs
366+ . entries
367+ . iter ( )
368+ . filter ( |e| matches ! ( e. entry_type, ProcEntryType :: BreenixTesting ) )
369+ . map ( |e| String :: from ( e. entry_type . name ( ) ) )
370+ . collect ( )
371+ }
372+
344373/// Check if procfs is initialized
345374pub fn is_initialized ( ) -> bool {
346375 PROCFS . lock ( ) . initialized
@@ -373,6 +402,20 @@ pub fn read_entry(entry_type: ProcEntryType) -> Result<String, i32> {
373402 ProcEntryType :: Stat => Ok ( generate_stat ( ) ) ,
374403 ProcEntryType :: CowInfo => Ok ( generate_cowinfo ( ) ) ,
375404 ProcEntryType :: Mounts => Ok ( generate_mounts ( ) ) ,
405+ ProcEntryType :: BreenixDir => {
406+ // Directory listing
407+ Ok ( String :: from ( "testing\n " ) )
408+ }
409+ ProcEntryType :: BreenixTesting => {
410+ #[ cfg( feature = "testing" ) ]
411+ {
412+ Ok ( String :: from ( "1\n " ) )
413+ }
414+ #[ cfg( not( feature = "testing" ) ) ]
415+ {
416+ Ok ( String :: from ( "0\n " ) )
417+ }
418+ }
376419 ProcEntryType :: PidDir ( pid) => Ok ( generate_pid_dir ( pid) ) ,
377420 ProcEntryType :: PidStatus ( pid) => Ok ( generate_pid_status ( pid) ) ,
378421 }
0 commit comments