find-runtime-roots.pl: Use Nix::Utils::readFile
This commit is contained in:
parent
772b70952f
commit
938092a213
1 changed files with 15 additions and 19 deletions
|
@ -1,19 +1,18 @@
|
||||||
#! @perl@ -w
|
#! @perl@ -w @perlFlags@
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
use Nix::Utils;
|
||||||
my $procDir = "/proc";
|
|
||||||
|
|
||||||
|
|
||||||
sub readProc {
|
sub readProc {
|
||||||
return unless -d $procDir;
|
return unless -d "/proc";
|
||||||
|
|
||||||
opendir DIR, $procDir or return;
|
opendir DIR, "/proc" or return;
|
||||||
|
|
||||||
foreach my $name (readdir DIR) {
|
foreach my $name (readdir DIR) {
|
||||||
next unless $name =~ /^\d+$/;
|
next unless $name =~ /^\d+$/;
|
||||||
|
|
||||||
my $process = "$procDir/$name";
|
my $process = "/proc/$name";
|
||||||
|
|
||||||
#print STDERR "=== $process\n";
|
#print STDERR "=== $process\n";
|
||||||
|
|
||||||
|
@ -58,18 +57,15 @@ readProc;
|
||||||
lsof;
|
lsof;
|
||||||
|
|
||||||
|
|
||||||
sub readFile {
|
sub printFile {
|
||||||
my $path = shift;
|
my ($fn) = @_;
|
||||||
if (-e $path) {
|
if (-e $fn) {
|
||||||
if (open FILE, "$path") {
|
print Nix::Utils::readFile($fn), "\n";
|
||||||
while (<FILE>) {
|
|
||||||
print;
|
|
||||||
}
|
|
||||||
close FILE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# This is rather NixOS-specific, so it probably shouldn't be here.
|
# This is rather NixOS-specific, so it probably shouldn't be here.
|
||||||
readFile "/proc/sys/kernel/modprobe";
|
printFile "/proc/sys/kernel/modprobe";
|
||||||
readFile "/proc/sys/kernel/fbsplash";
|
printFile "/proc/sys/kernel/fbsplash";
|
||||||
|
printFile "/proc/sys/kernel/poweroff_cmd";
|
||||||
|
|
Loading…
Reference in a new issue