summaryrefslogtreecommitdiffstats
path: root/move/tools/busy-files-accesses
blob: 241b68405fa3a53f8ee84fafaa45a03f881ea8d1 (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
26
27
28
29
30
31
32
33
34
#!/usr/bin/perl

use MDK::Common;
use Getopt::Long;

GetOptions('no-link' => \ (my $no_link), 
	   'no-dir' => \ (my $no_dir),
	   'full-dirs=s', \ (my $full_dirs),
	   'already-have=s', \ (my $already_have),
);

if ($full_dirs) {
    my @l = map { chomp_(MDK::Common::File::cat_or_die($_)) } split(' ', $full_dirs);
    $full_dirs = '/tmp/live_tree(' . join('|', map { quotemeta } @l) . ')/';
}
if ($already_have) {
    my @l = map { chomp_(MDK::Common::File::cat_or_die($_)) } split(' ', $already_have);
    $already_have = '(' . join('|', map { quotemeta } @l) . ')';
}

my ($file_list) = @ARGV;
foreach my $file (cat_($file_list)) {
    chomp $file;

    $file =~ m!/tmp/live_tree! or next;
    $already_have && $file =~ /^$already_have$/ and next;

    if (-l $file ? !$no_link : -d $file ? !$no_dir : 1) {
	my $s = $full_dirs && $file =~ /^$full_dirs/ ? "/tmp/live_tree$1" : $file;
	push @l, $s;
    }
}

print "$_\n" foreach sort(uniq(@l));