summaryrefslogtreecommitdiffstats
path: root/move/tools/busy-files
blob: 5c770c561fecd991aaaaf5f50251fc1e5503d18b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/perl

use MDK::Common;

my @pids = grep { $_ ne $$ && /^(\d+)$/ } all('/proc');

my @l = map {
    grep {
	$_ && !m!^(/proc/|/dev/|pipe:|socket:)!;
    } map { readlink($_) } "/proc/$_/exe", glob_("/proc/$_/fd/*");
} @pids;

push @l, grep { $_ } map { (split)[5] } map { cat_("/proc/$_/maps") } @pids;

if ($ARGV[0] eq '--totem') {
    @l = grep { m!/image(_boot|_raw)?/! } @l;
    $ARGV[0] = '--server';
}
foreach (uniq @l) {
    if ($ARGV[0] eq '--server') {
	s!/image(_always|_boot|_totem)?/!/tmp/live_tree/!;
	s!/image_raw/live_tree!/tmp/live_tree!;
    }
    print "$_\n";
}