my $opt_32bit = 0; # Scan 32-bit kernel.
my $page_offset_32bit = 0; # Page offset for 32-bit kernel.
-# Do not parse these files (absolute path).
-my @skip_parse_files_abs = ('/proc/kmsg',
- '/proc/kcore',
- '/proc/fs/ext4/sdb1/mb_groups',
- '/proc/1/fd/3',
- '/sys/firmware/devicetree',
- '/proc/device-tree',
- '/sys/kernel/debug/tracing/trace_pipe',
- '/sys/kernel/security/apparmor/revision');
-
-# Do not parse these files under any subdirectory.
-my @skip_parse_files_any = ('0',
- '1',
- '2',
- 'pagemap',
- 'events',
- 'access',
- 'registers',
- 'snapshot_raw',
- 'trace_pipe_raw',
- 'ptmx',
- 'trace_pipe');
-
-# Do not walk these directories (absolute path).
-my @skip_walk_dirs_abs = ();
-
-# Do not walk these directories under any subdirectory.
-my @skip_walk_dirs_any = ('self',
- 'thread-self',
- 'cwd',
- 'fd',
- 'usbmon',
- 'stderr',
- 'stdin',
- 'stdout');
+# Skip these absolute paths.
+my @skip_abs = (
+ '/proc/kmsg',
+ '/proc/device-tree',
+ '/sys/firmware/devicetree',
+ '/sys/kernel/debug/tracing/trace_pipe',
+ '/sys/kernel/security/apparmor/revision');
+
+# Skip these under any subdirectory.
+my @skip_any = (
+ 'pagemap',
+ 'events',
+ 'access',
+ 'registers',
+ 'snapshot_raw',
+ 'trace_pipe_raw',
+ 'ptmx',
+ 'trace_pipe',
+ 'fd',
+ 'usbmon');
sub help
{
# True if we should skip this path.
sub skip
{
- my ($path, $paths_abs, $paths_any) = @_;
+ my ($path) = @_;
- foreach (@$paths_abs) {
+ foreach (@skip_abs) {
return 1 if (/^$path$/);
}
my($filename, $dirs, $suffix) = fileparse($path);
- foreach (@$paths_any) {
+ foreach (@skip_any) {
return 1 if (/^$filename$/);
}
return 0;
}
-sub skip_parse
-{
- my ($path) = @_;
- return skip($path, \@skip_parse_files_abs, \@skip_parse_files_any);
-}
-
sub timed_parse_file
{
my ($file) = @_;
return;
}
- if (skip_parse($file)) {
- dprint "skipping file: $file\n";
- return;
- }
- dprint "parsing: $file\n";
-
open my $fh, "<", $file or return;
while ( <$fh> ) {
if (may_leak_address($_)) {
close $fh;
}
-
-# True if we should skip walking this directory.
-sub skip_walk
-{
- my ($path) = @_;
- return skip($path, \@skip_walk_dirs_abs, \@skip_walk_dirs_any)
-}
-
# Recursively walk directory tree.
sub walk
{
my @dirs = @_;
while (my $pwd = shift @dirs) {
- next if (skip_walk($pwd));
next if (!opendir(DIR, $pwd));
my @files = readdir(DIR);
closedir(DIR);
my $path = "$pwd/$file";
next if (-l $path);
+ next if (skip($path));
+
if (-d $path) {
push @dirs, $path;
- } else {
- timed_parse_file($path);
+ next;
}
+
+ dprint "parsing: $path\n";
+ timed_parse_file($path);
}
}
}