dm6: add comment about why we're not supporting non-ext[234] filesystems
[dupemerge] / dm6
diff --git a/dm6 b/dm6
index 26546983bccc5b0b1e1b3ae97e584df831163f85..44dcb9130318e4cad1c007a672f98fd5e6d88303 100755 (executable)
--- a/dm6
+++ b/dm6
@@ -67,7 +67,7 @@ sub link_files {
 }
 
 my $link_dir = shift @ARGV;
-(-d $link_dir) or usage;
+usage unless $link_dir;
 
 my $prefix_length = 3;
 
@@ -104,6 +104,8 @@ sub prepare_parents {
 }
 
 # ext3 cannot handle more than 32000 links to a file.  Leave some headroom.
+# Arguably this should be configurable, but the losses are miniscule and
+# the coding for option support is not.
 my $link_count_max = 31990;
 
 $/ = "\0";
@@ -125,7 +127,7 @@ while (<STDIN>) {
                        next if ($st->nlink > $link_count_max);
 
                        # Check link to inode
-                       my $inode_link = prepare_parents("$link_dir/inode", $st->ino);
+                       my $inode_link = prepare_parents($link_dir, $st->ino . 'I');
                        print STDERR 'I';
                        my $inode_st = lstat($inode_link);
                        my $update_links;
@@ -156,7 +158,7 @@ while (<STDIN>) {
                        $digest =~ y:/:_:;
 
                        # Check link to digest
-                       my $digest_link = prepare_parents("$link_dir/digest", $digest);
+                       my $digest_link = prepare_parents($link_dir, "${digest}D");
                        print STDERR 'D';
                        my $digest_st = lstat($digest_link);
                        if ($digest_st) {
@@ -189,9 +191,9 @@ while (<STDIN>) {
                        }
 
                        # A link to the inode indicates we are done, so do it last
-                       my $keep_link = prepare_parents("$link_dir/inode", $keep_ino);
-                       print STDERR '_';
-                       link_files($keep_link, $inode_link);
+                       $inode_link = prepare_parents($link_dir, "${keep_ino}I");
+                       print STDERR ' ';
+                       link_files($digest_link, $inode_link);
 
                }
        };
@@ -202,9 +204,9 @@ while (<STDIN>) {
 print STDERR "\nGarbage collection in '$link_dir'...";
 chdir($link_dir) || die "chdir: $link_dir: $!";
 print STDERR "\nRemoving files with link count < 3...";
-system("find digest inode -type f -links -3 -print0 | xargs -0 rm -f") and die "system: exit status $?";
+system("find . -type f -links -3 -print0 | xargs -0 rm -f") and die "system: exit status $?";
 print STDERR "\nRemoving empty directories...";
-system("find digest inode -type d -empty -print0 | xargs -0r rmdir -p --ignore-fail-on-non-empty") and die "system: exit status $?";
+system("find . -type d -empty -print0 | xargs -0r rmdir -p --ignore-fail-on-non-empty") and die "system: exit status $?";
 print STDERR "\nDone.\n";
 
 exit(0);