rendered paste body#!/usr/local/bin/perl
use File::Walker;
use Digest::MD5 qw(md5 md5_hex md5_base64);
use DB_File;
dbmopen %HASH, "/home/jamesr/DATABASE", 0666 or die "can't open\n";
my $walker = File::Walker->new( { start => "/tmp/foo", skip => "dl0" } );
my $file;
my $linkcount, $count;
my $tSize;
$|=1;
while ( $file = $walker->step() ) {
$count++;
my $curdir = $walker->curdir();
my $fullpath=$curdir . '/' . $file;
# print "At $fullpath\n";
if ( $file =~ /^[0-9]+\.$/ ) {
open(FILE, $fullpath) or die "Can't open '$fullpath': $!";
binmode(FILE);
$sum=Digest::MD5->new->addfile(FILE)->hexdigest;
if(exists $HASH{$sum}) {
print "Start stat()\n";
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($fullpath);
print "End stat()\n";
if($nlink==1) {
print "$fullpath can be relinked to $HASH{$sum}\n";
$linkcount++;
$tSize=$tSize+$size;
}
} else {
print "Adding hash\n";
$HASH{$sum} = $fullpath;
print "Done adding hash\n";
}
}
print "$count\r";
}
stats();
sub stats() {
print "Stats:\n";
print "\tTotal Files Seen: $count\n";
print "\tTotal Files Relinked: $linkcount\n";
print "\tTotal bytes saved: ~$tSize\n";
}
-- The truss
write(1, " A d d i n g h a s h\n", 12) = 12
Incurred fault #5, FLTACCESS %pc = 0xFEEA5BAC
siginfo: SIGBUS BUS_ADRALN addr=0x00000009
Received signal #10, SIGBUS [default]
siginfo: SIGBUS BUS_ADRALN addr=0x00000009