<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <font face="Helvetica, Arial, sans-serif">What is a hard link?
      --> <a href="http://www.linfo.org/hard_link.html">http://www.linfo.org/hard_link.html</a><br>
      <br>
      Because of the nature of hard links, there's no way to know which
      hard link existed first or which one is to be considered the
      "original" file, because they point to the same underlying storage
      which has only one lastmod/atime/mtime timestamp set.<br>
      <br>
      As such, the official rule on the matter is that the
      asciibetically-first fully-qualified file name will be considered
      the original, while the other hard links should be considered, as
      already stated in the rules, "files already deduped".  The reason
      for this is strictly for output and reporting consistencies.  (We
      need this to maintain a standard baseline output format, which
      I'll set forth in another email coming soon).<br>
      <br>
    </font>
    <h3><font face="Helvetica, Arial, sans-serif">SCENARIO:</font><br>
    </h3>
    <font face="Helvetica, Arial, sans-serif">The three files below have
      identical content:<br>
      /foo/bar/baz.txt -> ( inode 12345 )<br>
      /foo/car/daz.txt -> ( inode 12345 )<br>
      /foo/far/gaz.txt -> ( inode 67890 )<br>
      <br>
    </font>
    <h3><font face="Helvetica, Arial, sans-serif">OUTCOME:</font><br>
    </h3>
    <font face="Helvetica, Arial, sans-serif">/foo/far/gaz.txt should be
      reported as a duplicate of /foo/bar/baz.txt because
      /foo/bar/baz.txt comes before /foo/car/daz.txt in a sort and
      because /foo/car/daz.txt is a hard link.<br>
      <br>
    </font>
    <h3><font face="Helvetica, Arial, sans-serif">CODE:</font><br>
    </h3>
    <font face="Helvetica, Arial, sans-serif">I'm doing it like this. 
      This is just an unoptimized example.  TIMTOWTDI.</font>
    <meta http-equiv="content-type" content="text/html;
      charset=ISO-8859-1">
    <br>
    <blockquote><big><tt># this will automatically throw out all but one
          hardlink, with the only surviving</tt><tt><br>
        </tt><tt># file name being the first asciibetically-sorted entry<br>
          <br>
        </tt><tt></tt><tt>$dev_inodes{ join '', ( stat $_ )[0,1] } = $_<br>
             for reverse sort @group_of_same_size_files_by_name;</tt><tt><br>
        </tt><tt><br>
        </tt><tt>next if scalar keys %dev_inodes == 1; # don't keep
          working if there's nothing to compare</tt><tt><br>
        </tt><tt><br>
        </tt><tt>for my file ( values %dev_inodes )</tt><tt><br>
        </tt><tt>{</tt><tt><br>
        </tt><tt>   do stuff to figure out which of the same-size files
          are duplicates...</tt><tt><br>
        </tt><tt>}</tt><tt><br>
        </tt></big></blockquote>
    <font face="Helvetica, Arial, sans-serif"><br>
      --Tommy Butler</font><br>
  </body>
</html>