X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=faster-dupemerge;h=be6e29bc678bd78aec0d92fef00f030e8d829ef3;hb=629ed745a2842e156405cbb197ab854037ad7798;hp=8df7885878b2085bb2cfc8b61e05566c239225b0;hpb=7b251f6413738a3fef1a97ff6e74137460e03292;p=dupemerge diff --git a/faster-dupemerge b/faster-dupemerge index 8df7885..be6e29b 100755 --- a/faster-dupemerge +++ b/faster-dupemerge @@ -238,7 +238,7 @@ my @find_command = ('find', @directories, @extra_find_opts, '-type', 'f'); my $printf_string = '%s ' . ($collapse_access ? '0 0 0 ' : '%U %G %m ') . ($collapse_timestamp ? '0 ' : '%T@ ') . - '%D:%i %p\0'; + '%D %i %p\0'; push(@find_command, '!', '-empty') unless $collapse_zero; push(@find_command, '-printf', $printf_string); @@ -288,6 +288,13 @@ sub link_files { } } +# Convert $dev,$ino into a single string where lexical and numeric orderings are equivalent +sub format_inode ($$) { + my ($dev, $ino) = @_; + # 64 bits ought to be enough for everybody! + return sprintf('%016x:%016x', $dev, $ino); +} + # Process all known files so far. sub merge_files { $merges_attempted++; @@ -360,8 +367,8 @@ incumbent_file: next incumbent_file; } - if ($incumbent_ino != $incumbent) { - warn "$incumbent_file: expected inode $incumbent, found $incumbent_ino"; + if (format_inode($incumbent_dev, $incumbent_ino) ne $incumbent) { + warn "$incumbent_file: expected inode $incumbent, found $incumbent_dev:$incumbent_ino"; $surprises++; next incumbent_file; } @@ -380,8 +387,8 @@ candidate_file: next candidate_file; } - if ($candidate_ino != $candidate) { - warn "$candidate_file: expected inode $candidate, found $candidate_ino"; + if (format_inode($candidate_dev, $candidate_ino) ne $candidate) { + warn "$candidate_file: expected inode $candidate, found $candidate_dev:$candidate_ino"; $surprises++; next candidate_file; } @@ -543,9 +550,11 @@ end_merge: } while () { - my ($weak_key, $inode, $name) = m/^(\d+ \d+ \d+ \d+ -?[\d.]+) (\d+:\d+) (.+)\0$/so; + my ($weak_key, $dev, $ino, $name) = m/^(\d+ \d+ \d+ \d+ -?[\d.]+) (\d+) (\d+) (.+)\0$/so; die "read error: $!\nLast input line was '$_'" unless defined($name); + my $inode = format_inode($dev, $ino); + print STDERR "weak_key=$weak_key inode=$inode name=$name\n" if $debug; unless (! (-l $name) && (-f _)) {