From: Michael Prokop Date: Fri, 9 Jun 2017 20:08:03 +0000 (+0200) Subject: sysdump: ignore files inside /sys/kernel/debug to avoid hanging X-Git-Tag: v0.13.2~1 X-Git-Url: http://git.grml.org/?a=commitdiff_plain;ds=sidebyside;h=d116a7a066ded40f839b9d24d181c6e6cc933fad;p=grml-hwinfo.git sysdump: ignore files inside /sys/kernel/debug to avoid hanging There are several files inside /sys/kernel/debug which aren't safe for cat-ing, like for example /sys/kernel/debug/hid/0003:80EE:0021.0001/events So ignore all files inside /sys/kernel/debug to avoid a hanging sysdump process. While at it avoid read on already closed file-handle and redirect error message to stderr if a file can't be opened/read. Closes grml/grml#55 --- diff --git a/sysdump b/sysdump index 17c2b9f..177424c 100755 --- a/sysdump +++ b/sysdump @@ -62,7 +62,15 @@ sub dump_value($$) my $level = shift; my $file = shift; - open (FILE, "<$file") || print "can't open $file: $!"; + if ($file =~ "/sys/kernel/debug/.*") { + print("ignoring file $file\n"); + return 0; + } + + if (!open (FILE, "<$file")) { + print STDERR "can't open $file: '$!'\n"; + return 0; + } my $value; { local $/;