Hardlink sub-directories and files

Grant Edwards invalid at invalid.invalid
Wed Aug 3 16:22:57 CEST 2011

On 2011-08-03, Kushal Kumaran <kushal.kumaran+python at gmail.com> wrote:
> On Wed, Aug 3, 2011 at 7:29 AM, Dan Stromberg <drsalists at gmail.com> wrote:
>> On Tue, Aug 2, 2011 at 3:13 AM, Thomas Jollans <t at jollybox.de> wrote:
>>> On 02/08/11 11:32, loial wrote:
>>> > I am trying to hardlink all files in a directory structure using
>>> > os.link.
>>> >
>>> > However I do not think it is possible to hard link directories ?
>> That is pretty true.?? I've heard of hardlinked directories on Solaris, but
>> that's kind of an exception to the general rule.
> In APUE, Richard Stevens says only root could do this,

Yep, in early versions of Solaris root could hard-link directories.
I did it once, and it's not something one did a second time.  fsck
couldn't deal with it and pretty much fell over.  IIRC, the only way
to recover was to clear several inodes manually and then let fsck
salvage things.

> if it is supported by the system at all.  In a footnote, he
> additionally mentions he screwed up his filesystem by creating a loop
> of hardlinked directories while writing that section of the book.

That sounds about right.

> I suppose it is a good thing systems don't allow that now.

It wouldn't be a problem, except there are some important places in
Unix where it is assume that filesystems are trees.  Hard linking
directories causes that assumption to be false.

Grant Edwards               grant.b.edwards        Yow! Somewhere in DOWNTOWN
                                  at               BURBANK a prostitute is
                              gmail.com            OVERCOOKING a LAMB CHOP!!

More information about the Python-list mailing list