From d116a7a066ded40f839b9d24d181c6e6cc933fad Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Fri, 9 Jun 2017 22:08:03 +0200 Subject: [PATCH] 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 --- sysdump | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 $/; -- 2.1.4