This commit is contained in:
parent
c17183ded5
commit
00b05d30bb
@ -1,31 +0,0 @@
|
|||||||
#!/usr/bin/perl
|
|
||||||
use strict;
|
|
||||||
use warnings;
|
|
||||||
|
|
||||||
$/="";
|
|
||||||
while (<>) {
|
|
||||||
chomp;
|
|
||||||
|
|
||||||
my %dups; # hash: inode -> array of filenames
|
|
||||||
foreach (split /\n/) {
|
|
||||||
my $inode = (stat)[1];
|
|
||||||
push @{$dups{$inode}}, $_;
|
|
||||||
}
|
|
||||||
|
|
||||||
my @keys = keys(%dups);
|
|
||||||
|
|
||||||
# all are hardlinks to the same data
|
|
||||||
next if (scalar @keys < 2);
|
|
||||||
|
|
||||||
# sort by nlink
|
|
||||||
@keys = sort { scalar $dups{$a} <=> scalar $dups{$b} } @keys;
|
|
||||||
my $target = $dups{shift @keys}[0];
|
|
||||||
|
|
||||||
foreach (@keys) {
|
|
||||||
foreach (@{$dups{$_}}) {
|
|
||||||
print "relinking $_ -> $target\n";
|
|
||||||
unlink($_);
|
|
||||||
link($target, $_) or die "link failed";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user