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
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 $/;