2013-04-26 11:44:19 +02:00
|
|
|
#! @perl@ -w @perlFlags@
|
2006-07-19 18:49:59 +02:00
|
|
|
|
|
|
|
use strict;
|
2013-04-26 11:44:19 +02:00
|
|
|
use Nix::Utils;
|
2006-07-19 18:49:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
sub readProc {
|
2013-04-26 11:44:19 +02:00
|
|
|
return unless -d "/proc";
|
|
|
|
|
|
|
|
opendir DIR, "/proc" or return;
|
2006-07-19 18:49:59 +02:00
|
|
|
|
|
|
|
foreach my $name (readdir DIR) {
|
|
|
|
next unless $name =~ /^\d+$/;
|
|
|
|
|
2013-04-26 11:44:19 +02:00
|
|
|
my $process = "/proc/$name";
|
2006-07-19 18:49:59 +02:00
|
|
|
|
|
|
|
#print STDERR "=== $process\n";
|
2013-04-26 11:44:19 +02:00
|
|
|
|
2006-07-19 18:49:59 +02:00
|
|
|
my $target;
|
|
|
|
print "$target\n" if $target = readlink "$process/exe";
|
|
|
|
print "$target\n" if $target = readlink "$process/cwd";
|
|
|
|
|
|
|
|
if (opendir FDS, "$process/fd") {
|
|
|
|
foreach my $name (readdir FDS) {
|
|
|
|
$target = readlink "$process/fd/$name";
|
|
|
|
print "$target\n" if $target && substr($target, 0, 1) eq "/";
|
|
|
|
}
|
|
|
|
closedir FDS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (open MAP, "<$process/maps") {
|
|
|
|
while (<MAP>) {
|
|
|
|
next unless /^ \s* \S+ \s+ \S+ \s+ \S+ \s+ \S+ \s+ \S+ \s+ (\/\S+) \s* $/x;
|
|
|
|
print "$1\n";
|
|
|
|
}
|
|
|
|
close MAP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
closedir DIR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub lsof {
|
2006-09-20 17:14:19 +02:00
|
|
|
return unless open LSOF, "lsof -n -w -F n 2> /dev/null |";
|
2006-07-19 18:49:59 +02:00
|
|
|
|
|
|
|
while (<LSOF>) {
|
|
|
|
next unless /^n (\/ .*)$/x;
|
|
|
|
print $1, "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
close LSOF;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
readProc;
|
|
|
|
lsof;
|
2007-03-20 12:13:15 +01:00
|
|
|
|
|
|
|
|
2013-04-26 11:44:19 +02:00
|
|
|
sub printFile {
|
|
|
|
my ($fn) = @_;
|
|
|
|
if (-e $fn) {
|
|
|
|
print Nix::Utils::readFile($fn), "\n";
|
2007-03-20 12:13:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-26 11:44:19 +02:00
|
|
|
|
2007-03-20 12:13:15 +01:00
|
|
|
# This is rather NixOS-specific, so it probably shouldn't be here.
|
2013-04-26 11:44:19 +02:00
|
|
|
printFile "/proc/sys/kernel/modprobe";
|
|
|
|
printFile "/proc/sys/kernel/fbsplash";
|
|
|
|
printFile "/proc/sys/kernel/poweroff_cmd";
|