Kernel Bugs 2022-03-07 10:10:57 +00:00 committed by Git OBS Bridge
parent c17183ded5
commit 00b05d30bb

View File

@ -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";
}
}
}