3 # sysdump - dump /sys to a textformat
5 # Copyright 2005 David Schmitt <david@schmitt.edv-bus.at>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # Version 0.1: Initial prototype
29 #my $basedir = `systool -m`;
38 opendir(DIR, $dir) || die "can't opendir $dir: $!";
39 my @entries = grep { !/^\.\.?/ } readdir(DIR);
45 foreach my $entry (sort @entries)
47 dump_entry($level + 1, "$dir/$entry");
57 print $link, " -> ", readlink($link), "\n";
65 if ($file =~ "/sys/kernel/debug/.*") {
66 print("ignoring file $file\n");
69 if ($file =~ "/sys/kernel/security/apparmor/revision") {
70 print("ignoring file $file\n");
74 if (!open (FILE, "<$file")) {
75 print STDERR "can't open $file: '$!'\n";
82 $value = defined($value)?$value:"undef";
88 print $file, " = '", $value, "'\n";
96 return dump_link($level, $file) if -l $file;
97 return dump_dir($level, $file) if -d $file;
98 return dump_value($level, $file) if -r $file;
101 dump_dir(0, $basedir);