rt-utils: Remove access to /sys/kernel/realtime
PATCH 1/1 rt-utils: Remove access to /sys/kernel/realtime
The json file reads /sys/kernel/realtime and then writes the attribute 'realtime' = 1 if its content was 1. That file is only created with the PREEMPT_RT patch applied will not be submitted upstream.
The information can be deducted from the uname(2) function which is used and all fields are written into the json file.
Set the 'realtime' attribute to 1 if the version field contains 'PREEMPT_RT'. This was always the case.
--- src/lib/rt-utils.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
src/lib/rt-utils.c +4 -11
@@ -508,11 +508,9 @@ void rt_write_json(const char *filename, int return_code,void (*cb)(FILE *,void *), void *data) { - unsigned char buf[1]; struct utsname uts;char ts_end[MAX_TS_SIZE ]; -FILE *f, *s; -size_t n; +FILE *f;int rt =0 ;if (!filename || !strcmp ("-" , filename)) {
@@ -525,17 +523,12 @@ void rt_write_json(const char *filename, int return_code,get_timestamp (ts_end); - s =fopen ("/sys/kernel/realtime" ,"r" ); -if (s) { - n =fread (buf,1 ,1 , s); -if (n ==1 && buf[0 ] =='1' ) - rt =1 ; -fclose (s); - } -if (uname (&uts))err_exit (errno,"Could not retrieve system information" ); +if (strstr (uts.version,"PREEMPT_RT" )) + rt =1 ; +fprintf (f,"{\n" );fprintf (f," \"file_version\": 1,\n" );fprintf (f," \"cmdline:\": \"%s\",\n" , test_cmdline);
Signature · 1 line
2.55.0
Quoted 8 lines · Sebastian Andrzej Siewior
The json file reads
/sys/kernel/realtimeand then writes the attribute 'realtime' = 1 if its content was 1. That file is only created with thePREEMPT_RTpatch applied will not be submitted upstream.
The information can be deducted from the uname(2) function which is used and all fields are written into the json file.Set the 'realtime' attribute to 1 if the version field contains '
PREEMPT_RT'. This was always the case.
Makes sense to get rid of the dependency on /sys/kernel/realtime. Thanks!
Quoted 1 line · Sebastian Andrzej Siewior
rt-utils: Remove access to
/sys/kernel/realtime