From dcbb7fbe48c77998857e4ccd70d2fb29f41974f0 Mon Sep 17 00:00:00 2001 From: Nikola Pajkovsky Date: Wed, 24 Nov 2010 15:26:35 +0100 Subject: taint flag is decimal representation of a bitmask Signed-off-by: Nikola Pajkovsky --- src/plugins/KerneloopsScanner.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/plugins/KerneloopsScanner.cpp') diff --git a/src/plugins/KerneloopsScanner.cpp b/src/plugins/KerneloopsScanner.cpp index 39437969..93f37e07 100644 --- a/src/plugins/KerneloopsScanner.cpp +++ b/src/plugins/KerneloopsScanner.cpp @@ -121,16 +121,13 @@ int save_oops_to_debug_dump(GList **oopsList) VERB1 log("Saving %u oopses as crash dump dirs", idx >= countdown ? countdown-1 : idx); - char tainted[2] = {'x', '\0'}; + char *tainted_str = NULL; /* once tainted flag is set to 1, only restart can reset the flag to 0 */ - int tainted_fd = open("/proc/sys/kernel/tainted", O_RDONLY); - if (tainted_fd >= 0) + FILE *tainted_fd = fopen("/proc/sys/kernel/tainted", "r"); + if (tainted_fd) { - /* contain only 0 or 1 */ - if (read(tainted_fd, &tainted, 1) != 1) - error_msg("Unable to read one byte from /proc/sys/kernel/tainted"); - - close(tainted_fd); + tainted_str = xmalloc_fgetline(tainted_fd); + fclose(tainted_fd); } else error_msg("/proc/sys/kernel/tainted does not exist"); @@ -158,9 +155,10 @@ int save_oops_to_debug_dump(GList **oopsList) strchrnul(second_line, '\n')[0] = '\0'; dd_save_text(dd, FILENAME_REASON, second_line); - if (tainted[0] == '1') - dd_save_text(dd, FILENAME_TAINTED, tainted); + if (tainted_str && tainted_str[0] != '0') + dd_save_text(dd, FILENAME_TAINTED, tainted_str); + free(tainted_str); dd_close(dd); } else -- cgit