<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000099">
<br>
Smoot Carl-Mitchell wrote:
<blockquote cite="mid:1239733713.1813.18.camel@smoot.tic.com"
 type="cite">
  <pre wrap="">On Tue, 2009-04-14 at 19:45 +1200, Tim Frost wrote:

  </pre>
  <blockquote type="cite">
    <blockquote type="cite">
      <pre wrap="">Is it possible to create a hard link to a directory somehow?
      </pre>
    </blockquote>
    <pre wrap="">No. In general, a directory is a container, and as such it defines a
place in the tree which holds files (and other directories).  That
container only makes sense in that one place in the tree.
    </pre>
  </blockquote>
  <pre wrap=""><!---->
Hardlinks to directories are not allowed, except when creating a
directory.  A hard link is created to a new directory's parent directory
with the name ".." and linked to itself with the name ".".  This
standard is the way the utilities walk up the filesystem hierarchy.  The
"/" directory has the ".." hardlink point to itself.

This is the only case where hardlinks to directories appear in the
filesystem hierarchy.  Some Unices do allow userland programs to create
directory hardlinks, but it is inadvisable to do this, since many of the
standard utilities depend on this not being the case.  You can see the
hardlink count with the ls -la command. The -a lets you see the
directory links and all the hidden files in a directory.  The link count
is the number after the permissions.  A directory with lots of
subdirectories will have a lot of hardlinks.  Adding "-i" as an option
will let you display the inode number which is the only unique
identifier for each file.
  </pre>
</blockquote>
Apparently you all haven't had the pleasure of working with cPanel's
WHM product.  WHM uses something called virtfs to create chroot
environments for users to SSH into, and for SuEXEC PHP scripts to run
inside.  What's fantastic about how they do it is that they hardlink
the /home/username directory inside /home/virtfs/username/home/, and
they hardlink the /lib directory in /home/virtfs/username/lib.  What's
especially great about this is that you do some cleanup of accounts and
write yourself a little script to remove home directories not owned by
current users, next thing you know rm -r hits /home/virtfs and you
remove /lib/ldlinux.so.2.<br>
<br>
Wanna know a fun error message?<br>
bash: ls: ELF Interpreter not found: /lib/ldlinux.so.2<br>
<br>
That is why directories shouldn't be hardlinked.  :)<br>
<br>
- Kyle<br>
</body>
</html>