From: Michael Prokop Date: Fri, 5 Mar 2021 15:13:25 +0000 (+0100) Subject: sysdump: rework ignore list code and ignore further files X-Git-Tag: v0.16.0~4 X-Git-Url: http://git.grml.org/?p=grml-hwinfo.git;a=commitdiff_plain;h=3d53667bbd60379625f120ed3b90a5097f1cb248 sysdump: rework ignore list code and ignore further files When getting towards /sys/kernel/tracing, the script is known to hang at least at the following files: * /sys/kernel/tracing/trace_pipe * /sys/kernel/tracing/per_cpu/cpu[0-9]+/trace_pipe * /sys/kernel/tracing/per_cpu/cpu[0-9]+/trace_pipe_raw * /sys/kernel/tracing/per_cpu/cpu[0-9]+/snapshot_raw So we need to extend the list of files to be ignored. While at it, rework the checks and ignore a bunch of further files, that can't be read, e.g. due to "Permission denied". FTR, we sadly can't ignore "/sys/.*/uevent" files globally, as there are a bunch of files that contain and also provide actual data. Thanks: Darshaka Patirana for tracking down the /sys/kernel/tracing/* issue Closes: grml/grml-hwinfo#3 --- diff --git a/sysdump b/sysdump index e83738b..ea1a250 100755 --- a/sysdump +++ b/sysdump @@ -8,12 +8,12 @@ # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA @@ -62,13 +62,45 @@ sub dump_value($$) my $level = shift; my $file = shift; - if ($file =~ "/sys/kernel/debug/.*") { - print("ignoring file $file\n"); - return 0; - } - if ($file =~ "/sys/kernel/security/apparmor/revision") { - print("ignoring file $file\n"); - return 0; + # ignore list: files that we can't read or are known to cause problems + SWITCH: for ($file) { + ( + /.*\/bind$/ || + /.*\/clear$/ || + /.*\/delete$/ || + /.*\/delete_device$/ || + /.*\/drivers_probe$/ || + /.*\/host_reset$/ || + /.*\/new_device$/ || + /.*\/new_id$/ || + /.*\/reconfig$/ || + /.*\/remove$/ || + /.*\/remove_id$/ || + /.*\/rescan$/ || + /.*\/reset$/ || + /.*\/scan$/ || + /\/sys\/class\/gpio\/export$/ || + /\/sys\/class\/gpio\/unexport$/ || + /\/sys\/devices\/platform\/i8042\/serio[0-9]+\/drvctl$/ || + /\/sys\/devices\/system\/clockevents\/clockevent[0-9]+\/unbind_device$/ || + /\/sys\/devices\/system\/clocksource\/clocksource[0-9]+\/unbind_clocksource$/ || + /\/sys\/devices\/system\/memory\/hard_offline_page$/ || + /\/sys\/devices\/system\/memory\/soft_offline_page$/ || + /\/sys\/devices\/system\/node\/node[0-9]\/compact$/ || + /\/sys\/devices\/virtual\/graphics\/fbcon\/rotate_all$/ || + /\/sys\/firmware\/efi\/vars\/del_var$/ || + /\/sys\/firmware\/efi\/vars\/new_var$/ || + /\/sys\/kernel\/debug\/.*/ || + /\/sys\/kernel\/security\/apparmor\/revision$/ || + /\/sys\/kernel\/tracing\/per_cpu\/cpu[0-9]+\/snapshot_raw$/ || + /\/sys\/kernel\/tracing\/per_cpu\/cpu[0-9]+\/trace_pipe.*/ || + /\/sys\/kernel\/tracing\/trace_pipe/ || + /\/sys\/module\/md_mod\/parameters\/new_array$/ || + /.*\/unbind$/ + ) && do { + print "ignoring file $file\n"; + return 0; + } } if (!open (FILE, "<$file")) {